From 0d4d0d44c9c820329bf2c94374e1bfa929e785d6 Mon Sep 17 00:00:00 2001 From: DeeJayLSP Date: Fri, 9 May 2025 14:55:51 -0300 Subject: [PATCH] Force weights on custom editor fonts when variable --- doc/classes/EditorSettings.xml | 2 ++ editor/themes/editor_fonts.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index 9a3e6087d2..cbdb484a45 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -899,9 +899,11 @@ 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. + [b]Note:[/b] If the provided font is variable, a weight of 400 (normal) will be used. 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. + [b]Note:[/b] If the provided font is variable, a weight of 700 (bold) will be used. The size of the font in the editor interface. diff --git a/editor/themes/editor_fonts.cpp b/editor/themes/editor_fonts.cpp index e283f0342a..372393c67c 100644 --- a/editor/themes/editor_fonts.cpp +++ b/editor/themes/editor_fonts.cpp @@ -249,6 +249,9 @@ void editor_register_fonts(const Ref &p_theme) { } default_fc->set_spacing(TextServer::SPACING_TOP, -EDSCALE); default_fc->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE); + Dictionary default_fc_opentype; + default_fc_opentype["weight"] = 400; + default_fc->set_variation_opentype(default_fc_opentype); Ref default_fc_msdf; default_fc_msdf.instantiate(); @@ -265,6 +268,7 @@ void editor_register_fonts(const Ref &p_theme) { } default_fc_msdf->set_spacing(TextServer::SPACING_TOP, -EDSCALE); default_fc_msdf->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE); + default_fc_msdf->set_variation_opentype(default_fc_opentype); Ref bold_fc; bold_fc.instantiate(); @@ -289,6 +293,9 @@ void editor_register_fonts(const Ref &p_theme) { } bold_fc->set_spacing(TextServer::SPACING_TOP, -EDSCALE); bold_fc->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE); + Dictionary bold_fc_opentype; + bold_fc_opentype["weight"] = 700; + bold_fc->set_variation_opentype(bold_fc_opentype); Ref bold_fc_msdf; bold_fc_msdf.instantiate(); @@ -313,6 +320,7 @@ void editor_register_fonts(const Ref &p_theme) { } bold_fc_msdf->set_spacing(TextServer::SPACING_TOP, -EDSCALE); bold_fc_msdf->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE); + bold_fc_msdf->set_variation_opentype(bold_fc_opentype); Ref mono_fc; mono_fc.instantiate();