Skip to content

Commit 245ee98

Browse files
committed
Replace default editor font with Inter, disambiguation enabled
1 parent 4a1c1c4 commit 245ee98

File tree

10 files changed

+122
-18
lines changed

10 files changed

+122
-18
lines changed

COPYRIGHT.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ Comment: DroidSans font
273273
Copyright: 2008, The Android Open Source Project
274274
License: Apache-2.0
275275

276+
Files: thirdparty/fonts/Inter*.woff2
277+
Comment: Inter font
278+
Copyright: 2016, The Inter Project Authors
279+
License: OFL-1.1
280+
276281
Files: thirdparty/fonts/JetBrainsMono_Regular.woff2
277282
Comment: JetBrains Mono font
278283
Copyright: 2020, JetBrains s.r.o.

editor/themes/editor_fonts.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,11 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
153153
const int default_font_size = int(EDITOR_GET("interface/editor/main_font_size")) * EDSCALE;
154154
const float embolden_strength = 0.6;
155155

156-
Ref<Font> default_font = load_internal_font(_font_NotoSans_Regular, _font_NotoSans_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, font_disable_embedded_bitmaps, false);
157-
Ref<Font> default_font_msdf = load_internal_font(_font_NotoSans_Regular, _font_NotoSans_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, font_disable_embedded_bitmaps, font_allow_msdf);
156+
Dictionary default_font_disambiguation;
157+
default_font_disambiguation["ss02"] = true; // Make "I" and "l" more distinguishable, and slash zero.
158+
159+
Ref<Font> default_font = load_internal_font(_font_Inter_Regular, _font_Inter_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, font_disable_embedded_bitmaps, false);
160+
Ref<Font> default_font_msdf = load_internal_font(_font_Inter_Regular, _font_Inter_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, font_disable_embedded_bitmaps, font_allow_msdf);
158161

159162
String noto_cjk_path;
160163
String noto_cjk_bold_path;
@@ -188,8 +191,8 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
188191
default_font->set_fallbacks(fallbacks);
189192
default_font_msdf->set_fallbacks(fallbacks);
190193

191-
Ref<FontFile> default_font_bold = load_internal_font(_font_NotoSans_Bold, _font_NotoSans_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, font_disable_embedded_bitmaps, false);
192-
Ref<FontFile> default_font_bold_msdf = load_internal_font(_font_NotoSans_Bold, _font_NotoSans_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, font_disable_embedded_bitmaps, font_allow_msdf);
194+
Ref<FontFile> default_font_bold = load_internal_font(_font_Inter_Bold, _font_Inter_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, font_disable_embedded_bitmaps, false);
195+
Ref<FontFile> default_font_bold_msdf = load_internal_font(_font_Inter_Bold, _font_Inter_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, font_disable_embedded_bitmaps, font_allow_msdf);
193196

194197
TypedArray<Font> fallbacks_bold;
195198
Ref<FontFile> arabic_font_bold = load_internal_font(_font_Vazirmatn_Bold, _font_Vazirmatn_Bold_size, font_hinting, font_antialiasing, true, font_subpixel_positioning, font_disable_embedded_bitmaps, false, &fallbacks_bold);
@@ -245,6 +248,7 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
245248
default_fc->set_base_font(custom_font);
246249
} else {
247250
EditorSettings::get_singleton()->set_manually("interface/editor/main_font", "");
251+
default_fc->set_opentype_features(default_font_disambiguation);
248252
default_fc->set_base_font(default_font);
249253
}
250254
default_fc->set_spacing(TextServer::SPACING_TOP, -EDSCALE);
@@ -264,6 +268,7 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
264268
default_fc_msdf->set_base_font(custom_font);
265269
} else {
266270
EditorSettings::get_singleton()->set_manually("interface/editor/main_font", "");
271+
default_fc_msdf->set_opentype_features(default_font_disambiguation);
267272
default_fc_msdf->set_base_font(default_font_msdf);
268273
}
269274
default_fc_msdf->set_spacing(TextServer::SPACING_TOP, -EDSCALE);
@@ -289,6 +294,7 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
289294
bold_fc->set_variation_embolden(embolden_strength);
290295
} else {
291296
EditorSettings::get_singleton()->set_manually("interface/editor/main_font_bold", "");
297+
bold_fc->set_opentype_features(default_font_disambiguation);
292298
bold_fc->set_base_font(default_font_bold);
293299
}
294300
bold_fc->set_spacing(TextServer::SPACING_TOP, -EDSCALE);
@@ -316,6 +322,7 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
316322
bold_fc_msdf->set_variation_embolden(embolden_strength);
317323
} else {
318324
EditorSettings::get_singleton()->set_manually("interface/editor/main_font_bold", "");
325+
bold_fc_msdf->set_opentype_features(default_font_disambiguation);
319326
bold_fc_msdf->set_base_font(default_font_bold_msdf);
320327
}
321328
bold_fc_msdf->set_spacing(TextServer::SPACING_TOP, -EDSCALE);

