问题描述
我正在尝试获取typicalFullwidthCharacterWidth
的{{1}}类中可用的FontInfo
属性。
如摩纳哥编辑文档中所示:
https://microsoft.github.io/monaco-editor/api/classes/monaco.editor.fontinfo.html
查看使用monaco.editor
的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", …}