diff options
Diffstat (limited to 'editor/editor_fonts.cpp')
-rw-r--r-- | editor/editor_fonts.cpp | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 40ecffbb3b..55cae35a4a 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -93,8 +93,32 @@ void editor_register_fonts(Ref<Theme> p_theme) { /* Custom font */ - bool font_antialiased = (bool)EditorSettings::get_singleton()->get("interface/editor/main_font_antialiased"); - DynamicFontData::Hinting font_hinting = (DynamicFontData::Hinting)(int)EditorSettings::get_singleton()->get("interface/editor/main_font_hinting"); + bool font_antialiased = (bool)EditorSettings::get_singleton()->get("interface/editor/font_antialiased"); + int font_hinting_setting = (int)EditorSettings::get_singleton()->get("interface/editor/font_hinting"); + + DynamicFontData::Hinting font_hinting; + switch (font_hinting_setting) { + case 0: + // The "Auto" setting uses the setting that best matches the OS' font rendering: + // - macOS doesn't use font hinting. + // - Windows uses ClearType, which is in between "Light" and "Normal" hinting. + // - Linux has configurable font hinting, but most distributions including Ubuntu default to "Light". +#ifdef OSX_ENABLED + font_hinting = DynamicFontData::HINTING_NONE; +#else + font_hinting = DynamicFontData::HINTING_LIGHT; +#endif + break; + case 1: + font_hinting = DynamicFontData::HINTING_NONE; + break; + case 2: + font_hinting = DynamicFontData::HINTING_LIGHT; + break; + default: + font_hinting = DynamicFontData::HINTING_NORMAL; + break; + } String custom_font_path = EditorSettings::get_singleton()->get("interface/editor/main_font"); Ref<DynamicFontData> CustomFont; @@ -125,13 +149,11 @@ void editor_register_fonts(Ref<Theme> p_theme) { /* Custom source code font */ String custom_font_path_source = EditorSettings::get_singleton()->get("interface/editor/code_font"); - bool font_source_antialiased = (bool)EditorSettings::get_singleton()->get("interface/editor/code_font_antialiased"); - DynamicFontData::Hinting font_source_hinting = (DynamicFontData::Hinting)(int)EditorSettings::get_singleton()->get("interface/editor/code_font_hinting"); Ref<DynamicFontData> CustomFontSource; if (custom_font_path_source.length() > 0 && dir->file_exists(custom_font_path_source)) { CustomFontSource.instance(); - CustomFontSource->set_antialiased(font_source_antialiased); - CustomFontSource->set_hinting(font_source_hinting); + CustomFontSource->set_antialiased(font_antialiased); + CustomFontSource->set_hinting(font_hinting); CustomFontSource->set_font_path(custom_font_path_source); } else { EditorSettings::get_singleton()->set_manually("interface/editor/code_font", ""); @@ -201,8 +223,8 @@ void editor_register_fonts(Ref<Theme> p_theme) { Ref<DynamicFontData> dfmono; dfmono.instance(); - dfmono->set_antialiased(font_source_antialiased); - dfmono->set_hinting(font_source_hinting); + dfmono->set_antialiased(font_antialiased); + dfmono->set_hinting(font_hinting); dfmono->set_font_ptr(_font_Hack_Regular, _font_Hack_Regular_size); int default_font_size = int(EDITOR_GET("interface/editor/main_font_size")) * EDSCALE; |