1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Refactor Font configuration and import UI, and Font resources.

This commit is contained in:
bruvzg
2022-05-09 12:47:10 +03:00
parent cf19484746
commit 344ba0ffaf
113 changed files with 5041 additions and 6485 deletions

View File

@@ -1636,31 +1636,39 @@ void CodeTextEditor::_apply_settings_change() {
_update_text_editor_theme();
font_size = EditorSettings::get_singleton()->get("interface/editor/code_font_size");
int ot_mode = EditorSettings::get_singleton()->get("interface/editor/code_font_contextual_ligatures");
Ref<Font> fb = text_editor->get_theme_font(SNAME("font"));
Ref<FontVariation> fc = fb;
if (fc.is_null()) {
fc.instantiate();
fc->set_base_font(fb);
}
switch (ot_mode) {
case 1: { // Disable ligatures.
text_editor->clear_opentype_features();
text_editor->set_opentype_feature("calt", 0);
fc->set_opentype_features(Dictionary());
} break;
case 2: { // Custom.
text_editor->clear_opentype_features();
Vector<String> subtag = String(EditorSettings::get_singleton()->get("interface/editor/code_font_custom_opentype_features")).split(",");
Dictionary ftrs;
for (int i = 0; i < subtag.size(); i++) {
Vector<String> subtag_a = subtag[i].split("=");
if (subtag_a.size() == 2) {
text_editor->set_opentype_feature(subtag_a[0], subtag_a[1].to_int());
ftrs[TS->name_to_tag(subtag_a[0])] = subtag_a[1].to_int();
} else if (subtag_a.size() == 1) {
text_editor->set_opentype_feature(subtag_a[0], 1);
ftrs[TS->name_to_tag(subtag_a[0])] = 1;
}
}
fc->set_opentype_features(ftrs);
} break;
default: { // Default.
text_editor->clear_opentype_features();
text_editor->set_opentype_feature("calt", 1);
Dictionary ftrs;
ftrs[TS->name_to_tag("calt")] = 1;
fc->set_opentype_features(ftrs);
} break;
}
text_editor->add_theme_font_override("font", fc);
text_editor->set_code_hint_draw_below(EDITOR_GET("text_editor/completion/put_callhint_tooltip_below_current_line"));
@@ -1862,29 +1870,36 @@ CodeTextEditor::CodeTextEditor() {
text_editor->set_v_size_flags(SIZE_EXPAND_FILL);
int ot_mode = EditorSettings::get_singleton()->get("interface/editor/code_font_contextual_ligatures");
Ref<Font> fb = text_editor->get_theme_font(SNAME("font"));
Ref<FontVariation> fc = fb;
if (fc.is_null()) {
fc.instantiate();
fc->set_base_font(fb);
}
switch (ot_mode) {
case 1: { // Disable ligatures.
text_editor->clear_opentype_features();
text_editor->set_opentype_feature("calt", 0);
fc->set_opentype_features(Dictionary());
} break;
case 2: { // Custom.
text_editor->clear_opentype_features();
Vector<String> subtag = String(EditorSettings::get_singleton()->get("interface/editor/code_font_custom_opentype_features")).split(",");
Dictionary ftrs;
for (int i = 0; i < subtag.size(); i++) {
Vector<String> subtag_a = subtag[i].split("=");
if (subtag_a.size() == 2) {
text_editor->set_opentype_feature(subtag_a[0], subtag_a[1].to_int());
ftrs[TS->name_to_tag(subtag_a[0])] = subtag_a[1].to_int();
} else if (subtag_a.size() == 1) {
text_editor->set_opentype_feature(subtag_a[0], 1);
ftrs[TS->name_to_tag(subtag_a[0])] = 1;
}
}
fc->set_opentype_features(ftrs);
} break;
default: { // Default.
text_editor->clear_opentype_features();
text_editor->set_opentype_feature("calt", 1);
Dictionary ftrs;
ftrs[TS->name_to_tag("calt")] = 1;
fc->set_opentype_features(ftrs);
} break;
}
text_editor->add_theme_font_override("font", fc);
text_editor->set_draw_line_numbers(true);
text_editor->set_highlight_matching_braces_enabled(true);