From c940d29973776919e8fe4aac6ea815145375a1c3 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 14 Aug 2019 14:51:13 +0200 Subject: [PATCH] Add an "Auto" editor font hinting setting to match OS font rendering The "Auto" setting picks the font hinting setting that best matches the operating system's font rendering settings. This font hinting setting is now the default. --- editor/editor_fonts.cpp | 26 +++++++++++++++++++++++++- editor/editor_settings.cpp | 4 ++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 73438ffc0cb..55cae35a4a9 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -94,7 +94,31 @@ void editor_register_fonts(Ref p_theme) { /* Custom font */ bool font_antialiased = (bool)EditorSettings::get_singleton()->get("interface/editor/font_antialiased"); - DynamicFontData::Hinting font_hinting = (DynamicFontData::Hinting)(int)EditorSettings::get_singleton()->get("interface/editor/font_hinting"); + 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 CustomFont; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index e3f2a888d64..2d2e53370d1 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -324,8 +324,8 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { _initial_set("interface/editor/code_font_size", 14); hints["interface/editor/code_font_size"] = PropertyInfo(Variant::INT, "interface/editor/code_font_size", PROPERTY_HINT_RANGE, "8,48,1", PROPERTY_USAGE_DEFAULT); _initial_set("interface/editor/font_antialiased", true); - _initial_set("interface/editor/font_hinting", 2); - hints["interface/editor/font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT); + _initial_set("interface/editor/font_hinting", 0); + hints["interface/editor/font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/font_hinting", PROPERTY_HINT_ENUM, "Auto,None,Light,Normal", PROPERTY_USAGE_DEFAULT); _initial_set("interface/editor/main_font", ""); hints["interface/editor/main_font"] = PropertyInfo(Variant::STRING, "interface/editor/main_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT); _initial_set("interface/editor/main_font_bold", "");