从摩纳哥编辑器实例获取fontInfo?

问题描述

我正在尝试获取typicalFullwidthCharacterWidth的{​​{1}}类中可用的FontInfo属性。

如摩纳哥编辑文档中所示:

monaco.editor documentation

https://microsoft.github.io/monaco-editor/api/classes/monaco.editor.fontinfo.html

查看使用monaco.editor的Minimap组件:

monaco-editor minimap component

https://github.com/microsoft/vscode/blob/f74e473238aca7b79c08be761d99a0232838ca4c/src/vs/editor/browser/viewParts/minimap/minimap.ts#L108

是否可以公开获取?

解决方法

我已经找到了解决方案,您必须使用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", …}

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...