-
Notifications
You must be signed in to change notification settings - Fork 5
/
patch_editor_fonts_3_3_x.diff
323 lines (298 loc) · 14 KB
/
patch_editor_fonts_3_3_x.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
diff --git a/editor/SCsub b/editor/SCsub
index 67787ca49d..b679c7f9b1 100644
--- a/editor/SCsub
+++ b/editor/SCsub
@@ -78,6 +78,9 @@ if env["tools"]:
env.Depends("#editor/builtin_fonts.gen.h", flist)
env.CommandNoCache("#editor/builtin_fonts.gen.h", flist, run_in_subprocess(editor_builders.make_fonts_header))
+ env.Append(CXXFLAGS=["-DGODOT_MODULE"])
+ env.Append(CPPPATH=["#modules/godot_tl/src/resources", "#modules/godot_tl/src", "#modules/godot_tl/subprojects/graphite2/include", "#modules/godot_tl/subprojects/harfbuzz/src", "#modules/godot_tl/subprojects/icu4c/source/common"])
+
env.add_source_files(env.editor_sources, "*.cpp")
SConscript("collada/SCsub")
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index 39a825ea73..65470aed09 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -35,69 +35,31 @@
#include "editor_scale.h"
#include "editor_settings.h"
#include "scene/resources/default_theme/default_theme.h"
-#include "scene/resources/dynamic_font.h"
-
-#define MAKE_FALLBACKS(m_name) \
- m_name->add_fallback(FontArabic); \
- m_name->add_fallback(FontHebrew); \
- m_name->add_fallback(FontThai); \
- m_name->add_fallback(FontHindi); \
- m_name->add_fallback(FontJapanese); \
- m_name->add_fallback(FontFallback);
-
-// Enable filtering and mipmaps on the editor fonts to improve text appearance
-// in editors that are zoomed in/out without having dedicated fonts to generate.
-// This is the case in GraphEdit-based editors such as the visual script and
-// visual shader editors.
-
-// the custom spacings might only work with Noto Sans
+#include "scene/resources/theme.h"
+#include "modules/godot_tl/src/resources/tl_font_family.hpp"
+#include "modules/godot_tl/src/resources/tl_dynamic_font.hpp"
+#include "modules/godot_tl/src/resources/tl_gd_font_wrapper.hpp"
+
#define MAKE_DEFAULT_FONT(m_name, m_size) \
- Ref<DynamicFont> m_name; \
+ Ref<TLGDFontWrapper> m_name; \
m_name.instance(); \
- m_name->set_size(m_size); \
- m_name->set_use_filter(true); \
- m_name->set_use_mipmaps(true); \
- if (CustomFont.is_valid()) { \
- m_name->set_font_data(CustomFont); \
- m_name->add_fallback(DefaultFont); \
- } else { \
- m_name->set_font_data(DefaultFont); \
- } \
- m_name->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); \
- m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \
- MAKE_FALLBACKS(m_name);
+ m_name->set_base_font(dff); \
+ m_name->set_base_font_style("Default"); \
+ m_name->set_base_font_size(m_size);
#define MAKE_BOLD_FONT(m_name, m_size) \
- Ref<DynamicFont> m_name; \
+ Ref<TLGDFontWrapper> m_name; \
m_name.instance(); \
- m_name->set_size(m_size); \
- m_name->set_use_filter(true); \
- m_name->set_use_mipmaps(true); \
- if (CustomFontBold.is_valid()) { \
- m_name->set_font_data(CustomFontBold); \
- m_name->add_fallback(DefaultFontBold); \
- } else { \
- m_name->set_font_data(DefaultFontBold); \
- } \
- m_name->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); \
- m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \
- MAKE_FALLBACKS(m_name);
+ m_name->set_base_font(dff); \
+ m_name->set_base_font_style("Bold"); \
+ m_name->set_base_font_size(m_size);
#define MAKE_SOURCE_FONT(m_name, m_size) \
- Ref<DynamicFont> m_name; \
+ Ref<TLGDFontWrapper> m_name; \
m_name.instance(); \
- m_name->set_size(m_size); \
- m_name->set_use_filter(true); \
- m_name->set_use_mipmaps(true); \
- if (CustomFontSource.is_valid()) { \
- m_name->set_font_data(CustomFontSource); \
- m_name->add_fallback(dfmono); \
- } else { \
- m_name->set_font_data(dfmono); \
- } \
- m_name->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); \
- m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \
- MAKE_FALLBACKS(m_name);
+ m_name->set_base_font(dff); \
+ m_name->set_base_font_style("Bold"); \
+ m_name->set_base_font_size(m_size);
void editor_register_fonts(Ref<Theme> p_theme) {
DirAccess *dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
@@ -107,7 +69,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
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;
+ DynamicFaceHinting font_hinting;
switch (font_hinting_setting) {
case 0:
// The "Auto" setting uses the setting that best matches the OS' font rendering:
@@ -115,27 +77,26 @@ void editor_register_fonts(Ref<Theme> p_theme) {
// - 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;
+ font_hinting = DF_HINTING_NONE;
#else
- font_hinting = DynamicFontData::HINTING_LIGHT;
+ font_hinting = DF_HINTING_LIGHT;
#endif
break;
case 1:
- font_hinting = DynamicFontData::HINTING_NONE;
+ font_hinting = DF_HINTING_NONE;
break;
case 2:
- font_hinting = DynamicFontData::HINTING_LIGHT;
+ font_hinting = DF_HINTING_LIGHT;
break;
default:
- font_hinting = DynamicFontData::HINTING_NORMAL;
+ font_hinting = DF_HINTING_NORMAL;
break;
}
String custom_font_path = EditorSettings::get_singleton()->get("interface/editor/main_font");
- Ref<DynamicFontData> CustomFont;
+ Ref<TLDynamicFontFace> CustomFont;
if (custom_font_path.length() > 0 && dir->file_exists(custom_font_path)) {
CustomFont.instance();
- CustomFont->set_antialiased(font_antialiased);
CustomFont->set_hinting(font_hinting);
CustomFont->set_font_path(custom_font_path);
CustomFont->set_force_autohinter(true); //just looks better..i think?
@@ -146,10 +107,9 @@ void editor_register_fonts(Ref<Theme> p_theme) {
/* Custom Bold font */
String custom_font_path_bold = EditorSettings::get_singleton()->get("interface/editor/main_font_bold");
- Ref<DynamicFontData> CustomFontBold;
+ Ref<TLDynamicFontFace> CustomFontBold;
if (custom_font_path_bold.length() > 0 && dir->file_exists(custom_font_path_bold)) {
CustomFontBold.instance();
- CustomFontBold->set_antialiased(font_antialiased);
CustomFontBold->set_hinting(font_hinting);
CustomFontBold->set_font_path(custom_font_path_bold);
CustomFontBold->set_force_autohinter(true); //just looks better..i think?
@@ -160,10 +120,9 @@ 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");
- Ref<DynamicFontData> CustomFontSource;
+ Ref<TLDynamicFontFace> CustomFontSource;
if (custom_font_path_source.length() > 0 && dir->file_exists(custom_font_path_source)) {
CustomFontSource.instance();
- CustomFontSource->set_antialiased(font_antialiased);
CustomFontSource->set_hinting(font_hinting);
CustomFontSource->set_font_path(custom_font_path_source);
} else {
@@ -174,72 +133,104 @@ void editor_register_fonts(Ref<Theme> p_theme) {
/* Droid Sans */
- Ref<DynamicFontData> DefaultFont;
+ Ref<TLDynamicFontFace> DefaultFont;
DefaultFont.instance();
- DefaultFont->set_antialiased(font_antialiased);
DefaultFont->set_hinting(font_hinting);
DefaultFont->set_font_ptr(_font_NotoSansUI_Regular, _font_NotoSansUI_Regular_size);
DefaultFont->set_force_autohinter(true); //just looks better..i think?
- Ref<DynamicFontData> DefaultFontBold;
+ Ref<TLDynamicFontFace> DefaultFontBold;
DefaultFontBold.instance();
- DefaultFontBold->set_antialiased(font_antialiased);
DefaultFontBold->set_hinting(font_hinting);
DefaultFontBold->set_font_ptr(_font_NotoSansUI_Bold, _font_NotoSansUI_Bold_size);
DefaultFontBold->set_force_autohinter(true); // just looks better..i think?
- Ref<DynamicFontData> FontFallback;
+ Ref<TLDynamicFontFace> FontFallback;
FontFallback.instance();
- FontFallback->set_antialiased(font_antialiased);
FontFallback->set_hinting(font_hinting);
FontFallback->set_font_ptr(_font_DroidSansFallback, _font_DroidSansFallback_size);
FontFallback->set_force_autohinter(true); //just looks better..i think?
- Ref<DynamicFontData> FontJapanese;
+ Ref<TLDynamicFontFace> FontJapanese;
FontJapanese.instance();
- FontJapanese->set_antialiased(font_antialiased);
FontJapanese->set_hinting(font_hinting);
FontJapanese->set_font_ptr(_font_DroidSansJapanese, _font_DroidSansJapanese_size);
FontJapanese->set_force_autohinter(true); //just looks better..i think?
- Ref<DynamicFontData> FontArabic;
+ Ref<TLDynamicFontFace> FontArabic;
FontArabic.instance();
- FontArabic->set_antialiased(font_antialiased);
FontArabic->set_hinting(font_hinting);
FontArabic->set_font_ptr(_font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size);
FontArabic->set_force_autohinter(true); //just looks better..i think?
- Ref<DynamicFontData> FontHebrew;
+ Ref<TLDynamicFontFace> FontHebrew;
FontHebrew.instance();
- FontHebrew->set_antialiased(font_antialiased);
FontHebrew->set_hinting(font_hinting);
FontHebrew->set_font_ptr(_font_NotoSansHebrew_Regular, _font_NotoSansHebrew_Regular_size);
FontHebrew->set_force_autohinter(true); //just looks better..i think?
- Ref<DynamicFontData> FontThai;
+ Ref<TLDynamicFontFace> FontThai;
FontThai.instance();
- FontThai->set_antialiased(font_antialiased);
FontThai->set_hinting(font_hinting);
FontThai->set_font_ptr(_font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size);
FontThai->set_force_autohinter(true); //just looks better..i think?
- Ref<DynamicFontData> FontHindi;
+ Ref<TLDynamicFontFace> FontHindi;
FontHindi.instance();
- FontHindi->set_antialiased(font_antialiased);
FontHindi->set_hinting(font_hinting);
FontHindi->set_font_ptr(_font_NotoSansDevanagariUI_Regular, _font_NotoSansDevanagariUI_Regular_size);
FontHindi->set_force_autohinter(true); //just looks better..i think?
/* Hack */
- Ref<DynamicFontData> dfmono;
+ Ref<TLDynamicFontFace> dfmono;
dfmono.instance();
- 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;
+ Ref<TLFontFamily> dff;
+ dff.instance();
+ dff->add_style("Default");
+ dff->add_style("Bold");
+ dff->add_style("Source");
+ if (CustomFont.is_valid()) {
+ dff->add_face("Default", CustomFont);
+ }
+ dff->add_face("Default", DefaultFont);
+ dff->add_face("Default", FontArabic);
+ dff->add_face("Default", FontHebrew);
+ dff->add_face("Default", FontThai);
+ dff->add_face("Default", FontHindi);
+ dff->add_face("Default", FontJapanese);
+ dff->add_face("Default", FontFallback);
+
+ if (CustomFontBold.is_valid()) {
+ dff->add_face("Bold", CustomFontBold);
+ }
+ dff->add_face("Bold", DefaultFontBold);
+ dff->add_face("Bold", DefaultFont);
+ dff->add_face("Bold", FontArabic);
+ dff->add_face("Bold", FontHebrew);
+ dff->add_face("Bold", FontThai);
+ dff->add_face("Bold", FontHindi);
+ dff->add_face("Bold", FontJapanese);
+ dff->add_face("Bold", FontFallback);
+
+ if (CustomFontSource.is_valid()) {
+ dff->add_face("Source", CustomFontSource);
+ }
+ dff->add_face("Source", dfmono);
+ dff->add_face("Source", DefaultFontBold);
+ dff->add_face("Source", DefaultFont);
+ dff->add_face("Source", FontArabic);
+ dff->add_face("Source", FontHebrew);
+ dff->add_face("Source", FontThai);
+ dff->add_face("Source", FontHindi);
+ dff->add_face("Source", FontJapanese);
+ dff->add_face("Source", FontFallback);
+
// Default font
MAKE_DEFAULT_FONT(df, default_font_size);
p_theme->set_default_theme_font(df);
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 6fed5737de..4e90fc27ca 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -264,7 +264,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
// Some locales are not properly supported currently in Godot due to lack of font shaping
// (e.g. Arabic or Hindi), so even though we have work in progress translations for them,
// we skip them as they don't render properly. (GH-28577)
- const Vector<String> locales_to_skip = String("ar,bn,fa,he,hi,ml,si,ta,te,ur").split(",");
+ //const Vector<String> locales_to_skip = String("ar,bn,fa,he,hi,ml,si,ta,te,ur").split(",");
String best;
@@ -276,10 +276,10 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
// Skip locales which we can't render properly (see above comment).
// Test against language code without regional variants (e.g. ur_PK).
String lang_code = locale.get_slice("_", 0);
- if (locales_to_skip.find(lang_code) != -1) {
- etl++;
- continue;
- }
+ //if (locales_to_skip.find(lang_code) != -1) {
+ // etl++;
+ // continue;
+ //}
lang_hint += ",";
lang_hint += locale;