Skip to content

Commit 08c5f86

Browse files
authored
Merge pull request #1106 from rust-lang/monaco-font-measure
Ensure Monaco measures fonts after the font is loaded
2 parents efd614b + a66d813 commit 08c5f86

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ui/frontend/editor/MonacoEditorCore.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ import { themeVsDarkPlus } from './rust_monaco_def';
88

99
import * as styles from './Editor.module.css';
1010

11+
async function remeasureFontWhenReady(fonts: FontFaceSet, font: string) {
12+
while (!fonts.check(font)) {
13+
await fonts.ready;
14+
}
15+
16+
monaco.editor.remeasureFonts();
17+
}
18+
1119
function useEditorProp<T>(
1220
editor: monaco.editor.IStandaloneCodeEditor | null,
1321
prop: T,
@@ -68,6 +76,8 @@ const MonacoEditorCore: React.FC<CommonEditorProps> = (props) => {
6876
});
6977
setEditor(editor);
7078

79+
remeasureFontWhenReady(document.fonts, nodeStyle.font);
80+
7181
editor.focus();
7282
}, []);
7383

0 commit comments

Comments
 (0)