Skip to content

Commit 361ea11

Browse files
committed
Merge pull request #111140 from DeeJayLSP/gdinter
Use Inter as the default editor font, features enabled
2 parents c7b1767 + 6cf4daa commit 361ea11

File tree

11 files changed

+125
-18
lines changed

11 files changed

+125
-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.

doc/classes/EditorSettings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,7 @@
933933
<member name="interface/editor/main_font_custom_opentype_features" type="String" setter="" getter="">
934934
List of custom OpenType features to use, if supported by the currently configured main font. Check what OpenType features are supported by your font first.
935935
The string should follow the OpenType specification, e.g. [code]ss01,tnum,calt=false[/code]. Microsoft's documentation contains a list of [url=https://learn.microsoft.com/en-us/typography/opentype/spec/featurelist]all registered features[/url].
936+
[b]Note:[/b] The default editor main font ([url=https://rsms.me/inter]Inter[/url]) has custom OpenType features in its font file, with [code]ss04[/code] and [code]tnum[/code] enabled and [code]calt[/code] disabled by default. Supported features can be found at its website.
936937
</member>
937938
<member name="interface/editor/main_font_size" type="int" setter="" getter="">
938939
The size of the font in the editor interface.

editor/themes/editor_fonts.cpp

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

157-
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);
158-
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);
157+
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);
158+
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);
159+
160+
Dictionary default_features;
161+
default_features["calt"] = false; // Disable contextual alternates by default.
162+
default_features["ss04"] = true; // Serifed I, tailed l for better distinction.
163+
default_features["tnum"] = true; // Tabular numbers for better alignment.
159164

160165
String noto_cjk_path;
161166
String noto_cjk_bold_path;
@@ -189,8 +194,8 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
189194
default_font->set_fallbacks(fallbacks);
190195
default_font_msdf->set_fallbacks(fallbacks);
191196

192-
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);
193-
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);
197+
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);
198+
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);
194199

195200
TypedArray<Font> fallbacks_bold;
196201
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);
@@ -246,6 +251,7 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
246251
default_fc->set_base_font(custom_font);
247252
} else {
248253
EditorSettings::get_singleton()->set_manually("interface/editor/main_font", "");
254+
default_fc->set_opentype_features(default_features);
249255
default_fc->set_base_font(default_font);
250256
}
251257
default_fc->set_spacing(TextServer::SPACING_TOP, -EDSCALE);
@@ -265,6 +271,7 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
265271
default_fc_msdf->set_base_font(custom_font);
266272
} else {
267273
EditorSettings::get_singleton()->set_manually("interface/editor/main_font", "");
274+
default_fc_msdf->set_opentype_features(default_features);
268275
default_fc_msdf->set_base_font(default_font_msdf);
269276
}
270277
default_fc_msdf->set_spacing(TextServer::SPACING_TOP, -EDSCALE);
@@ -292,6 +299,7 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
292299
}
293300
} else {
294301
EditorSettings::get_singleton()->set_manually("interface/editor/main_font_bold", "");
302+
bold_fc->set_opentype_features(default_features);
295303
bold_fc->set_base_font(default_font_bold);
296304
}
297305
bold_fc->set_spacing(TextServer::SPACING_TOP, -EDSCALE);
@@ -321,6 +329,7 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
321329
}
322330
} else {
323331
EditorSettings::get_singleton()->set_manually("interface/editor/main_font_bold", "");
332+
bold_fc_msdf->set_opentype_features(default_features);
324333
bold_fc_msdf->set_base_font(default_font_bold_msdf);
325334
}
326335
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.

0 commit comments

Comments
 (0)