Skip to content

Commit

Permalink
Merge pull request #1106 from rust-lang/monaco-font-measure
Browse files Browse the repository at this point in the history
Ensure Monaco measures fonts after the font is loaded
  • Loading branch information
shepmaster authored Oct 9, 2024
2 parents efd614b + a66d813 commit 08c5f86
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ui/frontend/editor/MonacoEditorCore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import { themeVsDarkPlus } from './rust_monaco_def';

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

async function remeasureFontWhenReady(fonts: FontFaceSet, font: string) {
while (!fonts.check(font)) {
await fonts.ready;
}

monaco.editor.remeasureFonts();
}

function useEditorProp<T>(
editor: monaco.editor.IStandaloneCodeEditor | null,
prop: T,
Expand Down Expand Up @@ -68,6 +76,8 @@ const MonacoEditorCore: React.FC<CommonEditorProps> = (props) => {
});
setEditor(editor);

remeasureFontWhenReady(document.fonts, nodeStyle.font);

editor.focus();
}, []);

Expand Down

0 comments on commit 08c5f86

Please sign in to comment.