tests/scene/test_fontfile.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ TEST_CASE("[FontFile] Create font file and check data") {
101101
ERR_PRINT_ON
102102

103103
// Load a valid file.
104-
CHECK(font_file->load_dynamic_font("thirdparty/fonts/NotoSans_Regular.woff2") == OK);
104+
CHECK(font_file->load_dynamic_font("thirdparty/fonts/Inter_Regular.woff2") == OK);
105105

106106
// Check fontfile data.
107107
CHECK_MESSAGE(font_file->get_data().is_empty() == false, "Fontfile should have been loaded.");
108-
CHECK_MESSAGE(font_file->get_font_name() == "Noto Sans", "Loaded correct font name.");
108+
CHECK_MESSAGE(font_file->get_font_name() == "Inter", "Loaded correct font name.");
109109
CHECK_MESSAGE(font_file->get_font_style_name() == "Regular", "Loaded correct font style.");
110-
CHECK_MESSAGE(font_file->get_data().size() == 148480llu, "Whole fontfile was loaded.");
110+
CHECK_MESSAGE(font_file->get_data().size() == 111268llu, "Whole fontfile was loaded.");
111111

112112
// Valid glyphs.
113113
CHECK_MESSAGE(font_file->get_glyph_index(2, 'a', 0) != 0, "Glyph index for 'a' is valid.");

tests/servers/test_text_server.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ TEST_SUITE("[TextServer]") {
5050
}
5151

5252
RID font = ts->create_font();
53-
ts->font_set_data_ptr(font, _font_NotoSans_Regular, _font_NotoSans_Regular_size);
53+
ts->font_set_data_ptr(font, _font_Inter_Regular, _font_Inter_Regular_size);
5454
CHECK_FALSE_MESSAGE(font == RID(), "Loading font failed.");
5555
ts->free_rid(font);
5656
}
@@ -66,7 +66,7 @@ TEST_SUITE("[TextServer]") {
6666
}
6767

6868
RID font1 = ts->create_font();
69-
ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size);
69+
ts->font_set_data_ptr(font1, _font_Inter_Regular, _font_Inter_Regular_size);
7070
ts->font_set_allow_system_fallback(font1, false);
7171
RID font2 = ts->create_font();
7272
ts->font_set_data_ptr(font2, _font_NotoSansThai_Regular, _font_NotoSansThai_Regular_size);
@@ -118,7 +118,7 @@ TEST_SUITE("[TextServer]") {
118118
}
119119

120120
RID font1 = ts->create_font();
121-
ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size);
121+
ts->font_set_data_ptr(font1, _font_Inter_Regular, _font_Inter_Regular_size);
122122
RID font2 = ts->create_font();
123123
ts->font_set_data_ptr(font2, _font_Vazirmatn_Regular, _font_Vazirmatn_Regular_size);
124124

@@ -167,7 +167,7 @@ TEST_SUITE("[TextServer]") {
167167
}
168168

169169
RID font1 = ts->create_font();
170-
ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size);
170+
ts->font_set_data_ptr(font1, _font_Inter_Regular, _font_Inter_Regular_size);
171171
ts->font_set_allow_system_fallback(font1, false);
172172
RID font2 = ts->create_font();
173173
ts->font_set_data_ptr(font2, _font_NotoSansThai_Regular, _font_NotoSansThai_Regular_size);
@@ -565,7 +565,7 @@ TEST_SUITE("[TextServer]") {
565565
// 5^ 10^
566566

567567
RID font1 = ts->create_font();
568-
ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size);
568+
ts->font_set_data_ptr(font1, _font_Inter_Regular, _font_Inter_Regular_size);
569569
RID font2 = ts->create_font();
570570
ts->font_set_data_ptr(font2, _font_NotoSansThai_Regular, _font_NotoSansThai_Regular_size);
571571

@@ -620,7 +620,7 @@ TEST_SUITE("[TextServer]") {
620620
}
621621

622622
RID font1 = ts->create_font();
623-
ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size);
623+
ts->font_set_data_ptr(font1, _font_Inter_Regular, _font_Inter_Regular_size);
624624
RID font2 = ts->create_font();
625625
ts->font_set_data_ptr(font2, _font_Vazirmatn_Regular, _font_Vazirmatn_Regular_size);
626626

@@ -931,7 +931,7 @@ TEST_SUITE("[TextServer]") {
931931
}
932932

933933
RID font1 = ts->create_font();
934-
ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size);
934+
ts->font_set_data_ptr(font1, _font_Inter_Regular, _font_Inter_Regular_size);
935935

936936
Array font = { font1 };
937937
RID ctx = ts->create_shaped_text();

