summaryrefslogtreecommitdiffstats
path: root/editor/editor_fonts.cpp
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2019-08-14 14:51:13 +0200
committerHugo Locurcio <hugo.locurcio@hugo.pro>2019-08-14 15:57:07 +0200
commitc940d29973776919e8fe4aac6ea815145375a1c3 (patch)
tree237de9f74afade5cd53533914b9b1987f1197e8e /editor/editor_fonts.cpp
parent1dae4c9e7f547ce5da12ed0d741feb2b26e306bb (diff)
downloadredot-engine-c940d29973776919e8fe4aac6ea815145375a1c3.tar.gz
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.
Diffstat (limited to 'editor/editor_fonts.cpp')
-rw-r--r--editor/editor_fonts.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index 73438ffc0c..55cae35a4a 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -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;