Skip to content

Commit 97bd007

Browse files
committed
Properly update font info for Monaco
1 parent 2c621cb commit 97bd007

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

packages/app/src/app/components/CodeEditor/Monaco/MonacoReactComponent.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,23 @@ class MonacoEditor extends React.PureComponent {
6464
// Font is eg. '"aaaa"'
6565
firstFont = JSON.parse(firstFont);
6666
}
67-
const font = new FontFaceObserver(firstFont);
6867

69-
font.load().then(
70-
() => {
71-
if (this.editor && this.props.getEditorOptions) {
72-
this.editor.updateOptions(this.props.getEditorOptions());
68+
if (firstFont === 'dm') {
69+
const font = new FontFaceObserver(firstFont);
70+
71+
font.load().then(
72+
() => {
73+
if (this.editor && this.props.getEditorOptions) {
74+
this.editor.updateOptions(this.props.getEditorOptions());
75+
}
76+
},
77+
() => {
78+
// Font was not loaded in 3s, do nothing
7379
}
74-
},
75-
() => {
76-
// Font was not loaded in 3s, do nothing
77-
}
78-
);
80+
);
7981

80-
appliedOptions.fontFamily = fonts.slice(1).join(', ');
82+
appliedOptions.fontFamily = fonts.slice(1).join(', ');
83+
}
8184

8285
this.editor = context.monaco.editor[
8386
diffEditor ? 'createDiffEditor' : 'create'

packages/app/src/app/components/CodeEditor/Monaco/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ class MonacoEditor extends React.Component<Props, State> implements Editor {
184184
this.editor = editor;
185185
this.monaco = monaco;
186186

187-
this.editor.updateOptions(this.getEditorOptions());
188-
189187
// eslint-disable-next-line no-underscore-dangle
190188
window.CSEditor = {
191189
editor: this.editor,

0 commit comments

Comments
 (0)