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.
This commit is contained in:
Hugo Locurcio 2019-08-14 14:51:13 +02:00
parent 1dae4c9e7f
commit c940d29973
No known key found for this signature in database
GPG Key ID: 39E8F8BE30B0A49C
2 changed files with 27 additions and 3 deletions

View File

@ -94,7 +94,31 @@ void editor_register_fonts(Ref<Theme> 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<DynamicFontData> CustomFont;

View File

@ -324,8 +324,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> 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", "");