thirdparty/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,14 @@ Patches:
274274
* Upstream: https://android.googlesource.com/platform/frameworks/base/+/master/data/fonts/
275275
* Version: ? (pre-2014 commit when DroidSansJapanese.ttf was obsoleted)
276276
* License: Apache 2.0
277+
- `Inter*.woff2`:
278+
* Upstream: https://github.com/rsms/inter
279+
* Version: v4.1 (e3a3d4c57d5ecc01453a575621882a384c1995a3, 2024)
280+
* License: OFL-1.1
277281
- `JetBrainsMono_Regular.woff2`:
278282
* Upstream: https://github.com/JetBrains/JetBrainsMono
279283
* Version: 2.304 (cd5227bd1f61dff3bbd6c814ceaf7ffd95e947d9, 2023)
280284
* License: OFL-1.1
281-
- `NotoSans*.woff2`:
282-
* Upstream: https://github.com/notofonts/latin-greek-cyrillic
283-
* Version: 2.012 (9ea0c8d37bff0c0067b03777f40aa04f2bf78f99, 2023)
284-
* License: OFL-1.1
285285
- `NotoSansBengali*.woff2`:
286286
* Upstream: https://github.com/notofonts/bengali
287287
* Version: 2.003 (020a5701f6fc6a363d5eccbae45e37714c0ad686, 2022)

thirdparty/fonts/Inter_Bold.woff2

112 KB
Binary file not shown.
109 KB
Binary file not shown.

thirdparty/fonts/LICENSE.Inter.txt

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
2+
3+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
4+
This license is copied below, and is also available with a FAQ at:
5+
http://scripts.sil.org/OFL
6+
7+
-----------------------------------------------------------
8+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
9+
-----------------------------------------------------------
10+
11+
PREAMBLE
12+
The goals of the Open Font License (OFL) are to stimulate worldwide
13+
development of collaborative font projects, to support the font creation
14+
efforts of academic and linguistic communities, and to provide a free and
15+
open framework in which fonts may be shared and improved in partnership
16+
with others.
17+
18+
The OFL allows the licensed fonts to be used, studied, modified and
19+
redistributed freely as long as they are not sold by themselves. The
20+
fonts, including any derivative works, can be bundled, embedded,
21+
redistributed and/or sold with any software provided that any reserved
22+
names are not used by derivative works. The fonts and derivatives,
23+
however, cannot be released under any other type of license. The
24+
requirement for fonts to remain under this license does not apply
25+
to any document created using the fonts or their derivatives.
26+
27+
DEFINITIONS
28+
"Font Software" refers to the set of files released by the Copyright
29+
Holder(s) under this license and clearly marked as such. This may
30+
include source files, build scripts and documentation.
31+
32+
"Reserved Font Name" refers to any names specified as such after the
33+
copyright statement(s).
34+
35+
"Original Version" refers to the collection of Font Software components as
36+
distributed by the Copyright Holder(s).
37+
38+
"Modified Version" refers to any derivative made by adding to, deleting,
39+
or substituting -- in part or in whole -- any of the components of the
40+
Original Version, by changing formats or by porting the Font Software to a
41+
new environment.
42+
43+
"Author" refers to any designer, engineer, programmer, technical
44+
writer or other person who contributed to the Font Software.
45+
46+
PERMISSION AND CONDITIONS
47+
Permission is hereby granted, free of charge, to any person obtaining
48+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
49+
redistribute, and sell modified and unmodified copies of the Font
50+
Software, subject to the following conditions:
51+
52+
1) Neither the Font Software nor any of its individual components,
53+
in Original or Modified Versions, may be sold by itself.
54+
55+
2) Original or Modified Versions of the Font Software may be bundled,
56+
redistributed and/or sold with any software, provided that each copy
57+
contains the above copyright notice and this license. These can be
58+
included either as stand-alone text files, human-readable headers or
59+
in the appropriate machine-readable metadata fields within text or
60+
binary files as long as those fields can be easily viewed by the user.
61+
62+
3) No Modified Version of the Font Software may use the Reserved Font
63+
Name(s) unless explicit written permission is granted by the corresponding
64+
Copyright Holder. This restriction only applies to the primary font name as
65+
presented to the users.
66+
67+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
68+
Software shall not be used to promote, endorse or advertise any
69+
Modified Version, except to acknowledge the contribution(s) of the
70+
Copyright Holder(s) and the Author(s) or with their explicit written
71+
permission.
72+
73+
5) The Font Software, modified or unmodified, in part or in whole,
74+
must be distributed entirely under this license, and must not be
75+
distributed under any other license. The requirement for fonts to
76+
remain under this license does not apply to any document created
77+
using the Font Software.
78+
79+
TERMINATION
80+
This license becomes null and void if any of the above conditions are
81+
not met.
82+
83+
DISCLAIMER
84+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
85+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
86+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
87+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
88+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
89+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
90+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
91+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
92+
OTHER DEALINGS IN THE FONT SOFTWARE.
-143 KB
Binary file not shown.
-145 KB
Binary file not shown.

0 commit comments

Comments
 (0)