diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/code_editor.cpp | 108 | ||||
-rw-r--r-- | editor/editor_fonts.cpp | 61 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.cpp | 9 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.h | 2 | ||||
-rw-r--r-- | editor/import/scene_import_settings.cpp | 12 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 2 |
6 files changed, 106 insertions, 88 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 73059464be..a1979c7619 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1638,37 +1638,34 @@ void CodeTextEditor::_apply_settings_change() { 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. - fc->set_opentype_features(Dictionary()); - } break; - case 2: { // Custom. - 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) { - 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; + Ref<FontVariation> fc = text_editor->get_theme_font(SNAME("font")); + if (fc.is_valid()) { + switch (ot_mode) { + case 1: { // Disable ligatures. + Dictionary ftrs; + ftrs[TS->name_to_tag("calt")] = 0; + fc->set_opentype_features(ftrs); + } break; + case 2: { // Custom. + 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) { + 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; + } } - } - fc->set_opentype_features(ftrs); - } break; - default: { // Default. - Dictionary ftrs; - ftrs[TS->name_to_tag("calt")] = 1; - fc->set_opentype_features(ftrs); - } break; + fc->set_opentype_features(ftrs); + } break; + default: { // Default. + 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")); @@ -1870,34 +1867,33 @@ 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. - fc->set_opentype_features(Dictionary()); - } break; - case 2: { // Custom. - 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) { - 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; + Ref<FontVariation> fc = text_editor->get_theme_font(SNAME("font")); + if (fc.is_valid()) { + switch (ot_mode) { + case 1: { // Disable ligatures. + Dictionary ftrs; + ftrs[TS->name_to_tag("calt")] = 0; + fc->set_opentype_features(ftrs); + } break; + case 2: { // Custom. + 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) { + 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; + } } - } - fc->set_opentype_features(ftrs); - } break; - default: { // Default. - Dictionary ftrs; - ftrs[TS->name_to_tag("calt")] = 1; - fc->set_opentype_features(ftrs); - } break; + fc->set_opentype_features(ftrs); + } break; + default: { // Default. + Dictionary ftrs; + ftrs[TS->name_to_tag("calt")] = 1; + fc->set_opentype_features(ftrs); + } break; + } } text_editor->add_theme_font_override("font", fc); diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 8deee57dc9..d58dc98f07 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -164,11 +164,6 @@ void editor_register_fonts(Ref<Theme> p_theme) { default_font_bold_msdf->set_fallbacks(fallbacks_bold); Ref<FontFile> default_font_mono = load_internal_font(_font_JetBrainsMono_Regular, _font_JetBrainsMono_Regular_size, font_hinting, font_antialiased, true, font_subpixel_positioning); - { - Dictionary opentype_features_mono; - opentype_features_mono["calt"] = 0; - default_font_mono->set_opentype_feature_overrides(opentype_features_mono); // Disable contextual alternates (coding ligatures). - } default_font_mono->set_fallbacks(fallbacks); // Init base font configs and load custom fonts. @@ -276,23 +271,45 @@ void editor_register_fonts(Ref<Theme> p_theme) { EditorSettings::get_singleton()->set_manually("interface/editor/code_font", ""); mono_fc->set_base_font(default_font_mono); } + mono_fc->set_spacing(TextServer::SPACING_TOP, -EDSCALE); + mono_fc->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE); - String code_font_custom_variations = EditorSettings::get_singleton()->get("interface/editor/code_font_custom_variations"); - Dictionary variations_mono; - if (!code_font_custom_variations.is_empty()) { - Vector<String> variation_tags = code_font_custom_variations.split(","); - for (int i = 0; i < variation_tags.size(); i++) { - Vector<String> subtag_a = variation_tags[i].split("="); - if (subtag_a.size() == 2) { - variations_mono[TS->name_to_tag(subtag_a[0])] = subtag_a[1].to_float(); - } else if (subtag_a.size() == 1) { - variations_mono[TS->name_to_tag(subtag_a[0])] = 1; + Ref<FontVariation> mono_other_fc = mono_fc->duplicate(); + + // Enable contextual alternates (coding ligatures) and custom features for the source editor font. + int ot_mode = EditorSettings::get_singleton()->get("interface/editor/code_font_contextual_ligatures"); + switch (ot_mode) { + case 1: { // Disable ligatures. + Dictionary ftrs; + ftrs[TS->name_to_tag("calt")] = 0; + mono_fc->set_opentype_features(ftrs); + } break; + case 2: { // Custom. + 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) { + 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; + } } - } - mono_fc->set_variation_opentype(variations_mono); + mono_fc->set_opentype_features(ftrs); + } break; + default: { // Default. + Dictionary ftrs; + ftrs[TS->name_to_tag("calt")] = 1; + mono_fc->set_opentype_features(ftrs); + } break; + } + + { + // Disable contextual alternates (coding ligatures). + Dictionary ftrs; + ftrs[TS->name_to_tag("calt")] = 0; + mono_other_fc->set_opentype_features(ftrs); } - mono_fc->set_spacing(TextServer::SPACING_TOP, -EDSCALE); - mono_fc->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE); Ref<FontVariation> italic_fc = default_fc->duplicate(); italic_fc->set_variation_transform(Transform2D(1.0, 0.2, 0.0, 1.0, 0.0, 0.0)); @@ -359,11 +376,11 @@ void editor_register_fonts(Ref<Theme> p_theme) { p_theme->set_font("source", "EditorFonts", mono_fc); p_theme->set_font_size("expression_size", "EditorFonts", (int(EDITOR_GET("interface/editor/code_font_size")) - 1) * EDSCALE); - p_theme->set_font("expression", "EditorFonts", mono_fc); + p_theme->set_font("expression", "EditorFonts", mono_other_fc); p_theme->set_font_size("output_source_size", "EditorFonts", int(EDITOR_GET("run/output/font_size")) * EDSCALE); - p_theme->set_font("output_source", "EditorFonts", mono_fc); + p_theme->set_font("output_source", "EditorFonts", mono_other_fc); p_theme->set_font_size("status_source_size", "EditorFonts", default_font_size); - p_theme->set_font("status_source", "EditorFonts", mono_fc); + p_theme->set_font("status_source", "EditorFonts", mono_other_fc); } diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index a5920ef98d..860269bfcb 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -1972,7 +1972,7 @@ void ResourceImporterScene::_optimize_track_usage(AnimationPlayer *p_player, Ani } } -Node *ResourceImporterScene::pre_import(const String &p_source_file) { +Node *ResourceImporterScene::pre_import(const String &p_source_file, const HashMap<StringName, Variant> &p_options) { Ref<EditorSceneFormatImporter> importer; String ext = p_source_file.get_extension().to_lower(); @@ -1997,8 +1997,13 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file) { ERR_FAIL_COND_V(!importer.is_valid(), nullptr); + int bake_fps = 30; + if (p_options.has(SNAME("animation/fps"))) { + bake_fps = p_options[SNAME("animation/fps")]; + } + Error err = OK; - Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, HashMap<StringName, Variant>(), 15, nullptr, &err); + Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, p_options, bake_fps, nullptr, &err); if (!scene || err != OK) { return nullptr; } diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index c143e86bd4..b77c1dccb4 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -281,7 +281,7 @@ public: void _optimize_animations(AnimationPlayer *anim, float p_max_lin_error, float p_max_ang_error, float p_max_angle); void _compress_animations(AnimationPlayer *anim, int p_page_size_kb); - Node *pre_import(const String &p_source_file); + Node *pre_import(const String &p_source_file, const HashMap<StringName, Variant> &p_options); virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; virtual bool has_advanced_options() const override; diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index 8ae05f046e..b682407307 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -542,12 +542,6 @@ void SceneImportSettings::open_settings(const String &p_path, bool p_for_animati scene_import_settings_data->settings = nullptr; scene_import_settings_data->path = p_path; - scene = ResourceImporterScene::get_scene_singleton()->pre_import(p_path); // Use the scene singleton here because we want to see the full thing. - if (scene == nullptr) { - EditorNode::get_singleton()->show_warning(TTR("Error opening scene")); - return; - } - // Visibility data_mode->set_tab_hidden(1, p_for_animation); data_mode->set_tab_hidden(2, p_for_animation); @@ -593,6 +587,12 @@ void SceneImportSettings::open_settings(const String &p_path, bool p_for_animati } } + scene = ResourceImporterScene::get_scene_singleton()->pre_import(p_path, defaults); // Use the scene singleton here because we want to see the full thing. + if (scene == nullptr) { + EditorNode::get_singleton()->show_warning(TTR("Error opening scene")); + return; + } + first_aabb = true; _update_scene(); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 9ff32203f7..7e525a4698 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3697,7 +3697,7 @@ void CanvasItemEditor::_draw_transform_message() { return; } - Ref<FontFile> font = get_theme_font(SNAME("font"), SNAME("Label")); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); Point2 msgpos = Point2(RULER_WIDTH + 5 * EDSCALE, viewport->get_size().y - 20 * EDSCALE); viewport->draw_string(font, msgpos + Point2(1, 1), transform_message, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(0, 0, 0, 0.8)); |