summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-09-14 17:42:58 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-09-14 17:42:58 +0200
commitbbed0b43f7ac19f882d9a453d9b22689d4d844f7 (patch)
treeacfa0937cbd699c780dad8213a24820c6b23ac69
parent5ff8e4ee67de5bff0f5c4f75429e8cc202493adb (diff)
parente94ac75d3da19dfeb6cf577585795e977ae3e3d7 (diff)
Merge pull request #65774 from bruvzg/no_mono_hinting
Do not use horizontal hinting for the editor monospace font.
-rw-r--r--doc/classes/TextServer.xml1
-rw-r--r--editor/editor_fonts.cpp10
2 files changed, 9 insertions, 2 deletions
diff --git a/doc/classes/TextServer.xml b/doc/classes/TextServer.xml
index 0db16b491d..2e67c61e54 100644
--- a/doc/classes/TextServer.xml
+++ b/doc/classes/TextServer.xml
@@ -1720,6 +1720,7 @@
</constant>
<constant name="HINTING_NORMAL" value="2" enum="Hinting">
Use the default font hinting mode (crisper but less smooth).
+ [b]Note:[/b] This hinting mode changes both horizontal and vertical glyph metrics. If applied to monospace font, some glyphs might have different width.
</constant>
<constant name="SUBPIXEL_POSITIONING_DISABLED" value="0" enum="SubpixelPositioning">
Glyph horizontal position is rounded to the whole pixel size, each glyph is rasterized once.
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index fffe77f1c4..c31d13d122 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -96,6 +96,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
TextServer::SubpixelPositioning font_subpixel_positioning = (TextServer::SubpixelPositioning)(int)EditorSettings::get_singleton()->get("interface/editor/font_subpixel_positioning");
TextServer::Hinting font_hinting;
+ TextServer::Hinting font_mono_hinting;
switch (font_hinting_setting) {
case 0:
// The "Auto" setting uses the setting that best matches the OS' font rendering:
@@ -104,18 +105,23 @@ void editor_register_fonts(Ref<Theme> p_theme) {
// - Linux has configurable font hinting, but most distributions including Ubuntu default to "Light".
#ifdef MACOS_ENABLED
font_hinting = TextServer::HINTING_NONE;
+ font_mono_hinting = TextServer::HINTING_NONE;
#else
font_hinting = TextServer::HINTING_LIGHT;
+ font_mono_hinting = TextServer::HINTING_LIGHT;
#endif
break;
case 1:
font_hinting = TextServer::HINTING_NONE;
+ font_mono_hinting = TextServer::HINTING_NONE;
break;
case 2:
font_hinting = TextServer::HINTING_LIGHT;
+ font_mono_hinting = TextServer::HINTING_LIGHT;
break;
default:
font_hinting = TextServer::HINTING_NORMAL;
+ font_mono_hinting = TextServer::HINTING_LIGHT;
break;
}
@@ -163,7 +169,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
default_font_bold->set_fallbacks(fallbacks_bold);
default_font_bold_msdf->set_fallbacks(fallbacks_bold);
- Ref<FontFile> default_font_mono = load_internal_font(_font_JetBrainsMono_Regular, _font_JetBrainsMono_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning);
+ Ref<FontFile> default_font_mono = load_internal_font(_font_JetBrainsMono_Regular, _font_JetBrainsMono_Regular_size, font_mono_hinting, font_antialiasing, true, font_subpixel_positioning);
default_font_mono->set_fallbacks(fallbacks);
// Init base font configs and load custom fonts.
@@ -260,7 +266,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
Ref<FontVariation> mono_fc;
mono_fc.instantiate();
if (custom_font_path_source.length() > 0 && dir->file_exists(custom_font_path_source)) {
- Ref<FontFile> custom_font = load_external_font(custom_font_path_source, font_hinting, font_antialiasing, true, font_subpixel_positioning);
+ Ref<FontFile> custom_font = load_external_font(custom_font_path_source, font_mono_hinting, font_antialiasing, true, font_subpixel_positioning);
{
TypedArray<Font> fallback_custom;
fallback_custom.push_back(default_font_mono);