从 monaco-editor 实例获取 fontInfo?
Getting fontInfo from monaco-editor instance?
我正在尝试获取 typicalFullwidthCharacterWidth
属性 monaco.editor
class 中可用的 monaco.editor
。
如 monaco-editor 文档所示:
https://microsoft.github.io/monaco-editor/api/classes/monaco.editor.fontinfo.html
查看使用options.get(...)
的Minimap组件:
是否可以将其公开?
我找到了解决办法,你必须使用IEditor.getOption
函数:
var editor = monaco.editor.create(document.getElementById("container"), {
value: "// ... some text content",
language: "javascript",
});
// https://github.com/Microsoft/monaco-editor/blob/master/monaco.d.ts#L3667
const EDITOR_OPTION_FONT_INFO = 34;
// Get the font info from options using the fontInfo option id
const fontInfo = editor.getOption(EDITOR_OPTION_FONT_INFO);
console.log(fontInfo) // Output: {zoomLevel: 0, fontFamily: "Roboto", fontWeight: "400", fontSize: 14, fontFeatureSettings: ""liga" off, "calt" off", …}
我正在尝试获取 typicalFullwidthCharacterWidth
属性 monaco.editor
class 中可用的 monaco.editor
。
如 monaco-editor 文档所示:
https://microsoft.github.io/monaco-editor/api/classes/monaco.editor.fontinfo.html
查看使用options.get(...)
的Minimap组件:
是否可以将其公开?
我找到了解决办法,你必须使用IEditor.getOption
函数:
var editor = monaco.editor.create(document.getElementById("container"), {
value: "// ... some text content",
language: "javascript",
});
// https://github.com/Microsoft/monaco-editor/blob/master/monaco.d.ts#L3667
const EDITOR_OPTION_FONT_INFO = 34;
// Get the font info from options using the fontInfo option id
const fontInfo = editor.getOption(EDITOR_OPTION_FONT_INFO);
console.log(fontInfo) // Output: {zoomLevel: 0, fontFamily: "Roboto", fontWeight: "400", fontSize: 14, fontFeatureSettings: ""liga" off, "calt" off", …}