Skip to content

Commit f342601

Browse files
committed
Merge pull request #106217 from DeeJayLSP/variable-weights-editor
Force weights on custom editor fonts when variable
2 parents 31c3c8d + 0d4d0d4 commit f342601

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

doc/classes/EditorSettings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,9 +902,11 @@
902902
</member>
903903
<member name="interface/editor/main_font" type="String" setter="" getter="">
904904
The font to use for the editor interface. Must be a resource of a [Font] type such as a [code].ttf[/code] or [code].otf[/code] font file.
905+
[b]Note:[/b] If the provided font is variable, a weight of 400 (normal) will be used.
905906
</member>
906907
<member name="interface/editor/main_font_bold" type="String" setter="" getter="">
907908
The font to use for bold text in the editor interface. Must be a resource of a [Font] type such as a [code].ttf[/code] or [code].otf[/code] font file.
909+
[b]Note:[/b] If the provided font is variable, a weight of 700 (bold) will be used.
908910
</member>
909911
<member name="interface/editor/main_font_size" type="int" setter="" getter="">
910912
The size of the font in the editor interface.

editor/themes/editor_fonts.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
249249
}
250250
default_fc->set_spacing(TextServer::SPACING_TOP, -EDSCALE);
251251
default_fc->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE);
252+
Dictionary default_fc_opentype;
253+
default_fc_opentype["weight"] = 400;
254+
default_fc->set_variation_opentype(default_fc_opentype);
252255

253256
Ref<FontVariation> default_fc_msdf;
254257
default_fc_msdf.instantiate();
@@ -265,6 +268,7 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
265268
}
266269
default_fc_msdf->set_spacing(TextServer::SPACING_TOP, -EDSCALE);
267270
default_fc_msdf->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE);
271+
default_fc_msdf->set_variation_opentype(default_fc_opentype);
268272

269273
Ref<FontVariation> bold_fc;
270274
bold_fc.instantiate();
@@ -289,6 +293,9 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
289293
}
290294
bold_fc->set_spacing(TextServer::SPACING_TOP, -EDSCALE);
291295
bold_fc->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE);
296+
Dictionary bold_fc_opentype;
297+
bold_fc_opentype["weight"] = 700;
298+
bold_fc->set_variation_opentype(bold_fc_opentype);
292299

293300
Ref<FontVariation> bold_fc_msdf;
294301
bold_fc_msdf.instantiate();
@@ -313,6 +320,7 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
313320
}
314321
bold_fc_msdf->set_spacing(TextServer::SPACING_TOP, -EDSCALE);
315322
bold_fc_msdf->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE);
323+
bold_fc_msdf->set_variation_opentype(bold_fc_opentype);
316324

317325
Ref<FontVariation> mono_fc;
318326
mono_fc.instantiate();

0 commit comments

Comments
 (0)