如何解决从摩纳哥编辑器实例获取fontInfo?
我正在尝试获取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", …}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。