1
0
mirror of https://github.com/godotengine/godot.git synced 2026-01-06 19:41:11 +00:00

Merge pull request #111773 from DeeJayLSP/main-font-calt-ot-features

Editor: Add OpenType feature settings to Main Font
This commit is contained in:
Thaddeus Crews
2025-10-21 10:26:57 -05:00
3 changed files with 24 additions and 0 deletions

View File

@@ -924,6 +924,10 @@
The font to use for bold text in the editor interface. Must be a resource of a [Font] type such as a [code].ttf[/code] or [code].otf[/code] font file.
[b]Note:[/b] If the provided font is variable, a weight of 700 (bold) will be used.
</member>
<member name="interface/editor/main_font_custom_opentype_features" type="String" setter="" getter="">
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.
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].
</member>
<member name="interface/editor/main_font_size" type="int" setter="" getter="">
The size of the font in the editor interface.
</member>

View File

@@ -488,6 +488,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_RANGE, "interface/editor/main_font_size", 14, "8,48,1")
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_RANGE, "interface/editor/code_font_size", 14, "8,48,1")
_initial_set("interface/editor/main_font_custom_opentype_features", "");
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/code_font_contextual_ligatures", 1, "Enabled,Disable Contextual Alternates (Coding Ligatures),Use Custom OpenType Feature Set")
_initial_set("interface/editor/code_font_custom_opentype_features", "");
_initial_set("interface/editor/code_font_custom_variations", "");

View File

@@ -327,6 +327,25 @@ void editor_register_fonts(const Ref<Theme> &p_theme) {
bold_fc_msdf->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE);
bold_fc_msdf->set_variation_opentype(bold_fc_opentype);
if (!String(EDITOR_GET("interface/editor/main_font_custom_opentype_features")).is_empty()) {
Vector<String> subtag = String(EDITOR_GET("interface/editor/main_font_custom_opentype_features")).split(",");
if (!subtag.is_empty()) {
Dictionary ftrs;
for (int i = 0; i < subtag.size(); i++) {
Vector<String> subtag_a = subtag[i].split("=");
if (subtag_a.size() == 2) {
ftrs[TS->name_to_tag(subtag_a[0])] = subtag_a[1].to_int();
} else if (subtag_a.size() == 1) {
ftrs[TS->name_to_tag(subtag_a[0])] = 1;
}
}
default_fc->set_opentype_features(ftrs);
default_fc_msdf->set_opentype_features(ftrs);
bold_fc->set_opentype_features(ftrs);
bold_fc_msdf->set_opentype_features(ftrs);
}
}
Ref<FontVariation> mono_fc;
mono_fc.instantiate();
if (custom_font_path_source.length() > 0 && dir->file_exists(custom_font_path_source)) {