如何设置摩纳哥的字体样式?



我需要在编辑器中以斜体显示单词。我该怎么做?当我把它传递给create时,我没有发现如何在IStandaloneEditorConstructionOptions选项中设置它,只有如何用defineTheme()这样指定它:

monaco.editor.defineTheme('placeHolderTheme', {
base: 'vs-dark',
inherit: false,
rules: [

{ 
token: 'my-token',
foreground: '#311b92',
fontStyle: 'italic' 
},
colors: {
"editor.background": "#2B2B2B",
'editor.foreground': '#FFFFFF',
}
});

但我确实需要一次设置整个文本。怎么能做到呢?

只能在编辑器中为语法标记设置字体样式。如果要为所有令牌设置样式,请定义一个匹配为空的令牌,并将其设置在那里:https://microsoft.github.io/monaco-editor/playground.html#customizing-外观标记和颜色。

monaco.editor.defineTheme('myCustomTheme', {
base: 'vs', // can also be vs-dark or hc-black
inherit: true, // can also be false to completely replace the builtin rules
rules: [
{ token: '', fontStyle: 'italic' },
{ token: 'comment', foreground: 'ffa500', fontStyle: 'italic underline' },
{ token: 'comment.js', foreground: '008800', fontStyle: 'bold' },
{ token: 'comment.css', foreground: '0000ff' } // will inherit fontStyle from `comment` above
],
colors: {
'editor.foreground': '#000000'
}
});

最新更新