[英]Getting fontInfo from monaco-editor instance?
I'm trying to get the typicalFullwidthCharacterWidth
property which is available in the FontInfo
class of monaco.editor
.我试图让
typicalFullwidthCharacterWidth
财产可在FontInfo
类的monaco.editor
。
As shown in the monaco-editor docs:如 monaco-editor 文档所示:
https://microsoft.github.io/monaco-editor/api/classes/monaco.editor.fontinfo.html https://microsoft.github.io/monaco-editor/api/classes/monaco.editor.fontinfo.html
Upon looking into the Minimap component which uses options.get(...)
:在查看使用
options.get(...)
的 Minimap 组件后:
https://github.com/microsoft/vscode/blob/f74e473238aca7b79c08be761d99a0232838ca4c/src/vs/editor/browser/viewParts/minimap/minimap.ts#L108 https://github.com/microsoft/vscode/blob/f74e473238aca7b79c08be761d99a0232838ca4c/src/vs/editor/browser/viewParts/minimap/minimap.ts#L108
Is it possible to get this publically?是否可以公开获取此信息?
I've found the solution, you have to use the IEditor.getOption
function:我找到了解决方案,您必须使用
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", …}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.