diff options
Diffstat (limited to 'modules')
29 files changed, 713 insertions, 583 deletions
diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 1be690d894..2bfa191ff1 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -442,7 +442,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l if (str[k] == '(') { in_function_name = true; - } else if (prev_text == GDScriptTokenizer::get_token_name(GDScriptTokenizer::Token::VAR)) { + } else if (prev_text == GDScriptTokenizer::get_token_name(GDScriptTokenizer::Token::VAR) || prev_text == GDScriptTokenizer::get_token_name(GDScriptTokenizer::Token::FOR)) { in_variable_declaration = true; } @@ -480,7 +480,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l in_function_args = false; } - if (expect_type && (prev_is_char || str[j] == '=') && str[j] != '[') { + if (expect_type && (prev_is_char || str[j] == '=') && str[j] != '[' && str[j] != '.') { expect_type = false; } @@ -562,16 +562,11 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l } else if (in_keyword) { next_type = KEYWORD; color = keyword_color; - } else if (in_member_variable) { - next_type = MEMBER; - color = member_color; } else if (in_signal_declaration) { next_type = SIGNAL; - color = member_color; } else if (in_function_name) { next_type = FUNCTION; - if (!in_lambda && prev_text == GDScriptTokenizer::get_token_name(GDScriptTokenizer::Token::FUNC)) { color = function_definition_color; } else { @@ -586,6 +581,9 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l } else if (expect_type) { next_type = TYPE; color = type_color; + } else if (in_member_variable) { + next_type = MEMBER; + color = member_color; } else { next_type = IDENTIFIER; } @@ -683,6 +681,12 @@ void GDScriptSyntaxHighlighter::_update_cache() { for (const String &E : core_types) { class_names[StringName(E)] = basetype_color; } + class_names[SNAME("Variant")] = basetype_color; + class_names[SNAME("void")] = basetype_color; + // `get_core_type_words()` doesn't return primitive types. + class_names[SNAME("bool")] = basetype_color; + class_names[SNAME("int")] = basetype_color; + class_names[SNAME("float")] = basetype_color; /* Reserved words. */ const Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color"); @@ -697,6 +701,10 @@ void GDScriptSyntaxHighlighter::_update_cache() { } } + // Highlight `set` and `get` as "keywords" with the function color to avoid conflicts with method calls. + reserved_keywords[SNAME("set")] = function_color; + reserved_keywords[SNAME("get")] = function_color; + /* Global functions. */ List<StringName> global_function_list; GDScriptUtilityFunctions::get_function_list(&global_function_list); diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index b5c80d9e2d..f10ed0df29 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -2368,62 +2368,60 @@ void GDScriptLanguage::frame() { /* EDITOR FUNCTIONS */ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const { - // TODO: Add annotations here? + // Please keep alphabetical order within categories. static const char *_reserved_words[] = { - // operators + // Control flow. + "break", + "continue", + "elif", + "else", + "for", + "if", + "match", + "pass", + "return", + "when", + "while", + // Declarations. + "class", + "class_name", + "const", + "enum", + "extends", + "func", + "namespace", // Reserved for potential future use. + "signal", + "static", + "trait", // Reserved for potential future use. + "var", + // Other keywords. + "await", + "breakpoint", + "self", + "super", + "yield", // Reserved for potential future use. + // Operators. "and", + "as", "in", + "is", "not", "or", - // types and values + // Special values (tokenizer treats them as literals, not as tokens). "false", - "float", - "int", - "bool", "null", - "PI", - "TAU", + "true", + // Constants. "INF", "NAN", - "self", - "true", - "void", - // functions - "as", + "PI", + "TAU", + // Functions (highlighter uses global function color instead). "assert", - "await", - "breakpoint", - "class", - "class_name", - "extends", - "is", - "func", "preload", - "signal", - "super", - // var - "const", - "enum", - "static", - "var", - // control flow - "break", - "continue", - "if", - "elif", - "else", - "for", - "pass", - "return", - "match", - "while", - "when", - // These keywords are not implemented currently, but reserved for (potential) future use. - // We highlight them as keywords to make errors easier to understand. - "trait", - "namespace", - "yield", - nullptr + // Types (highlighter uses type color instead). + "void", + nullptr, }; const char **w = _reserved_words; @@ -2432,22 +2430,16 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const { p_words->push_back(*w); w++; } - - List<StringName> functions; - GDScriptUtilityFunctions::get_function_list(&functions); - - for (const StringName &E : functions) { - p_words->push_back(String(E)); - } } bool GDScriptLanguage::is_control_flow_keyword(String p_keyword) const { + // Please keep alphabetical order. return p_keyword == "break" || p_keyword == "continue" || p_keyword == "elif" || p_keyword == "else" || - p_keyword == "if" || p_keyword == "for" || + p_keyword == "if" || p_keyword == "match" || p_keyword == "pass" || p_keyword == "return" || diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index adfe4a3290..2f26069281 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -3396,6 +3396,12 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co } } + if ("Variant" == p_symbol) { + r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS; + r_result.class_name = "Variant"; + return OK; + } + if ("PI" == p_symbol || "TAU" == p_symbol || "INF" == p_symbol || "NAN" == p_symbol) { r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT; r_result.class_name = "@GDScript"; diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index 3e13d1525d..372c212d2b 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -140,7 +140,7 @@ Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_ar if (p_argcount == 0) { r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; - r_error.argument = 1; + r_error.expected = 1; return Variant(); } else if (p_argcount == 1) { //noooneee diff --git a/modules/gdscript/gdscript_utility_functions.cpp b/modules/gdscript/gdscript_utility_functions.cpp index d85b12b7fe..69a0b42d89 100644 --- a/modules/gdscript/gdscript_utility_functions.cpp +++ b/modules/gdscript/gdscript_utility_functions.cpp @@ -45,14 +45,12 @@ #define VALIDATE_ARG_COUNT(m_count) \ if (p_arg_count < m_count) { \ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; \ - r_error.argument = m_count; \ r_error.expected = m_count; \ *r_ret = Variant(); \ return; \ } \ if (p_arg_count > m_count) { \ r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; \ - r_error.argument = m_count; \ r_error.expected = m_count; \ *r_ret = Variant(); \ return; \ @@ -119,7 +117,6 @@ struct GDScriptUtilityFunctionsDefinitions { switch (p_arg_count) { case 0: { r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; - r_error.argument = 1; r_error.expected = 1; *r_ret = Variant(); } break; @@ -223,7 +220,6 @@ struct GDScriptUtilityFunctionsDefinitions { } break; default: { r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; - r_error.argument = 3; r_error.expected = 3; *r_ret = Variant(); @@ -251,6 +247,7 @@ struct GDScriptUtilityFunctionsDefinitions { } else if (p_args[0]->get_type() != Variant::OBJECT) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument = 0; + r_error.expected = Variant::OBJECT; *r_ret = Variant(); } else { Object *obj = *p_args[0]; @@ -390,13 +387,13 @@ struct GDScriptUtilityFunctionsDefinitions { static inline void Color8(Variant *r_ret, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { if (p_arg_count < 3) { r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; - r_error.argument = 3; + r_error.expected = 3; *r_ret = Variant(); return; } if (p_arg_count > 4) { r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; - r_error.argument = 4; + r_error.expected = 4; *r_ret = Variant(); return; } diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp index be18dee2cf..5ecae08f6c 100644 --- a/modules/gdscript/gdscript_vm.cpp +++ b/modules/gdscript/gdscript_vm.cpp @@ -519,7 +519,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a if (p_argcount > _argument_count) { r_err.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; r_err.expected = _argument_count; - call_depth--; return _get_default_variant_for_data_type(return_type); } else if (p_argcount < _argument_count - _default_arg_count) { diff --git a/modules/gdscript/tests/scripts/utils.notest.gd b/modules/gdscript/tests/scripts/utils.notest.gd index fb20817117..781843b8e2 100644 --- a/modules/gdscript/tests/scripts/utils.notest.gd +++ b/modules/gdscript/tests/scripts/utils.notest.gd @@ -17,7 +17,7 @@ static func get_type(property: Dictionary, is_return: bool = false) -> String: TYPE_OBJECT: if not str(property.class_name).is_empty(): return property.class_name - return variant_get_type_name(property.type) + return type_string(property.type) static func get_property_signature(property: Dictionary, is_static: bool = false) -> String: @@ -66,88 +66,6 @@ static func get_method_signature(method: Dictionary, is_signal: bool = false) -> return result -static func variant_get_type_name(type: Variant.Type) -> String: - match type: - TYPE_NIL: - return "Nil" # `Nil` in core, `null` in GDScript. - TYPE_BOOL: - return "bool" - TYPE_INT: - return "int" - TYPE_FLOAT: - return "float" - TYPE_STRING: - return "String" - TYPE_VECTOR2: - return "Vector2" - TYPE_VECTOR2I: - return "Vector2i" - TYPE_RECT2: - return "Rect2" - TYPE_RECT2I: - return "Rect2i" - TYPE_VECTOR3: - return "Vector3" - TYPE_VECTOR3I: - return "Vector3i" - TYPE_TRANSFORM2D: - return "Transform2D" - TYPE_VECTOR4: - return "Vector4" - TYPE_VECTOR4I: - return "Vector4i" - TYPE_PLANE: - return "Plane" - TYPE_QUATERNION: - return "Quaternion" - TYPE_AABB: - return "AABB" - TYPE_BASIS: - return "Basis" - TYPE_TRANSFORM3D: - return "Transform3D" - TYPE_PROJECTION: - return "Projection" - TYPE_COLOR: - return "Color" - TYPE_STRING_NAME: - return "StringName" - TYPE_NODE_PATH: - return "NodePath" - TYPE_RID: - return "RID" - TYPE_OBJECT: - return "Object" - TYPE_CALLABLE: - return "Callable" - TYPE_SIGNAL: - return "Signal" - TYPE_DICTIONARY: - return "Dictionary" - TYPE_ARRAY: - return "Array" - TYPE_PACKED_BYTE_ARRAY: - return "PackedByteArray" - TYPE_PACKED_INT32_ARRAY: - return "PackedInt32Array" - TYPE_PACKED_INT64_ARRAY: - return "PackedInt64Array" - TYPE_PACKED_FLOAT32_ARRAY: - return "PackedFloat32Array" - TYPE_PACKED_FLOAT64_ARRAY: - return "PackedFloat64Array" - TYPE_PACKED_STRING_ARRAY: - return "PackedStringArray" - TYPE_PACKED_VECTOR2_ARRAY: - return "PackedVector2Array" - TYPE_PACKED_VECTOR3_ARRAY: - return "PackedVector3Array" - TYPE_PACKED_COLOR_ARRAY: - return "PackedColorArray" - push_error("Argument `type` is invalid. Use `TYPE_*` constants.") - return "<invalid type>" - - static func get_property_hint_name(hint: PropertyHint) -> String: match hint: PROPERTY_HINT_NONE: diff --git a/modules/gdscript/tests/test_gdscript.cpp b/modules/gdscript/tests/test_gdscript.cpp index b86a8b3cb1..467bedc4b2 100644 --- a/modules/gdscript/tests/test_gdscript.cpp +++ b/modules/gdscript/tests/test_gdscript.cpp @@ -223,6 +223,16 @@ void test(TestType p_type) { // Initialize the language for the test routine. init_language(fa->get_path_absolute().get_base_dir()); + // Load global classes. + TypedArray<Dictionary> script_classes = ProjectSettings::get_singleton()->get_global_class_list(); + for (int i = 0; i < script_classes.size(); i++) { + Dictionary c = script_classes[i]; + if (!c.has("class") || !c.has("language") || !c.has("path") || !c.has("base")) { + continue; + } + ScriptServer::add_global_class(c["class"], c["base"], c["language"], c["path"]); + } + Vector<uint8_t> buf; uint64_t flen = fa->get_length(); buf.resize(flen + 1); diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp index 3787d0fe5e..cb45a6589e 100644 --- a/modules/gltf/editor/editor_scene_importer_blend.cpp +++ b/modules/gltf/editor/editor_scene_importer_blend.cpp @@ -49,6 +49,67 @@ #include <shlwapi.h> #endif +static bool _get_blender_version(const String &p_path, int &r_major, int &r_minor, String *r_err = nullptr) { + String path = p_path; +#ifdef WINDOWS_ENABLED + path = path.path_join("blender.exe"); +#else + path = path.path_join("blender"); +#endif + +#if defined(MACOS_ENABLED) + if (!FileAccess::exists(path)) { + path = p_path.path_join("Blender"); + } +#endif + + if (!FileAccess::exists(path)) { + if (r_err) { + *r_err = TTR("Path does not contain a Blender installation."); + } + return false; + } + List<String> args; + args.push_back("--version"); + String pipe; + Error err = OS::get_singleton()->execute(path, args, &pipe); + if (err != OK) { + if (r_err) { + *r_err = TTR("Can't execute Blender binary."); + } + return false; + } + int bl = pipe.find("Blender "); + if (bl == -1) { + if (r_err) { + *r_err = vformat(TTR("Unexpected --version output from Blender binary at: %s."), path); + } + return false; + } + pipe = pipe.substr(bl); + pipe = pipe.replace_first("Blender ", ""); + int pp = pipe.find("."); + if (pp == -1) { + if (r_err) { + *r_err = TTR("Path supplied lacks a Blender binary."); + } + return false; + } + String v = pipe.substr(0, pp); + r_major = v.to_int(); + if (r_major < 3) { + if (r_err) { + *r_err = TTR("This Blender installation is too old for this importer (not 3.0+)."); + } + return false; + } + + int pp2 = pipe.find(".", pp + 1); + r_minor = pp2 > pp ? pipe.substr(pp + 1, pp2 - pp - 1).to_int() : 0; + + return true; +} + uint32_t EditorSceneFormatImporterBlend::get_import_flags() const { return ImportFlags::IMPORT_SCENE | ImportFlags::IMPORT_ANIMATION; } @@ -60,8 +121,13 @@ void EditorSceneFormatImporterBlend::get_extensions(List<String> *r_extensions) Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, List<String> *r_missing_deps, Error *r_err) { - // Get global paths for source and sink. + String blender_path = EDITOR_GET("filesystem/import/blender/blender3_path"); + if (blender_major_version == -1 || blender_minor_version == -1) { + _get_blender_version(blender_path, blender_major_version, blender_minor_version, nullptr); + } + + // Get global paths for source and sink. // Escape paths to be valid Python strings to embed in the script. const String source_global = ProjectSettings::get_singleton()->globalize_path(p_path).c_escape(); const String sink = ProjectSettings::get_singleton()->get_imported_files_path().path_join( @@ -153,9 +219,17 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_ parameters_map["export_tangents"] = false; } if (p_options.has(SNAME("blender/animation/group_tracks")) && p_options[SNAME("blender/animation/group_tracks")]) { - parameters_map["export_nla_strips"] = true; + if (blender_major_version > 3 || (blender_major_version == 3 && blender_minor_version >= 6)) { + parameters_map["export_animation_mode"] = "ACTIONS"; + } else { + parameters_map["export_nla_strips"] = true; + } } else { - parameters_map["export_nla_strips"] = false; + if (blender_major_version > 3 || (blender_major_version == 3 && blender_minor_version >= 6)) { + parameters_map["export_animation_mode"] = "ACTIVE_ACTIONS"; + } else { + parameters_map["export_nla_strips"] = false; + } } if (p_options.has(SNAME("blender/animation/limit_playback")) && p_options[SNAME("blender/animation/limit_playback")]) { parameters_map["export_frame_range"] = true; @@ -269,67 +343,8 @@ void EditorSceneFormatImporterBlend::get_import_options(const String &p_path, Li /////////////////////////// static bool _test_blender_path(const String &p_path, String *r_err = nullptr) { - String path = p_path; -#ifdef WINDOWS_ENABLED - path = path.path_join("blender.exe"); -#else - path = path.path_join("blender"); -#endif - -#if defined(MACOS_ENABLED) - if (!FileAccess::exists(path)) { - path = path.path_join("Blender"); - } -#endif - - if (!FileAccess::exists(path)) { - if (r_err) { - *r_err = TTR("Path does not contain a Blender installation."); - } - return false; - } - List<String> args; - args.push_back("--version"); - String pipe; - Error err = OS::get_singleton()->execute(path, args, &pipe); - if (err != OK) { - if (r_err) { - *r_err = TTR("Can't execute Blender binary."); - } - return false; - } - int bl = pipe.find("Blender "); - if (bl == -1) { - if (r_err) { - *r_err = vformat(TTR("Unexpected --version output from Blender binary at: %s"), path); - } - return false; - } - pipe = pipe.substr(bl); - pipe = pipe.replace_first("Blender ", ""); - int pp = pipe.find("."); - if (pp == -1) { - if (r_err) { - *r_err = TTR("Path supplied lacks a Blender binary."); - } - return false; - } - String v = pipe.substr(0, pp); - int version = v.to_int(); - if (version < 3) { - if (r_err) { - *r_err = TTR("This Blender installation is too old for this importer (not 3.0+)."); - } - return false; - } - if (version > 3) { - if (r_err) { - *r_err = TTR("This Blender installation is too new for this importer (not 3.x)."); - } - return false; - } - - return true; + int major, minor; + return _get_blender_version(p_path, major, minor, r_err); } bool EditorFileSystemImportFormatSupportQueryBlend::is_active() const { diff --git a/modules/gltf/editor/editor_scene_importer_blend.h b/modules/gltf/editor/editor_scene_importer_blend.h index c77a23f9f6..ec467db457 100644 --- a/modules/gltf/editor/editor_scene_importer_blend.h +++ b/modules/gltf/editor/editor_scene_importer_blend.h @@ -43,6 +43,9 @@ class ConfirmationDialog; class EditorSceneFormatImporterBlend : public EditorSceneFormatImporter { GDCLASS(EditorSceneFormatImporterBlend, EditorSceneFormatImporter); + int blender_major_version = -1; + int blender_minor_version = -1; + public: enum { BLEND_VISIBLE_ALL, diff --git a/modules/lightmapper_rd/config.py b/modules/lightmapper_rd/config.py index d22f9454ed..ecc61c2d7e 100644 --- a/modules/lightmapper_rd/config.py +++ b/modules/lightmapper_rd/config.py @@ -1,5 +1,5 @@ def can_build(env, platform): - return True + return env.editor_build and platform not in ["android", "ios"] def configure(env): diff --git a/modules/lightmapper_rd/lightmapper_rd.cpp b/modules/lightmapper_rd/lightmapper_rd.cpp index e9550f9c28..556b0b4374 100644 --- a/modules/lightmapper_rd/lightmapper_rd.cpp +++ b/modules/lightmapper_rd/lightmapper_rd.cpp @@ -1493,14 +1493,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d } #endif - { - SWAP(light_accum_tex, light_accum_tex2); - BakeError error = _dilate(rd, compute_shader, compute_base_uniform_set, push_constant, light_accum_tex2, light_accum_tex, atlas_size, atlas_slices * (p_bake_sh ? 4 : 1)); - if (unlikely(error != BAKE_OK)) { - return error; - } - } - /* DENOISE */ if (p_use_denoiser) { @@ -1515,13 +1507,13 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d return error; } } + } - { - SWAP(light_accum_tex, light_accum_tex2); - BakeError error = _dilate(rd, compute_shader, compute_base_uniform_set, push_constant, light_accum_tex2, light_accum_tex, atlas_size, atlas_slices * (p_bake_sh ? 4 : 1)); - if (unlikely(error != BAKE_OK)) { - return error; - } + { + SWAP(light_accum_tex, light_accum_tex2); + BakeError error = _dilate(rd, compute_shader, compute_base_uniform_set, push_constant, light_accum_tex2, light_accum_tex, atlas_size, atlas_slices * (p_bake_sh ? 4 : 1)); + if (unlikely(error != BAKE_OK)) { + return error; } } diff --git a/modules/lightmapper_rd/register_types.cpp b/modules/lightmapper_rd/register_types.cpp index 7ec4a40766..984ce88316 100644 --- a/modules/lightmapper_rd/register_types.cpp +++ b/modules/lightmapper_rd/register_types.cpp @@ -58,7 +58,6 @@ void initialize_lightmapper_rd_module(ModuleInitializationLevel p_level) { GLOBAL_DEF("rendering/lightmapping/bake_quality/high_quality_probe_ray_count", 512); GLOBAL_DEF("rendering/lightmapping/bake_quality/ultra_quality_probe_ray_count", 2048); GLOBAL_DEF("rendering/lightmapping/bake_performance/max_rays_per_probe_pass", 64); - GLOBAL_DEF("rendering/lightmapping/primitive_meshes/texel_size", 0.2); #ifndef _3D_DISABLED GDREGISTER_CLASS(LightmapperRD); Lightmapper::create_gpu = create_lightmapper_rd; diff --git a/modules/minimp3/SCsub b/modules/minimp3/SCsub index 20e3165f38..09e84f71e9 100644 --- a/modules/minimp3/SCsub +++ b/modules/minimp3/SCsub @@ -13,5 +13,8 @@ if not env.msvc: else: env_minimp3.Prepend(CPPPATH=[thirdparty_dir]) +if not env["minimp3_extra_formats"]: + env_minimp3.Append(CPPDEFINES=["MINIMP3_ONLY_MP3"]) + # Godot source files env_minimp3.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/minimp3/audio_stream_mp3.cpp b/modules/minimp3/audio_stream_mp3.cpp index 6af86a96dc..4efa4d329e 100644 --- a/modules/minimp3/audio_stream_mp3.cpp +++ b/modules/minimp3/audio_stream_mp3.cpp @@ -28,7 +28,6 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#define MINIMP3_ONLY_MP3 #define MINIMP3_FLOAT_OUTPUT #define MINIMP3_IMPLEMENTATION #define MINIMP3_NO_STDIO diff --git a/modules/minimp3/config.py b/modules/minimp3/config.py index e6bdcb2a83..115b376fc8 100644 --- a/modules/minimp3/config.py +++ b/modules/minimp3/config.py @@ -2,6 +2,14 @@ def can_build(env, platform): return True +def get_opts(platform): + from SCons.Variables import BoolVariable + + return [ + BoolVariable("minimp3_extra_formats", "Build minimp3 with MP1/MP2 decoding support", False), + ] + + def configure(env): pass diff --git a/modules/minimp3/resource_importer_mp3.cpp b/modules/minimp3/resource_importer_mp3.cpp index 4e56120ec6..d60b979c3f 100644 --- a/modules/minimp3/resource_importer_mp3.cpp +++ b/modules/minimp3/resource_importer_mp3.cpp @@ -47,6 +47,10 @@ String ResourceImporterMP3::get_visible_name() const { } void ResourceImporterMP3::get_recognized_extensions(List<String> *p_extensions) const { +#ifndef MINIMP3_ONLY_MP3 + p_extensions->push_back("mp1"); + p_extensions->push_back("mp2"); +#endif p_extensions->push_back("mp3"); } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs index 81b2ffef34..09269508b7 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs @@ -134,6 +134,38 @@ namespace Godot } /// <summary> + /// Returns the difference between the two angles, + /// in range of -<see cref="Pi"/>, <see cref="Pi"/>. + /// When <paramref name="from"/> and <paramref name="to"/> are opposite, + /// returns -<see cref="Pi"/> if <paramref name="from"/> is smaller than <paramref name="to"/>, + /// or <see cref="Pi"/> otherwise. + /// </summary> + /// <param name="from">The start angle.</param> + /// <param name="to">The destination angle.</param> + /// <returns>The difference between the two angles.</returns> + public static float AngleDifference(float from, float to) + { + float difference = (to - from) % MathF.Tau; + return ((2.0f * difference) % MathF.Tau) - difference; + } + + /// <summary> + /// Returns the difference between the two angles, + /// in range of -<see cref="Pi"/>, <see cref="Pi"/>. + /// When <paramref name="from"/> and <paramref name="to"/> are opposite, + /// returns -<see cref="Pi"/> if <paramref name="from"/> is smaller than <paramref name="to"/>, + /// or <see cref="Pi"/> otherwise. + /// </summary> + /// <param name="from">The start angle.</param> + /// <param name="to">The destination angle.</param> + /// <returns>The difference between the two angles.</returns> + public static double AngleDifference(double from, double to) + { + double difference = (to - from) % Math.Tau; + return ((2.0 * difference) % Math.Tau) - difference; + } + + /// <summary> /// Returns the arc sine of <paramref name="s"/> in radians. /// Use to get the angle of sine <paramref name="s"/>. /// </summary> @@ -1093,9 +1125,7 @@ namespace Godot /// <returns>The resulting angle of the interpolation.</returns> public static float LerpAngle(float from, float to, float weight) { - float difference = (to - from) % MathF.Tau; - float distance = ((2 * difference) % MathF.Tau) - difference; - return from + (distance * weight); + return from + AngleDifference(from, to) * weight; } /// <summary> @@ -1110,9 +1140,7 @@ namespace Godot /// <returns>The resulting angle of the interpolation.</returns> public static double LerpAngle(double from, double to, double weight) { - double difference = (to - from) % Math.Tau; - double distance = ((2 * difference) % Math.Tau) - difference; - return from + (distance * weight); + return from + AngleDifference(from, to) * weight; } /// <summary> @@ -1429,6 +1457,38 @@ namespace Godot } /// <summary> + /// Rotates <paramref name="from"/> toward <paramref name="to"/> by the <paramref name="delta"/> amount. Will not go past <paramref name="to"/>. + /// Similar to <see cref="MoveToward(float, float, float)"/> but interpolates correctly when the angles wrap around <see cref="Tau"/>. + /// If <paramref name="delta"/> is negative, this function will rotate away from <paramref name="to"/>, toward the opposite angle, and will not go past the opposite angle. + /// </summary> + /// <param name="from">The start angle.</param> + /// <param name="to">The angle to move towards.</param> + /// <param name="delta">The amount to move by.</param> + /// <returns>The angle after moving.</returns> + public static float RotateToward(float from, float to, float delta) + { + float difference = AngleDifference(from, to); + float absDifference = Math.Abs(difference); + return from + Math.Clamp(delta, absDifference - MathF.PI, absDifference) * (difference >= 0.0f ? 1.0f : -1.0f); + } + + /// <summary> + /// Rotates <paramref name="from"/> toward <paramref name="to"/> by the <paramref name="delta"/> amount. Will not go past <paramref name="to"/>. + /// Similar to <see cref="MoveToward(double, double, double)"/> but interpolates correctly when the angles wrap around <see cref="Tau"/>. + /// If <paramref name="delta"/> is negative, this function will rotate away from <paramref name="to"/>, toward the opposite angle, and will not go past the opposite angle. + /// </summary> + /// <param name="from">The start angle.</param> + /// <param name="to">The angle to move towards.</param> + /// <param name="delta">The amount to move by.</param> + /// <returns>The angle after moving.</returns> + public static double RotateToward(double from, double to, double delta) + { + double difference = AngleDifference(from, to); + double absDifference = Math.Abs(difference); + return from + Math.Clamp(delta, absDifference - Math.PI, absDifference) * (difference >= 0.0 ? 1.0 : -1.0); + } + + /// <summary> /// Rounds <paramref name="s"/> to the nearest whole number, /// with halfway cases rounded towards the nearest multiple of two. /// </summary> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/ExceptionUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/ExceptionUtils.cs index a656c5de90..dc53e48bd0 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/ExceptionUtils.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/ExceptionUtils.cs @@ -206,7 +206,7 @@ namespace Godot.NativeInterop } case godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_TOO_MANY_ARGUMENTS: case godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_TOO_FEW_ARGUMENTS: - return $"Invalid call to {where}. Expected {error.Argument} arguments."; + return $"Invalid call to {where}. Expected {error.Expected} arguments."; case godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_INVALID_METHOD: return $"Invalid call. Nonexistent {where}."; case godot_variant_call_error_error.GODOT_CALL_ERROR_CALL_ERROR_INSTANCE_IS_NULL: diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs index 0b203c5148..d26d4662a0 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs @@ -265,7 +265,7 @@ namespace Godot return new Vector3( Mathf.BezierDerivative(X, control1.X, control2.X, end.X, t), Mathf.BezierDerivative(Y, control1.Y, control2.Y, end.Y, t), - Mathf.BezierDerivative(Z, control1.Z, control2.Z, end.Y, t) + Mathf.BezierDerivative(Z, control1.Z, control2.Z, end.Z, t) ); } diff --git a/modules/svg/SCsub b/modules/svg/SCsub index 55b8c4f4a0..a99bc8df60 100644 --- a/modules/svg/SCsub +++ b/modules/svg/SCsub @@ -11,39 +11,45 @@ thirdparty_obj = [] thirdparty_dir = "#thirdparty/thorvg/" thirdparty_sources = [ - "src/lib/sw_engine/tvgSwFill.cpp", - "src/lib/sw_engine/tvgSwImage.cpp", - "src/lib/sw_engine/tvgSwMath.cpp", - "src/lib/sw_engine/tvgSwMemPool.cpp", - "src/lib/sw_engine/tvgSwRaster.cpp", - "src/lib/sw_engine/tvgSwRenderer.cpp", - "src/lib/sw_engine/tvgSwRle.cpp", - "src/lib/sw_engine/tvgSwShape.cpp", - "src/lib/sw_engine/tvgSwStroke.cpp", - "src/lib/tvgAccessor.cpp", - "src/lib/tvgCanvas.cpp", - "src/lib/tvgFill.cpp", - "src/lib/tvgGlCanvas.cpp", - "src/lib/tvgInitializer.cpp", - "src/lib/tvgLoader.cpp", - "src/lib/tvgPaint.cpp", - "src/lib/tvgPicture.cpp", - "src/lib/tvgRender.cpp", - "src/lib/tvgSaver.cpp", - "src/lib/tvgScene.cpp", - "src/lib/tvgShape.cpp", - "src/lib/tvgSwCanvas.cpp", - "src/lib/tvgTaskScheduler.cpp", - "src/utils/tvgBezier.cpp", - "src/utils/tvgCompressor.cpp", - "src/utils/tvgStr.cpp", - "src/loaders/raw/tvgRawLoader.cpp", + # common + "src/common/tvgBezier.cpp", + "src/common/tvgCompressor.cpp", + "src/common/tvgMath.cpp", + "src/common/tvgStr.cpp", + # SVG parser "src/loaders/svg/tvgSvgCssStyle.cpp", "src/loaders/svg/tvgSvgLoader.cpp", "src/loaders/svg/tvgSvgPath.cpp", "src/loaders/svg/tvgSvgSceneBuilder.cpp", "src/loaders/svg/tvgSvgUtil.cpp", "src/loaders/svg/tvgXmlParser.cpp", + "src/loaders/raw/tvgRawLoader.cpp", + # renderer common + "src/renderer/tvgAccessor.cpp", + # "src/renderer/tvgAnimation.cpp", + "src/renderer/tvgCanvas.cpp", + "src/renderer/tvgFill.cpp", + # "src/renderer/tvgGlCanvas.cpp", + "src/renderer/tvgInitializer.cpp", + "src/renderer/tvgLoader.cpp", + "src/renderer/tvgPaint.cpp", + "src/renderer/tvgPicture.cpp", + "src/renderer/tvgRender.cpp", + # "src/renderer/tvgSaver.cpp", + "src/renderer/tvgScene.cpp", + "src/renderer/tvgShape.cpp", + "src/renderer/tvgSwCanvas.cpp", + "src/renderer/tvgTaskScheduler.cpp", + # renderer sw_engine + "src/renderer/sw_engine/tvgSwFill.cpp", + "src/renderer/sw_engine/tvgSwImage.cpp", + "src/renderer/sw_engine/tvgSwMath.cpp", + "src/renderer/sw_engine/tvgSwMemPool.cpp", + "src/renderer/sw_engine/tvgSwRaster.cpp", + "src/renderer/sw_engine/tvgSwRenderer.cpp", + "src/renderer/sw_engine/tvgSwRle.cpp", + "src/renderer/sw_engine/tvgSwShape.cpp", + "src/renderer/sw_engine/tvgSwStroke.cpp", ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] @@ -57,16 +63,13 @@ env_thirdparty = env_svg.Clone() env_thirdparty.disable_warnings() env_thirdparty.Prepend( CPPPATH=[ - thirdparty_dir + "src/lib", - thirdparty_dir + "src/lib/sw_engine", - thirdparty_dir + "src/loaders/raw", + thirdparty_dir + "src/common", thirdparty_dir + "src/loaders/svg", - thirdparty_dir + "src/utils", + thirdparty_dir + "src/renderer", + thirdparty_dir + "src/renderer/sw_engine", + thirdparty_dir + "src/loaders/raw", ] ) -# Also requires libpng headers -if env["builtin_libpng"]: - env_thirdparty.Prepend(CPPPATH=["#thirdparty/libpng"]) env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources) env.modules_sources += thirdparty_obj diff --git a/modules/text_server_adv/SCsub b/modules/text_server_adv/SCsub index 1acff68135..3c468e61d7 100644 --- a/modules/text_server_adv/SCsub +++ b/modules/text_server_adv/SCsub @@ -40,7 +40,11 @@ msdfgen_enabled = "msdfgen" in env.module_list if "svg" in env.module_list: env_text_server_adv.Prepend( - CPPPATH=["#thirdparty/thorvg/inc", "#thirdparty/thorvg/src/lib", "#thirdparty/thorvg/src/utils"] + CPPPATH=[ + "#thirdparty/thorvg/inc", + "#thirdparty/thorvg/src/common", + "#thirdparty/thorvg/src/renderer", + ] ) # Enable ThorVG static object linking. env_text_server_adv.Append(CPPDEFINES=["TVG_STATIC"]) diff --git a/modules/text_server_adv/gdextension_build/SConstruct b/modules/text_server_adv/gdextension_build/SConstruct index bf29ad3016..b95c35f80d 100644 --- a/modules/text_server_adv/gdextension_build/SConstruct +++ b/modules/text_server_adv/gdextension_build/SConstruct @@ -42,51 +42,56 @@ if env["thorvg_enabled"] and env["freetype_enabled"]: thirdparty_tvg_dir = "../../../thirdparty/thorvg/" thirdparty_tvg_sources = [ - "src/lib/sw_engine/tvgSwFill.cpp", - "src/lib/sw_engine/tvgSwImage.cpp", - "src/lib/sw_engine/tvgSwMath.cpp", - "src/lib/sw_engine/tvgSwMemPool.cpp", - "src/lib/sw_engine/tvgSwRaster.cpp", - "src/lib/sw_engine/tvgSwRenderer.cpp", - "src/lib/sw_engine/tvgSwRle.cpp", - "src/lib/sw_engine/tvgSwShape.cpp", - "src/lib/sw_engine/tvgSwStroke.cpp", - "src/lib/tvgAccessor.cpp", - "src/lib/tvgCanvas.cpp", - "src/lib/tvgFill.cpp", - "src/lib/tvgGlCanvas.cpp", - "src/lib/tvgInitializer.cpp", - "src/lib/tvgLoader.cpp", - "src/lib/tvgPaint.cpp", - "src/lib/tvgPicture.cpp", - "src/lib/tvgRender.cpp", - "src/lib/tvgSaver.cpp", - "src/lib/tvgScene.cpp", - "src/lib/tvgShape.cpp", - "src/lib/tvgSwCanvas.cpp", - "src/lib/tvgTaskScheduler.cpp", - "src/utils/tvgBezier.cpp", - "src/utils/tvgCompressor.cpp", - "src/utils/tvgStr.cpp", - "src/loaders/raw/tvgRawLoader.cpp", + # common + "src/common/tvgBezier.cpp", + "src/common/tvgCompressor.cpp", + "src/common/tvgMath.cpp", + "src/common/tvgStr.cpp", + # SVG parser "src/loaders/svg/tvgSvgCssStyle.cpp", "src/loaders/svg/tvgSvgLoader.cpp", "src/loaders/svg/tvgSvgPath.cpp", "src/loaders/svg/tvgSvgSceneBuilder.cpp", "src/loaders/svg/tvgSvgUtil.cpp", "src/loaders/svg/tvgXmlParser.cpp", + "src/loaders/raw/tvgRawLoader.cpp", + # renderer common + "src/renderer/tvgAccessor.cpp", + # "src/renderer/tvgAnimation.cpp", + "src/renderer/tvgCanvas.cpp", + "src/renderer/tvgFill.cpp", + # "src/renderer/tvgGlCanvas.cpp", + "src/renderer/tvgInitializer.cpp", + "src/renderer/tvgLoader.cpp", + "src/renderer/tvgPaint.cpp", + "src/renderer/tvgPicture.cpp", + "src/renderer/tvgRender.cpp", + # "src/renderer/tvgSaver.cpp", + "src/renderer/tvgScene.cpp", + "src/renderer/tvgShape.cpp", + "src/renderer/tvgSwCanvas.cpp", + "src/renderer/tvgTaskScheduler.cpp", + # renderer sw_engine + "src/renderer/sw_engine/tvgSwFill.cpp", + "src/renderer/sw_engine/tvgSwImage.cpp", + "src/renderer/sw_engine/tvgSwMath.cpp", + "src/renderer/sw_engine/tvgSwMemPool.cpp", + "src/renderer/sw_engine/tvgSwRaster.cpp", + "src/renderer/sw_engine/tvgSwRenderer.cpp", + "src/renderer/sw_engine/tvgSwRle.cpp", + "src/renderer/sw_engine/tvgSwShape.cpp", + "src/renderer/sw_engine/tvgSwStroke.cpp", ] thirdparty_tvg_sources = [thirdparty_tvg_dir + file for file in thirdparty_tvg_sources] env_tvg.Append( CPPPATH=[ "../../../thirdparty/thorvg/inc", - "../../../thirdparty/thorvg/src/lib", - "../../../thirdparty/thorvg/src/lib/sw_engine", - "../../../thirdparty/thorvg/src/loaders/raw", + "../../../thirdparty/thorvg/src/common", "../../../thirdparty/thorvg/src/loaders/svg", - "../../../thirdparty/thorvg/src/utils", - "../../../thirdparty/libpng", + "../../../thirdparty/thorvg/src/loaders/raw", + "../../../thirdparty/thorvg/src/renderer", + "../../../thirdparty/thorvg/src/renderer/sw_engine", ] ) @@ -96,8 +101,8 @@ if env["thorvg_enabled"] and env["freetype_enabled"]: env.Append( CPPPATH=[ "../../../thirdparty/thorvg/inc", - "../../../thirdparty/thorvg/src/lib", - "../../../thirdparty/thorvg/src/utils", + "../../../thirdparty/thorvg/src/common", + "../../../thirdparty/thorvg/src/renderer", ] ) env.Append(CPPDEFINES=["MODULE_SVG_ENABLED"]) diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 9adb10236e..b605b29f84 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -397,6 +397,14 @@ void TextServerAdvanced::_free_rid(const RID &p_rid) { font_owner.free(p_rid); } memdelete(fd); + } else if (font_var_owner.owns(p_rid)) { + MutexLock ftlock(ft_mutex); + + FontAdvancedLinkedVariation *fdv = font_var_owner.get_or_null(p_rid); + { + font_var_owner.free(p_rid); + } + memdelete(fdv); } else if (shaped_owner.owns(p_rid)) { ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_rid); { @@ -409,7 +417,7 @@ void TextServerAdvanced::_free_rid(const RID &p_rid) { bool TextServerAdvanced::_has(const RID &p_rid) { _THREAD_SAFE_METHOD_ - return font_owner.owns(p_rid) || shaped_owner.owns(p_rid); + return font_owner.owns(p_rid) || font_var_owner.owns(p_rid) || shaped_owner.owns(p_rid); } bool TextServerAdvanced::_load_support_data(const String &p_filename) { @@ -1809,7 +1817,7 @@ _FORCE_INLINE_ void TextServerAdvanced::_font_clear_cache(FontAdvanced *p_font_d } hb_font_t *TextServerAdvanced::_font_get_hb_handle(const RID &p_font_rid, int64_t p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, nullptr); MutexLock lock(fd->mutex); @@ -1828,8 +1836,24 @@ RID TextServerAdvanced::_create_font() { return font_owner.make_rid(fd); } +RID TextServerAdvanced::_create_font_linked_variation(const RID &p_font_rid) { + _THREAD_SAFE_METHOD_ + + RID rid = p_font_rid; + FontAdvancedLinkedVariation *fdv = font_var_owner.get_or_null(rid); + if (unlikely(fdv)) { + rid = fdv->base_font; + } + ERR_FAIL_COND_V(!font_owner.owns(rid), RID()); + + FontAdvancedLinkedVariation *new_fdv = memnew(FontAdvancedLinkedVariation); + new_fdv->base_font = rid; + + return font_var_owner.make_rid(new_fdv); +} + void TextServerAdvanced::_font_set_data(const RID &p_font_rid, const PackedByteArray &p_data) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1840,7 +1864,7 @@ void TextServerAdvanced::_font_set_data(const RID &p_font_rid, const PackedByteA } void TextServerAdvanced::_font_set_data_ptr(const RID &p_font_rid, const uint8_t *p_data_ptr, int64_t p_data_size) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1854,7 +1878,7 @@ void TextServerAdvanced::_font_set_face_index(const RID &p_font_rid, int64_t p_f ERR_FAIL_COND(p_face_index < 0); ERR_FAIL_COND(p_face_index >= 0x7FFF); - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1865,7 +1889,7 @@ void TextServerAdvanced::_font_set_face_index(const RID &p_font_rid, int64_t p_f } int64_t TextServerAdvanced::_font_get_face_index(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0); MutexLock lock(fd->mutex); @@ -1873,7 +1897,7 @@ int64_t TextServerAdvanced::_font_get_face_index(const RID &p_font_rid) const { } int64_t TextServerAdvanced::_font_get_face_count(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0); MutexLock lock(fd->mutex); @@ -1919,7 +1943,7 @@ int64_t TextServerAdvanced::_font_get_face_count(const RID &p_font_rid) const { } void TextServerAdvanced::_font_set_style(const RID &p_font_rid, BitField<FontStyle> p_style) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1929,7 +1953,7 @@ void TextServerAdvanced::_font_set_style(const RID &p_font_rid, BitField<FontSty } BitField<TextServer::FontStyle> TextServerAdvanced::_font_get_style(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0); MutexLock lock(fd->mutex); @@ -1939,7 +1963,7 @@ BitField<TextServer::FontStyle> TextServerAdvanced::_font_get_style(const RID &p } void TextServerAdvanced::_font_set_style_name(const RID &p_font_rid, const String &p_name) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1949,7 +1973,7 @@ void TextServerAdvanced::_font_set_style_name(const RID &p_font_rid, const Strin } String TextServerAdvanced::_font_get_style_name(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, String()); MutexLock lock(fd->mutex); @@ -1959,7 +1983,7 @@ String TextServerAdvanced::_font_get_style_name(const RID &p_font_rid) const { } void TextServerAdvanced::_font_set_weight(const RID &p_font_rid, int64_t p_weight) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1969,7 +1993,7 @@ void TextServerAdvanced::_font_set_weight(const RID &p_font_rid, int64_t p_weigh } int64_t TextServerAdvanced::_font_get_weight(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 400); MutexLock lock(fd->mutex); @@ -1979,7 +2003,7 @@ int64_t TextServerAdvanced::_font_get_weight(const RID &p_font_rid) const { } void TextServerAdvanced::_font_set_stretch(const RID &p_font_rid, int64_t p_stretch) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1989,7 +2013,7 @@ void TextServerAdvanced::_font_set_stretch(const RID &p_font_rid, int64_t p_stre } int64_t TextServerAdvanced::_font_get_stretch(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 100); MutexLock lock(fd->mutex); @@ -1999,7 +2023,7 @@ int64_t TextServerAdvanced::_font_get_stretch(const RID &p_font_rid) const { } void TextServerAdvanced::_font_set_name(const RID &p_font_rid, const String &p_name) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2009,7 +2033,7 @@ void TextServerAdvanced::_font_set_name(const RID &p_font_rid, const String &p_n } String TextServerAdvanced::_font_get_name(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, String()); MutexLock lock(fd->mutex); @@ -2019,7 +2043,7 @@ String TextServerAdvanced::_font_get_name(const RID &p_font_rid) const { } Dictionary TextServerAdvanced::_font_get_ot_name_strings(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Dictionary()); MutexLock lock(fd->mutex); @@ -2132,7 +2156,7 @@ Dictionary TextServerAdvanced::_font_get_ot_name_strings(const RID &p_font_rid) } void TextServerAdvanced::_font_set_antialiasing(const RID &p_font_rid, TextServer::FontAntialiasing p_antialiasing) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2143,7 +2167,7 @@ void TextServerAdvanced::_font_set_antialiasing(const RID &p_font_rid, TextServe } TextServer::FontAntialiasing TextServerAdvanced::_font_get_antialiasing(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, TextServer::FONT_ANTIALIASING_NONE); MutexLock lock(fd->mutex); @@ -2151,7 +2175,7 @@ TextServer::FontAntialiasing TextServerAdvanced::_font_get_antialiasing(const RI } void TextServerAdvanced::_font_set_generate_mipmaps(const RID &p_font_rid, bool p_generate_mipmaps) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2167,7 +2191,7 @@ void TextServerAdvanced::_font_set_generate_mipmaps(const RID &p_font_rid, bool } bool TextServerAdvanced::_font_get_generate_mipmaps(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -2175,7 +2199,7 @@ bool TextServerAdvanced::_font_get_generate_mipmaps(const RID &p_font_rid) const } void TextServerAdvanced::_font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2186,7 +2210,7 @@ void TextServerAdvanced::_font_set_multichannel_signed_distance_field(const RID } bool TextServerAdvanced::_font_is_multichannel_signed_distance_field(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -2194,7 +2218,7 @@ bool TextServerAdvanced::_font_is_multichannel_signed_distance_field(const RID & } void TextServerAdvanced::_font_set_msdf_pixel_range(const RID &p_font_rid, int64_t p_msdf_pixel_range) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2205,7 +2229,7 @@ void TextServerAdvanced::_font_set_msdf_pixel_range(const RID &p_font_rid, int64 } int64_t TextServerAdvanced::_font_get_msdf_pixel_range(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -2213,7 +2237,7 @@ int64_t TextServerAdvanced::_font_get_msdf_pixel_range(const RID &p_font_rid) co } void TextServerAdvanced::_font_set_msdf_size(const RID &p_font_rid, int64_t p_msdf_size) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2224,7 +2248,7 @@ void TextServerAdvanced::_font_set_msdf_size(const RID &p_font_rid, int64_t p_ms } int64_t TextServerAdvanced::_font_get_msdf_size(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -2232,7 +2256,7 @@ int64_t TextServerAdvanced::_font_get_msdf_size(const RID &p_font_rid) const { } void TextServerAdvanced::_font_set_fixed_size(const RID &p_font_rid, int64_t p_fixed_size) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2240,7 +2264,7 @@ void TextServerAdvanced::_font_set_fixed_size(const RID &p_font_rid, int64_t p_f } int64_t TextServerAdvanced::_font_get_fixed_size(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -2248,7 +2272,7 @@ int64_t TextServerAdvanced::_font_get_fixed_size(const RID &p_font_rid) const { } void TextServerAdvanced::_font_set_allow_system_fallback(const RID &p_font_rid, bool p_allow_system_fallback) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2256,7 +2280,7 @@ void TextServerAdvanced::_font_set_allow_system_fallback(const RID &p_font_rid, } bool TextServerAdvanced::_font_is_allow_system_fallback(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -2264,7 +2288,7 @@ bool TextServerAdvanced::_font_is_allow_system_fallback(const RID &p_font_rid) c } void TextServerAdvanced::_font_set_force_autohinter(const RID &p_font_rid, bool p_force_autohinter) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2275,7 +2299,7 @@ void TextServerAdvanced::_font_set_force_autohinter(const RID &p_font_rid, bool } bool TextServerAdvanced::_font_is_force_autohinter(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -2283,7 +2307,7 @@ bool TextServerAdvanced::_font_is_force_autohinter(const RID &p_font_rid) const } void TextServerAdvanced::_font_set_hinting(const RID &p_font_rid, TextServer::Hinting p_hinting) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2294,7 +2318,7 @@ void TextServerAdvanced::_font_set_hinting(const RID &p_font_rid, TextServer::Hi } TextServer::Hinting TextServerAdvanced::_font_get_hinting(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, HINTING_NONE); MutexLock lock(fd->mutex); @@ -2302,7 +2326,7 @@ TextServer::Hinting TextServerAdvanced::_font_get_hinting(const RID &p_font_rid) } void TextServerAdvanced::_font_set_subpixel_positioning(const RID &p_font_rid, TextServer::SubpixelPositioning p_subpixel) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2310,7 +2334,7 @@ void TextServerAdvanced::_font_set_subpixel_positioning(const RID &p_font_rid, T } TextServer::SubpixelPositioning TextServerAdvanced::_font_get_subpixel_positioning(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, SUBPIXEL_POSITIONING_DISABLED); MutexLock lock(fd->mutex); @@ -2318,7 +2342,7 @@ TextServer::SubpixelPositioning TextServerAdvanced::_font_get_subpixel_positioni } void TextServerAdvanced::_font_set_embolden(const RID &p_font_rid, double p_strength) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2329,7 +2353,7 @@ void TextServerAdvanced::_font_set_embolden(const RID &p_font_rid, double p_stre } double TextServerAdvanced::_font_get_embolden(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); @@ -2338,29 +2362,38 @@ double TextServerAdvanced::_font_get_embolden(const RID &p_font_rid) const { void TextServerAdvanced::_font_set_spacing(const RID &p_font_rid, SpacingType p_spacing, int64_t p_value) { ERR_FAIL_INDEX((int)p_spacing, 4); - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_NULL(fd); + FontAdvancedLinkedVariation *fdv = font_var_owner.get_or_null(p_font_rid); + if (fdv) { + if (fdv->extra_spacing[p_spacing] != p_value) { + fdv->extra_spacing[p_spacing] = p_value; + } + } else { + FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_NULL(fd); - MutexLock lock(fd->mutex); - if (fd->extra_spacing[p_spacing] != p_value) { - _font_clear_cache(fd); - fd->extra_spacing[p_spacing] = p_value; + MutexLock lock(fd->mutex); + if (fd->extra_spacing[p_spacing] != p_value) { + fd->extra_spacing[p_spacing] = p_value; + } } } int64_t TextServerAdvanced::_font_get_spacing(const RID &p_font_rid, SpacingType p_spacing) const { ERR_FAIL_INDEX_V((int)p_spacing, 4, 0); + FontAdvancedLinkedVariation *fdv = font_var_owner.get_or_null(p_font_rid); + if (fdv) { + return fdv->extra_spacing[p_spacing]; + } else { + FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_NULL_V(fd, 0); - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_NULL_V(fd, 0); - - MutexLock lock(fd->mutex); - - return fd->extra_spacing[p_spacing]; + MutexLock lock(fd->mutex); + return fd->extra_spacing[p_spacing]; + } } void TextServerAdvanced::_font_set_transform(const RID &p_font_rid, const Transform2D &p_transform) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2371,7 +2404,7 @@ void TextServerAdvanced::_font_set_transform(const RID &p_font_rid, const Transf } Transform2D TextServerAdvanced::_font_get_transform(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Transform2D()); MutexLock lock(fd->mutex); @@ -2379,7 +2412,7 @@ Transform2D TextServerAdvanced::_font_get_transform(const RID &p_font_rid) const } void TextServerAdvanced::_font_set_variation_coordinates(const RID &p_font_rid, const Dictionary &p_variation_coordinates) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2390,7 +2423,7 @@ void TextServerAdvanced::_font_set_variation_coordinates(const RID &p_font_rid, } Dictionary TextServerAdvanced::_font_get_variation_coordinates(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Dictionary()); MutexLock lock(fd->mutex); @@ -2398,7 +2431,7 @@ Dictionary TextServerAdvanced::_font_get_variation_coordinates(const RID &p_font } void TextServerAdvanced::_font_set_oversampling(const RID &p_font_rid, double p_oversampling) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2409,7 +2442,7 @@ void TextServerAdvanced::_font_set_oversampling(const RID &p_font_rid, double p_ } double TextServerAdvanced::_font_get_oversampling(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); @@ -2417,7 +2450,7 @@ double TextServerAdvanced::_font_get_oversampling(const RID &p_font_rid) const { } TypedArray<Vector2i> TextServerAdvanced::_font_get_size_cache_list(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, TypedArray<Vector2i>()); MutexLock lock(fd->mutex); @@ -2429,7 +2462,7 @@ TypedArray<Vector2i> TextServerAdvanced::_font_get_size_cache_list(const RID &p_ } void TextServerAdvanced::_font_clear_size_cache(const RID &p_font_rid) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2441,7 +2474,7 @@ void TextServerAdvanced::_font_clear_size_cache(const RID &p_font_rid) { } void TextServerAdvanced::_font_remove_size_cache(const RID &p_font_rid, const Vector2i &p_size) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2453,7 +2486,7 @@ void TextServerAdvanced::_font_remove_size_cache(const RID &p_font_rid, const Ve } void TextServerAdvanced::_font_set_ascent(const RID &p_font_rid, int64_t p_size, double p_ascent) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2464,7 +2497,7 @@ void TextServerAdvanced::_font_set_ascent(const RID &p_font_rid, int64_t p_size, } double TextServerAdvanced::_font_get_ascent(const RID &p_font_rid, int64_t p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); @@ -2480,7 +2513,7 @@ double TextServerAdvanced::_font_get_ascent(const RID &p_font_rid, int64_t p_siz } void TextServerAdvanced::_font_set_descent(const RID &p_font_rid, int64_t p_size, double p_descent) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); Vector2i size = _get_size(fd, p_size); @@ -2490,7 +2523,7 @@ void TextServerAdvanced::_font_set_descent(const RID &p_font_rid, int64_t p_size } double TextServerAdvanced::_font_get_descent(const RID &p_font_rid, int64_t p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); @@ -2506,7 +2539,7 @@ double TextServerAdvanced::_font_get_descent(const RID &p_font_rid, int64_t p_si } void TextServerAdvanced::_font_set_underline_position(const RID &p_font_rid, int64_t p_size, double p_underline_position) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2517,7 +2550,7 @@ void TextServerAdvanced::_font_set_underline_position(const RID &p_font_rid, int } double TextServerAdvanced::_font_get_underline_position(const RID &p_font_rid, int64_t p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); @@ -2533,7 +2566,7 @@ double TextServerAdvanced::_font_get_underline_position(const RID &p_font_rid, i } void TextServerAdvanced::_font_set_underline_thickness(const RID &p_font_rid, int64_t p_size, double p_underline_thickness) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2544,7 +2577,7 @@ void TextServerAdvanced::_font_set_underline_thickness(const RID &p_font_rid, in } double TextServerAdvanced::_font_get_underline_thickness(const RID &p_font_rid, int64_t p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); @@ -2560,7 +2593,7 @@ double TextServerAdvanced::_font_get_underline_thickness(const RID &p_font_rid, } void TextServerAdvanced::_font_set_scale(const RID &p_font_rid, int64_t p_size, double p_scale) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2576,7 +2609,7 @@ void TextServerAdvanced::_font_set_scale(const RID &p_font_rid, int64_t p_size, } double TextServerAdvanced::_font_get_scale(const RID &p_font_rid, int64_t p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); @@ -2592,7 +2625,7 @@ double TextServerAdvanced::_font_get_scale(const RID &p_font_rid, int64_t p_size } int64_t TextServerAdvanced::_font_get_texture_count(const RID &p_font_rid, const Vector2i &p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0); MutexLock lock(fd->mutex); @@ -2604,7 +2637,7 @@ int64_t TextServerAdvanced::_font_get_texture_count(const RID &p_font_rid, const } void TextServerAdvanced::_font_clear_textures(const RID &p_font_rid, const Vector2i &p_size) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -2614,7 +2647,7 @@ void TextServerAdvanced::_font_clear_textures(const RID &p_font_rid, const Vecto } void TextServerAdvanced::_font_remove_texture(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2626,7 +2659,7 @@ void TextServerAdvanced::_font_remove_texture(const RID &p_font_rid, const Vecto } void TextServerAdvanced::_font_set_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const Ref<Image> &p_image) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); ERR_FAIL_COND(p_image.is_null()); @@ -2655,7 +2688,7 @@ void TextServerAdvanced::_font_set_texture_image(const RID &p_font_rid, const Ve } Ref<Image> TextServerAdvanced::_font_get_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Ref<Image>()); MutexLock lock(fd->mutex); @@ -2669,7 +2702,7 @@ Ref<Image> TextServerAdvanced::_font_get_texture_image(const RID &p_font_rid, co void TextServerAdvanced::_font_set_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const PackedInt32Array &p_offsets) { ERR_FAIL_COND(p_offsets.size() % 4 != 0); - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2688,7 +2721,7 @@ void TextServerAdvanced::_font_set_texture_offsets(const RID &p_font_rid, const } PackedInt32Array TextServerAdvanced::_font_get_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, PackedInt32Array()); MutexLock lock(fd->mutex); @@ -2713,7 +2746,7 @@ PackedInt32Array TextServerAdvanced::_font_get_texture_offsets(const RID &p_font } PackedInt32Array TextServerAdvanced::_font_get_glyph_list(const RID &p_font_rid, const Vector2i &p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, PackedInt32Array()); MutexLock lock(fd->mutex); @@ -2729,7 +2762,7 @@ PackedInt32Array TextServerAdvanced::_font_get_glyph_list(const RID &p_font_rid, } void TextServerAdvanced::_font_clear_glyphs(const RID &p_font_rid, const Vector2i &p_size) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2740,7 +2773,7 @@ void TextServerAdvanced::_font_clear_glyphs(const RID &p_font_rid, const Vector2 } void TextServerAdvanced::_font_remove_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2751,7 +2784,7 @@ void TextServerAdvanced::_font_remove_glyph(const RID &p_font_rid, const Vector2 } double TextServerAdvanced::_get_extra_advance(RID p_font_rid, int p_font_size) const { - const FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + const FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); @@ -2765,7 +2798,7 @@ double TextServerAdvanced::_get_extra_advance(RID p_font_rid, int p_font_size) c } Vector2 TextServerAdvanced::_font_get_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Vector2()); MutexLock lock(fd->mutex); @@ -2803,7 +2836,7 @@ Vector2 TextServerAdvanced::_font_get_glyph_advance(const RID &p_font_rid, int64 } void TextServerAdvanced::_font_set_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph, const Vector2 &p_advance) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2818,7 +2851,7 @@ void TextServerAdvanced::_font_set_glyph_advance(const RID &p_font_rid, int64_t } Vector2 TextServerAdvanced::_font_get_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Vector2()); MutexLock lock(fd->mutex); @@ -2848,7 +2881,7 @@ Vector2 TextServerAdvanced::_font_get_glyph_offset(const RID &p_font_rid, const } void TextServerAdvanced::_font_set_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_offset) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2863,7 +2896,7 @@ void TextServerAdvanced::_font_set_glyph_offset(const RID &p_font_rid, const Vec } Vector2 TextServerAdvanced::_font_get_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Vector2()); MutexLock lock(fd->mutex); @@ -2893,7 +2926,7 @@ Vector2 TextServerAdvanced::_font_get_glyph_size(const RID &p_font_rid, const Ve } void TextServerAdvanced::_font_set_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_gl_size) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2908,7 +2941,7 @@ void TextServerAdvanced::_font_set_glyph_size(const RID &p_font_rid, const Vecto } Rect2 TextServerAdvanced::_font_get_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Rect2()); MutexLock lock(fd->mutex); @@ -2933,7 +2966,7 @@ Rect2 TextServerAdvanced::_font_get_glyph_uv_rect(const RID &p_font_rid, const V } void TextServerAdvanced::_font_set_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Rect2 &p_uv_rect) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2948,7 +2981,7 @@ void TextServerAdvanced::_font_set_glyph_uv_rect(const RID &p_font_rid, const Ve } int64_t TextServerAdvanced::_font_get_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, -1); MutexLock lock(fd->mutex); @@ -2973,7 +3006,7 @@ int64_t TextServerAdvanced::_font_get_glyph_texture_idx(const RID &p_font_rid, c } void TextServerAdvanced::_font_set_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, int64_t p_texture_idx) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2988,7 +3021,7 @@ void TextServerAdvanced::_font_set_glyph_texture_idx(const RID &p_font_rid, cons } RID TextServerAdvanced::_font_get_glyph_texture_rid(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, RID()); MutexLock lock(fd->mutex); @@ -3034,7 +3067,7 @@ RID TextServerAdvanced::_font_get_glyph_texture_rid(const RID &p_font_rid, const } Size2 TextServerAdvanced::_font_get_glyph_texture_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Size2()); MutexLock lock(fd->mutex); @@ -3080,7 +3113,7 @@ Size2 TextServerAdvanced::_font_get_glyph_texture_size(const RID &p_font_rid, co } Dictionary TextServerAdvanced::_font_get_glyph_contours(const RID &p_font_rid, int64_t p_size, int64_t p_index) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Dictionary()); MutexLock lock(fd->mutex); @@ -3130,7 +3163,7 @@ Dictionary TextServerAdvanced::_font_get_glyph_contours(const RID &p_font_rid, i } TypedArray<Vector2i> TextServerAdvanced::_font_get_kerning_list(const RID &p_font_rid, int64_t p_size) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, TypedArray<Vector2i>()); MutexLock lock(fd->mutex); @@ -3146,7 +3179,7 @@ TypedArray<Vector2i> TextServerAdvanced::_font_get_kerning_list(const RID &p_fon } void TextServerAdvanced::_font_clear_kerning_map(const RID &p_font_rid, int64_t p_size) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -3157,7 +3190,7 @@ void TextServerAdvanced::_font_clear_kerning_map(const RID &p_font_rid, int64_t } void TextServerAdvanced::_font_remove_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -3168,7 +3201,7 @@ void TextServerAdvanced::_font_remove_kerning(const RID &p_font_rid, int64_t p_s } void TextServerAdvanced::_font_set_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -3179,7 +3212,7 @@ void TextServerAdvanced::_font_set_kerning(const RID &p_font_rid, int64_t p_size } Vector2 TextServerAdvanced::_font_get_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Vector2()); MutexLock lock(fd->mutex); @@ -3212,7 +3245,7 @@ Vector2 TextServerAdvanced::_font_get_kerning(const RID &p_font_rid, int64_t p_s } int64_t TextServerAdvanced::_font_get_glyph_index(const RID &p_font_rid, int64_t p_size, int64_t p_char, int64_t p_variation_selector) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0); ERR_FAIL_COND_V_MSG((p_char >= 0xd800 && p_char <= 0xdfff) || (p_char > 0x10ffff), 0, "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_char, 16) + "."); ERR_FAIL_COND_V_MSG((p_variation_selector >= 0xd800 && p_variation_selector <= 0xdfff) || (p_variation_selector > 0x10ffff), 0, "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_variation_selector, 16) + "."); @@ -3237,7 +3270,7 @@ int64_t TextServerAdvanced::_font_get_glyph_index(const RID &p_font_rid, int64_t } int64_t TextServerAdvanced::_font_get_char_from_glyph_index(const RID &p_font_rid, int64_t p_size, int64_t p_glyph_index) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0); MutexLock lock(fd->mutex); @@ -3268,7 +3301,7 @@ int64_t TextServerAdvanced::_font_get_char_from_glyph_index(const RID &p_font_ri } bool TextServerAdvanced::_font_has_char(const RID &p_font_rid, int64_t p_char) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_COND_V_MSG((p_char >= 0xd800 && p_char <= 0xdfff) || (p_char > 0x10ffff), false, "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_char, 16) + "."); if (!fd) { return false; @@ -3289,7 +3322,7 @@ bool TextServerAdvanced::_font_has_char(const RID &p_font_rid, int64_t p_char) c } String TextServerAdvanced::_font_get_supported_chars(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, String()); MutexLock lock(fd->mutex); @@ -3322,7 +3355,7 @@ String TextServerAdvanced::_font_get_supported_chars(const RID &p_font_rid) cons } void TextServerAdvanced::_font_render_range(const RID &p_font_rid, const Vector2i &p_size, int64_t p_start, int64_t p_end) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); ERR_FAIL_COND_MSG((p_start >= 0xd800 && p_start <= 0xdfff) || (p_start > 0x10ffff), "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_start, 16) + "."); ERR_FAIL_COND_MSG((p_end >= 0xd800 && p_end <= 0xdfff) || (p_end > 0x10ffff), "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_end, 16) + "."); @@ -3357,7 +3390,7 @@ void TextServerAdvanced::_font_render_range(const RID &p_font_rid, const Vector2 } void TextServerAdvanced::_font_render_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_index) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -3388,7 +3421,7 @@ void TextServerAdvanced::_font_render_glyph(const RID &p_font_rid, const Vector2 } void TextServerAdvanced::_font_draw_glyph(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -3480,7 +3513,7 @@ void TextServerAdvanced::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca } void TextServerAdvanced::_font_draw_glyph_outline(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, int64_t p_outline_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -3572,7 +3605,7 @@ void TextServerAdvanced::_font_draw_glyph_outline(const RID &p_font_rid, const R } bool TextServerAdvanced::_font_is_language_supported(const RID &p_font_rid, const String &p_language) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -3584,7 +3617,7 @@ bool TextServerAdvanced::_font_is_language_supported(const RID &p_font_rid, cons } void TextServerAdvanced::_font_set_language_support_override(const RID &p_font_rid, const String &p_language, bool p_supported) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -3592,7 +3625,7 @@ void TextServerAdvanced::_font_set_language_support_override(const RID &p_font_r } bool TextServerAdvanced::_font_get_language_support_override(const RID &p_font_rid, const String &p_language) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -3600,7 +3633,7 @@ bool TextServerAdvanced::_font_get_language_support_override(const RID &p_font_r } void TextServerAdvanced::_font_remove_language_support_override(const RID &p_font_rid, const String &p_language) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -3608,7 +3641,7 @@ void TextServerAdvanced::_font_remove_language_support_override(const RID &p_fon } PackedStringArray TextServerAdvanced::_font_get_language_support_overrides(const RID &p_font_rid) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, PackedStringArray()); MutexLock lock(fd->mutex); @@ -3620,7 +3653,7 @@ PackedStringArray TextServerAdvanced::_font_get_language_support_overrides(const } bool TextServerAdvanced::_font_is_script_supported(const RID &p_font_rid, const String &p_script) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -3634,7 +3667,7 @@ bool TextServerAdvanced::_font_is_script_supported(const RID &p_font_rid, const } void TextServerAdvanced::_font_set_script_support_override(const RID &p_font_rid, const String &p_script, bool p_supported) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -3642,7 +3675,7 @@ void TextServerAdvanced::_font_set_script_support_override(const RID &p_font_rid } bool TextServerAdvanced::_font_get_script_support_override(const RID &p_font_rid, const String &p_script) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -3650,7 +3683,7 @@ bool TextServerAdvanced::_font_get_script_support_override(const RID &p_font_rid } void TextServerAdvanced::_font_remove_script_support_override(const RID &p_font_rid, const String &p_script) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -3658,7 +3691,7 @@ void TextServerAdvanced::_font_remove_script_support_override(const RID &p_font_ } PackedStringArray TextServerAdvanced::_font_get_script_support_overrides(const RID &p_font_rid) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, PackedStringArray()); MutexLock lock(fd->mutex); @@ -3670,7 +3703,7 @@ PackedStringArray TextServerAdvanced::_font_get_script_support_overrides(const R } void TextServerAdvanced::_font_set_opentype_feature_overrides(const RID &p_font_rid, const Dictionary &p_overrides) { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -3680,7 +3713,7 @@ void TextServerAdvanced::_font_set_opentype_feature_overrides(const RID &p_font_ } Dictionary TextServerAdvanced::_font_get_opentype_feature_overrides(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Dictionary()); MutexLock lock(fd->mutex); @@ -3688,7 +3721,7 @@ Dictionary TextServerAdvanced::_font_get_opentype_feature_overrides(const RID &p } Dictionary TextServerAdvanced::_font_supported_feature_list(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Dictionary()); MutexLock lock(fd->mutex); @@ -3698,7 +3731,7 @@ Dictionary TextServerAdvanced::_font_supported_feature_list(const RID &p_font_ri } Dictionary TextServerAdvanced::_font_supported_variation_list(const RID &p_font_rid) const { - FontAdvanced *fd = font_owner.get_or_null(p_font_rid); + FontAdvanced *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Dictionary()); MutexLock lock(fd->mutex); @@ -4051,7 +4084,7 @@ bool TextServerAdvanced::_shaped_text_add_string(const RID &p_shaped, const Stri MutexLock lock(sd->mutex); for (int i = 0; i < p_fonts.size(); i++) { - ERR_FAIL_COND_V(!font_owner.get_or_null(p_fonts[i]), false); + ERR_FAIL_COND_V(!_get_font_data(p_fonts[i]), false); } if (p_text.is_empty()) { @@ -5633,7 +5666,7 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int64_t p_star return; } - FontAdvanced *fd = font_owner.get_or_null(f); + FontAdvanced *fd = _get_font_data(f); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); diff --git a/modules/text_server_adv/text_server_adv.h b/modules/text_server_adv/text_server_adv.h index 7445becfae..57cca819be 100644 --- a/modules/text_server_adv/text_server_adv.h +++ b/modules/text_server_adv/text_server_adv.h @@ -293,6 +293,11 @@ class TextServerAdvanced : public TextServerExtension { } }; + struct FontAdvancedLinkedVariation { + RID base_font; + int extra_spacing[4] = { 0, 0, 0, 0 }; + }; + struct FontAdvanced { Mutex mutex; @@ -534,9 +539,19 @@ class TextServerAdvanced : public TextServerExtension { // Common data. double oversampling = 1.0; + mutable RID_PtrOwner<FontAdvancedLinkedVariation> font_var_owner; mutable RID_PtrOwner<FontAdvanced> font_owner; mutable RID_PtrOwner<ShapedTextDataAdvanced> shaped_owner; + _FORCE_INLINE_ FontAdvanced *_get_font_data(const RID &p_font_rid) const { + RID rid = p_font_rid; + FontAdvancedLinkedVariation *fdv = font_var_owner.get_or_null(rid); + if (unlikely(fdv)) { + rid = fdv->base_font; + } + return font_owner.get_or_null(rid); + } + struct SystemFontKey { String font_name; TextServer::FontAntialiasing antialiasing = TextServer::FONT_ANTIALIASING_GRAY; @@ -704,6 +719,7 @@ public: /* Font interface */ MODBIND0R(RID, create_font); + MODBIND1R(RID, create_font_linked_variation, const RID &); MODBIND2(font_set_data, const RID &, const PackedByteArray &); MODBIND3(font_set_data_ptr, const RID &, const uint8_t *, int64_t); diff --git a/modules/text_server_fb/SCsub b/modules/text_server_fb/SCsub index 8705bc430d..e808864512 100644 --- a/modules/text_server_fb/SCsub +++ b/modules/text_server_fb/SCsub @@ -10,7 +10,7 @@ env_text_server_fb = env_modules.Clone() if "svg" in env.module_list: env_text_server_fb.Prepend( - CPPPATH=["#thirdparty/thorvg/inc", "#thirdparty/thorvg/src/lib", "#thirdparty/thorvg/src/utils"] + CPPPATH=["#thirdparty/thorvg/inc", "#thirdparty/thorvg/src/common", "#thirdparty/thorvg/src/renderer"] ) # Enable ThorVG static object linking. env_text_server_fb.Append(CPPDEFINES=["TVG_STATIC"]) diff --git a/modules/text_server_fb/gdextension_build/SConstruct b/modules/text_server_fb/gdextension_build/SConstruct index 40bb2dc1b9..846ac02cf1 100644 --- a/modules/text_server_fb/gdextension_build/SConstruct +++ b/modules/text_server_fb/gdextension_build/SConstruct @@ -37,51 +37,56 @@ if env["thorvg_enabled"] and env["freetype_enabled"]: thirdparty_tvg_dir = "../../../thirdparty/thorvg/" thirdparty_tvg_sources = [ - "src/lib/sw_engine/tvgSwFill.cpp", - "src/lib/sw_engine/tvgSwImage.cpp", - "src/lib/sw_engine/tvgSwMath.cpp", - "src/lib/sw_engine/tvgSwMemPool.cpp", - "src/lib/sw_engine/tvgSwRaster.cpp", - "src/lib/sw_engine/tvgSwRenderer.cpp", - "src/lib/sw_engine/tvgSwRle.cpp", - "src/lib/sw_engine/tvgSwShape.cpp", - "src/lib/sw_engine/tvgSwStroke.cpp", - "src/lib/tvgAccessor.cpp", - "src/lib/tvgCanvas.cpp", - "src/lib/tvgFill.cpp", - "src/lib/tvgGlCanvas.cpp", - "src/lib/tvgInitializer.cpp", - "src/lib/tvgLoader.cpp", - "src/lib/tvgPaint.cpp", - "src/lib/tvgPicture.cpp", - "src/lib/tvgRender.cpp", - "src/lib/tvgSaver.cpp", - "src/lib/tvgScene.cpp", - "src/lib/tvgShape.cpp", - "src/lib/tvgSwCanvas.cpp", - "src/lib/tvgTaskScheduler.cpp", - "src/utils/tvgBezier.cpp", - "src/utils/tvgCompressor.cpp", - "src/utils/tvgStr.cpp", - "src/loaders/raw/tvgRawLoader.cpp", + # common + "src/common/tvgBezier.cpp", + "src/common/tvgCompressor.cpp", + "src/common/tvgMath.cpp", + "src/common/tvgStr.cpp", + # SVG parser "src/loaders/svg/tvgSvgCssStyle.cpp", "src/loaders/svg/tvgSvgLoader.cpp", "src/loaders/svg/tvgSvgPath.cpp", "src/loaders/svg/tvgSvgSceneBuilder.cpp", "src/loaders/svg/tvgSvgUtil.cpp", "src/loaders/svg/tvgXmlParser.cpp", + "src/loaders/raw/tvgRawLoader.cpp", + # renderer common + "src/renderer/tvgAccessor.cpp", + # "src/renderer/tvgAnimation.cpp", + "src/renderer/tvgCanvas.cpp", + "src/renderer/tvgFill.cpp", + # "src/renderer/tvgGlCanvas.cpp", + "src/renderer/tvgInitializer.cpp", + "src/renderer/tvgLoader.cpp", + "src/renderer/tvgPaint.cpp", + "src/renderer/tvgPicture.cpp", + "src/renderer/tvgRender.cpp", + # "src/renderer/tvgSaver.cpp", + "src/renderer/tvgScene.cpp", + "src/renderer/tvgShape.cpp", + "src/renderer/tvgSwCanvas.cpp", + "src/renderer/tvgTaskScheduler.cpp", + # renderer sw_engine + "src/renderer/sw_engine/tvgSwFill.cpp", + "src/renderer/sw_engine/tvgSwImage.cpp", + "src/renderer/sw_engine/tvgSwMath.cpp", + "src/renderer/sw_engine/tvgSwMemPool.cpp", + "src/renderer/sw_engine/tvgSwRaster.cpp", + "src/renderer/sw_engine/tvgSwRenderer.cpp", + "src/renderer/sw_engine/tvgSwRle.cpp", + "src/renderer/sw_engine/tvgSwShape.cpp", + "src/renderer/sw_engine/tvgSwStroke.cpp", ] thirdparty_tvg_sources = [thirdparty_tvg_dir + file for file in thirdparty_tvg_sources] env_tvg.Append( CPPPATH=[ "../../../thirdparty/thorvg/inc", - "../../../thirdparty/thorvg/src/lib", - "../../../thirdparty/thorvg/src/lib/sw_engine", - "../../../thirdparty/thorvg/src/loaders/raw", + "../../../thirdparty/thorvg/src/common", "../../../thirdparty/thorvg/src/loaders/svg", - "../../../thirdparty/thorvg/src/utils", - "../../../thirdparty/libpng", + "../../../thirdparty/thorvg/src/loaders/raw", + "../../../thirdparty/thorvg/src/renderer", + "../../../thirdparty/thorvg/src/renderer/sw_engine", ] ) @@ -91,8 +96,8 @@ if env["thorvg_enabled"] and env["freetype_enabled"]: env.Append( CPPPATH=[ "../../../thirdparty/thorvg/inc", - "../../../thirdparty/thorvg/src/lib", - "../../../thirdparty/thorvg/src/utils", + "../../../thirdparty/thorvg/src/common", + "../../../thirdparty/thorvg/src/renderer", ] ) env.Append(CPPDEFINES=["MODULE_SVG_ENABLED"]) diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp index c3b64929a9..0cfbf7f530 100644 --- a/modules/text_server_fb/text_server_fb.cpp +++ b/modules/text_server_fb/text_server_fb.cpp @@ -123,6 +123,14 @@ void TextServerFallback::_free_rid(const RID &p_rid) { font_owner.free(p_rid); } memdelete(fd); + } else if (font_var_owner.owns(p_rid)) { + MutexLock ftlock(ft_mutex); + + FontFallbackLinkedVariation *fdv = font_var_owner.get_or_null(p_rid); + { + font_var_owner.free(p_rid); + } + memdelete(fdv); } else if (shaped_owner.owns(p_rid)) { ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_rid); { @@ -935,8 +943,24 @@ RID TextServerFallback::_create_font() { return font_owner.make_rid(fd); } +RID TextServerFallback::_create_font_linked_variation(const RID &p_font_rid) { + _THREAD_SAFE_METHOD_ + + RID rid = p_font_rid; + FontFallbackLinkedVariation *fdv = font_var_owner.get_or_null(rid); + if (unlikely(fdv)) { + rid = fdv->base_font; + } + ERR_FAIL_COND_V(!font_owner.owns(rid), RID()); + + FontFallbackLinkedVariation *new_fdv = memnew(FontFallbackLinkedVariation); + new_fdv->base_font = rid; + + return font_var_owner.make_rid(new_fdv); +} + void TextServerFallback::_font_set_data(const RID &p_font_rid, const PackedByteArray &p_data) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -947,7 +971,7 @@ void TextServerFallback::_font_set_data(const RID &p_font_rid, const PackedByteA } void TextServerFallback::_font_set_data_ptr(const RID &p_font_rid, const uint8_t *p_data_ptr, int64_t p_data_size) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -958,7 +982,7 @@ void TextServerFallback::_font_set_data_ptr(const RID &p_font_rid, const uint8_t } void TextServerFallback::_font_set_style(const RID &p_font_rid, BitField<FontStyle> p_style) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -971,7 +995,7 @@ void TextServerFallback::_font_set_face_index(const RID &p_font_rid, int64_t p_f ERR_FAIL_COND(p_face_index < 0); ERR_FAIL_COND(p_face_index >= 0x7FFF); - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -982,7 +1006,7 @@ void TextServerFallback::_font_set_face_index(const RID &p_font_rid, int64_t p_f } int64_t TextServerFallback::_font_get_face_index(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0); MutexLock lock(fd->mutex); @@ -990,7 +1014,7 @@ int64_t TextServerFallback::_font_get_face_index(const RID &p_font_rid) const { } int64_t TextServerFallback::_font_get_face_count(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0); MutexLock lock(fd->mutex); @@ -1036,7 +1060,7 @@ int64_t TextServerFallback::_font_get_face_count(const RID &p_font_rid) const { } BitField<TextServer::FontStyle> TextServerFallback::_font_get_style(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0); MutexLock lock(fd->mutex); @@ -1046,7 +1070,7 @@ BitField<TextServer::FontStyle> TextServerFallback::_font_get_style(const RID &p } void TextServerFallback::_font_set_style_name(const RID &p_font_rid, const String &p_name) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1056,7 +1080,7 @@ void TextServerFallback::_font_set_style_name(const RID &p_font_rid, const Strin } String TextServerFallback::_font_get_style_name(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, String()); MutexLock lock(fd->mutex); @@ -1066,7 +1090,7 @@ String TextServerFallback::_font_get_style_name(const RID &p_font_rid) const { } void TextServerFallback::_font_set_weight(const RID &p_font_rid, int64_t p_weight) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1076,7 +1100,7 @@ void TextServerFallback::_font_set_weight(const RID &p_font_rid, int64_t p_weigh } int64_t TextServerFallback::_font_get_weight(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 400); MutexLock lock(fd->mutex); @@ -1086,7 +1110,7 @@ int64_t TextServerFallback::_font_get_weight(const RID &p_font_rid) const { } void TextServerFallback::_font_set_stretch(const RID &p_font_rid, int64_t p_stretch) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1096,7 +1120,7 @@ void TextServerFallback::_font_set_stretch(const RID &p_font_rid, int64_t p_stre } int64_t TextServerFallback::_font_get_stretch(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 100); MutexLock lock(fd->mutex); @@ -1106,7 +1130,7 @@ int64_t TextServerFallback::_font_get_stretch(const RID &p_font_rid) const { } void TextServerFallback::_font_set_name(const RID &p_font_rid, const String &p_name) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1116,7 +1140,7 @@ void TextServerFallback::_font_set_name(const RID &p_font_rid, const String &p_n } String TextServerFallback::_font_get_name(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, String()); MutexLock lock(fd->mutex); @@ -1126,7 +1150,7 @@ String TextServerFallback::_font_get_name(const RID &p_font_rid) const { } void TextServerFallback::_font_set_antialiasing(const RID &p_font_rid, TextServer::FontAntialiasing p_antialiasing) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1137,7 +1161,7 @@ void TextServerFallback::_font_set_antialiasing(const RID &p_font_rid, TextServe } TextServer::FontAntialiasing TextServerFallback::_font_get_antialiasing(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, TextServer::FONT_ANTIALIASING_NONE); MutexLock lock(fd->mutex); @@ -1145,7 +1169,7 @@ TextServer::FontAntialiasing TextServerFallback::_font_get_antialiasing(const RI } void TextServerFallback::_font_set_generate_mipmaps(const RID &p_font_rid, bool p_generate_mipmaps) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1161,7 +1185,7 @@ void TextServerFallback::_font_set_generate_mipmaps(const RID &p_font_rid, bool } bool TextServerFallback::_font_get_generate_mipmaps(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -1169,7 +1193,7 @@ bool TextServerFallback::_font_get_generate_mipmaps(const RID &p_font_rid) const } void TextServerFallback::_font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1180,7 +1204,7 @@ void TextServerFallback::_font_set_multichannel_signed_distance_field(const RID } bool TextServerFallback::_font_is_multichannel_signed_distance_field(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -1188,7 +1212,7 @@ bool TextServerFallback::_font_is_multichannel_signed_distance_field(const RID & } void TextServerFallback::_font_set_msdf_pixel_range(const RID &p_font_rid, int64_t p_msdf_pixel_range) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1199,7 +1223,7 @@ void TextServerFallback::_font_set_msdf_pixel_range(const RID &p_font_rid, int64 } int64_t TextServerFallback::_font_get_msdf_pixel_range(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -1207,7 +1231,7 @@ int64_t TextServerFallback::_font_get_msdf_pixel_range(const RID &p_font_rid) co } void TextServerFallback::_font_set_msdf_size(const RID &p_font_rid, int64_t p_msdf_size) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1218,7 +1242,7 @@ void TextServerFallback::_font_set_msdf_size(const RID &p_font_rid, int64_t p_ms } int64_t TextServerFallback::_font_get_msdf_size(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -1226,7 +1250,7 @@ int64_t TextServerFallback::_font_get_msdf_size(const RID &p_font_rid) const { } void TextServerFallback::_font_set_fixed_size(const RID &p_font_rid, int64_t p_fixed_size) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1234,7 +1258,7 @@ void TextServerFallback::_font_set_fixed_size(const RID &p_font_rid, int64_t p_f } int64_t TextServerFallback::_font_get_fixed_size(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -1242,7 +1266,7 @@ int64_t TextServerFallback::_font_get_fixed_size(const RID &p_font_rid) const { } void TextServerFallback::_font_set_allow_system_fallback(const RID &p_font_rid, bool p_allow_system_fallback) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1250,7 +1274,7 @@ void TextServerFallback::_font_set_allow_system_fallback(const RID &p_font_rid, } bool TextServerFallback::_font_is_allow_system_fallback(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -1258,7 +1282,7 @@ bool TextServerFallback::_font_is_allow_system_fallback(const RID &p_font_rid) c } void TextServerFallback::_font_set_force_autohinter(const RID &p_font_rid, bool p_force_autohinter) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1269,7 +1293,7 @@ void TextServerFallback::_font_set_force_autohinter(const RID &p_font_rid, bool } bool TextServerFallback::_font_is_force_autohinter(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -1277,7 +1301,7 @@ bool TextServerFallback::_font_is_force_autohinter(const RID &p_font_rid) const } void TextServerFallback::_font_set_hinting(const RID &p_font_rid, TextServer::Hinting p_hinting) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1288,7 +1312,7 @@ void TextServerFallback::_font_set_hinting(const RID &p_font_rid, TextServer::Hi } TextServer::Hinting TextServerFallback::_font_get_hinting(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, HINTING_NONE); MutexLock lock(fd->mutex); @@ -1296,7 +1320,7 @@ TextServer::Hinting TextServerFallback::_font_get_hinting(const RID &p_font_rid) } void TextServerFallback::_font_set_subpixel_positioning(const RID &p_font_rid, TextServer::SubpixelPositioning p_subpixel) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1304,7 +1328,7 @@ void TextServerFallback::_font_set_subpixel_positioning(const RID &p_font_rid, T } TextServer::SubpixelPositioning TextServerFallback::_font_get_subpixel_positioning(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, SUBPIXEL_POSITIONING_DISABLED); MutexLock lock(fd->mutex); @@ -1312,7 +1336,7 @@ TextServer::SubpixelPositioning TextServerFallback::_font_get_subpixel_positioni } void TextServerFallback::_font_set_embolden(const RID &p_font_rid, double p_strength) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1323,7 +1347,7 @@ void TextServerFallback::_font_set_embolden(const RID &p_font_rid, double p_stre } double TextServerFallback::_font_get_embolden(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); @@ -1332,28 +1356,39 @@ double TextServerFallback::_font_get_embolden(const RID &p_font_rid) const { void TextServerFallback::_font_set_spacing(const RID &p_font_rid, SpacingType p_spacing, int64_t p_value) { ERR_FAIL_INDEX((int)p_spacing, 4); - FontFallback *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_NULL(fd); + FontFallbackLinkedVariation *fdv = font_var_owner.get_or_null(p_font_rid); + if (fdv) { + if (fdv->extra_spacing[p_spacing] != p_value) { + fdv->extra_spacing[p_spacing] = p_value; + } + } else { + FontFallback *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_NULL(fd); - MutexLock lock(fd->mutex); - if (fd->extra_spacing[p_spacing] != p_value) { - _font_clear_cache(fd); - fd->extra_spacing[p_spacing] = p_value; + MutexLock lock(fd->mutex); + if (fd->extra_spacing[p_spacing] != p_value) { + _font_clear_cache(fd); + fd->extra_spacing[p_spacing] = p_value; + } } } int64_t TextServerFallback::_font_get_spacing(const RID &p_font_rid, SpacingType p_spacing) const { ERR_FAIL_INDEX_V((int)p_spacing, 4, 0); + FontFallbackLinkedVariation *fdv = font_var_owner.get_or_null(p_font_rid); + if (fdv) { + return fdv->extra_spacing[p_spacing]; + } else { + FontFallback *fd = font_owner.get_or_null(p_font_rid); + ERR_FAIL_NULL_V(fd, 0); - FontFallback *fd = font_owner.get_or_null(p_font_rid); - ERR_FAIL_NULL_V(fd, 0); - - MutexLock lock(fd->mutex); - return fd->extra_spacing[p_spacing]; + MutexLock lock(fd->mutex); + return fd->extra_spacing[p_spacing]; + } } void TextServerFallback::_font_set_transform(const RID &p_font_rid, const Transform2D &p_transform) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1364,7 +1399,7 @@ void TextServerFallback::_font_set_transform(const RID &p_font_rid, const Transf } Transform2D TextServerFallback::_font_get_transform(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Transform2D()); MutexLock lock(fd->mutex); @@ -1372,7 +1407,7 @@ Transform2D TextServerFallback::_font_get_transform(const RID &p_font_rid) const } void TextServerFallback::_font_set_variation_coordinates(const RID &p_font_rid, const Dictionary &p_variation_coordinates) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1383,7 +1418,7 @@ void TextServerFallback::_font_set_variation_coordinates(const RID &p_font_rid, } Dictionary TextServerFallback::_font_get_variation_coordinates(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Dictionary()); MutexLock lock(fd->mutex); @@ -1391,7 +1426,7 @@ Dictionary TextServerFallback::_font_get_variation_coordinates(const RID &p_font } void TextServerFallback::_font_set_oversampling(const RID &p_font_rid, double p_oversampling) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1402,7 +1437,7 @@ void TextServerFallback::_font_set_oversampling(const RID &p_font_rid, double p_ } double TextServerFallback::_font_get_oversampling(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); @@ -1410,7 +1445,7 @@ double TextServerFallback::_font_get_oversampling(const RID &p_font_rid) const { } TypedArray<Vector2i> TextServerFallback::_font_get_size_cache_list(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, TypedArray<Vector2i>()); MutexLock lock(fd->mutex); @@ -1422,7 +1457,7 @@ TypedArray<Vector2i> TextServerFallback::_font_get_size_cache_list(const RID &p_ } void TextServerFallback::_font_clear_size_cache(const RID &p_font_rid) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1434,7 +1469,7 @@ void TextServerFallback::_font_clear_size_cache(const RID &p_font_rid) { } void TextServerFallback::_font_remove_size_cache(const RID &p_font_rid, const Vector2i &p_size) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1446,7 +1481,7 @@ void TextServerFallback::_font_remove_size_cache(const RID &p_font_rid, const Ve } void TextServerFallback::_font_set_ascent(const RID &p_font_rid, int64_t p_size, double p_ascent) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1457,7 +1492,7 @@ void TextServerFallback::_font_set_ascent(const RID &p_font_rid, int64_t p_size, } double TextServerFallback::_font_get_ascent(const RID &p_font_rid, int64_t p_size) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); @@ -1473,7 +1508,7 @@ double TextServerFallback::_font_get_ascent(const RID &p_font_rid, int64_t p_siz } void TextServerFallback::_font_set_descent(const RID &p_font_rid, int64_t p_size, double p_descent) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); Vector2i size = _get_size(fd, p_size); @@ -1483,7 +1518,7 @@ void TextServerFallback::_font_set_descent(const RID &p_font_rid, int64_t p_size } double TextServerFallback::_font_get_descent(const RID &p_font_rid, int64_t p_size) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); @@ -1499,7 +1534,7 @@ double TextServerFallback::_font_get_descent(const RID &p_font_rid, int64_t p_si } void TextServerFallback::_font_set_underline_position(const RID &p_font_rid, int64_t p_size, double p_underline_position) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1510,7 +1545,7 @@ void TextServerFallback::_font_set_underline_position(const RID &p_font_rid, int } double TextServerFallback::_font_get_underline_position(const RID &p_font_rid, int64_t p_size) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); @@ -1526,7 +1561,7 @@ double TextServerFallback::_font_get_underline_position(const RID &p_font_rid, i } void TextServerFallback::_font_set_underline_thickness(const RID &p_font_rid, int64_t p_size, double p_underline_thickness) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1537,7 +1572,7 @@ void TextServerFallback::_font_set_underline_thickness(const RID &p_font_rid, in } double TextServerFallback::_font_get_underline_thickness(const RID &p_font_rid, int64_t p_size) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); @@ -1553,7 +1588,7 @@ double TextServerFallback::_font_get_underline_thickness(const RID &p_font_rid, } void TextServerFallback::_font_set_scale(const RID &p_font_rid, int64_t p_size, double p_scale) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1569,7 +1604,7 @@ void TextServerFallback::_font_set_scale(const RID &p_font_rid, int64_t p_size, } double TextServerFallback::_font_get_scale(const RID &p_font_rid, int64_t p_size) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0.0); MutexLock lock(fd->mutex); @@ -1585,7 +1620,7 @@ double TextServerFallback::_font_get_scale(const RID &p_font_rid, int64_t p_size } int64_t TextServerFallback::_font_get_texture_count(const RID &p_font_rid, const Vector2i &p_size) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, 0); MutexLock lock(fd->mutex); @@ -1597,7 +1632,7 @@ int64_t TextServerFallback::_font_get_texture_count(const RID &p_font_rid, const } void TextServerFallback::_font_clear_textures(const RID &p_font_rid, const Vector2i &p_size) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); Vector2i size = _get_size_outline(fd, p_size); @@ -1607,7 +1642,7 @@ void TextServerFallback::_font_clear_textures(const RID &p_font_rid, const Vecto } void TextServerFallback::_font_remove_texture(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1619,7 +1654,7 @@ void TextServerFallback::_font_remove_texture(const RID &p_font_rid, const Vecto } void TextServerFallback::_font_set_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const Ref<Image> &p_image) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); ERR_FAIL_COND(p_image.is_null()); @@ -1648,7 +1683,7 @@ void TextServerFallback::_font_set_texture_image(const RID &p_font_rid, const Ve } Ref<Image> TextServerFallback::_font_get_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Ref<Image>()); MutexLock lock(fd->mutex); @@ -1662,7 +1697,7 @@ Ref<Image> TextServerFallback::_font_get_texture_image(const RID &p_font_rid, co void TextServerFallback::_font_set_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const PackedInt32Array &p_offsets) { ERR_FAIL_COND(p_offsets.size() % 4 != 0); - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1681,7 +1716,7 @@ void TextServerFallback::_font_set_texture_offsets(const RID &p_font_rid, const } PackedInt32Array TextServerFallback::_font_get_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, PackedInt32Array()); MutexLock lock(fd->mutex); @@ -1706,7 +1741,7 @@ PackedInt32Array TextServerFallback::_font_get_texture_offsets(const RID &p_font } PackedInt32Array TextServerFallback::_font_get_glyph_list(const RID &p_font_rid, const Vector2i &p_size) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, PackedInt32Array()); MutexLock lock(fd->mutex); @@ -1722,7 +1757,7 @@ PackedInt32Array TextServerFallback::_font_get_glyph_list(const RID &p_font_rid, } void TextServerFallback::_font_clear_glyphs(const RID &p_font_rid, const Vector2i &p_size) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1733,7 +1768,7 @@ void TextServerFallback::_font_clear_glyphs(const RID &p_font_rid, const Vector2 } void TextServerFallback::_font_remove_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1744,7 +1779,7 @@ void TextServerFallback::_font_remove_glyph(const RID &p_font_rid, const Vector2 } Vector2 TextServerFallback::_font_get_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Vector2()); MutexLock lock(fd->mutex); @@ -1782,7 +1817,7 @@ Vector2 TextServerFallback::_font_get_glyph_advance(const RID &p_font_rid, int64 } void TextServerFallback::_font_set_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph, const Vector2 &p_advance) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1797,7 +1832,7 @@ void TextServerFallback::_font_set_glyph_advance(const RID &p_font_rid, int64_t } Vector2 TextServerFallback::_font_get_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Vector2()); MutexLock lock(fd->mutex); @@ -1827,7 +1862,7 @@ Vector2 TextServerFallback::_font_get_glyph_offset(const RID &p_font_rid, const } void TextServerFallback::_font_set_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_offset) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1842,7 +1877,7 @@ void TextServerFallback::_font_set_glyph_offset(const RID &p_font_rid, const Vec } Vector2 TextServerFallback::_font_get_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Vector2()); MutexLock lock(fd->mutex); @@ -1872,7 +1907,7 @@ Vector2 TextServerFallback::_font_get_glyph_size(const RID &p_font_rid, const Ve } void TextServerFallback::_font_set_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_gl_size) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1887,7 +1922,7 @@ void TextServerFallback::_font_set_glyph_size(const RID &p_font_rid, const Vecto } Rect2 TextServerFallback::_font_get_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Rect2()); MutexLock lock(fd->mutex); @@ -1912,7 +1947,7 @@ Rect2 TextServerFallback::_font_get_glyph_uv_rect(const RID &p_font_rid, const V } void TextServerFallback::_font_set_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Rect2 &p_uv_rect) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1927,7 +1962,7 @@ void TextServerFallback::_font_set_glyph_uv_rect(const RID &p_font_rid, const Ve } int64_t TextServerFallback::_font_get_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, -1); MutexLock lock(fd->mutex); @@ -1952,7 +1987,7 @@ int64_t TextServerFallback::_font_get_glyph_texture_idx(const RID &p_font_rid, c } void TextServerFallback::_font_set_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, int64_t p_texture_idx) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -1967,7 +2002,7 @@ void TextServerFallback::_font_set_glyph_texture_idx(const RID &p_font_rid, cons } RID TextServerFallback::_font_get_glyph_texture_rid(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, RID()); MutexLock lock(fd->mutex); @@ -2013,7 +2048,7 @@ RID TextServerFallback::_font_get_glyph_texture_rid(const RID &p_font_rid, const } Size2 TextServerFallback::_font_get_glyph_texture_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Size2()); MutexLock lock(fd->mutex); @@ -2059,7 +2094,7 @@ Size2 TextServerFallback::_font_get_glyph_texture_size(const RID &p_font_rid, co } Dictionary TextServerFallback::_font_get_glyph_contours(const RID &p_font_rid, int64_t p_size, int64_t p_index) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Dictionary()); MutexLock lock(fd->mutex); @@ -2109,7 +2144,7 @@ Dictionary TextServerFallback::_font_get_glyph_contours(const RID &p_font_rid, i } TypedArray<Vector2i> TextServerFallback::_font_get_kerning_list(const RID &p_font_rid, int64_t p_size) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, TypedArray<Vector2i>()); MutexLock lock(fd->mutex); @@ -2125,7 +2160,7 @@ TypedArray<Vector2i> TextServerFallback::_font_get_kerning_list(const RID &p_fon } void TextServerFallback::_font_clear_kerning_map(const RID &p_font_rid, int64_t p_size) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2136,7 +2171,7 @@ void TextServerFallback::_font_clear_kerning_map(const RID &p_font_rid, int64_t } void TextServerFallback::_font_remove_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2147,7 +2182,7 @@ void TextServerFallback::_font_remove_kerning(const RID &p_font_rid, int64_t p_s } void TextServerFallback::_font_set_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2158,7 +2193,7 @@ void TextServerFallback::_font_set_kerning(const RID &p_font_rid, int64_t p_size } Vector2 TextServerFallback::_font_get_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Vector2()); MutexLock lock(fd->mutex); @@ -2202,7 +2237,7 @@ int64_t TextServerFallback::_font_get_char_from_glyph_index(const RID &p_font_ri } bool TextServerFallback::_font_has_char(const RID &p_font_rid, int64_t p_char) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_COND_V_MSG((p_char >= 0xd800 && p_char <= 0xdfff) || (p_char > 0x10ffff), false, "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_char, 16) + "."); if (!fd) { return false; @@ -2223,7 +2258,7 @@ bool TextServerFallback::_font_has_char(const RID &p_font_rid, int64_t p_char) c } String TextServerFallback::_font_get_supported_chars(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, String()); MutexLock lock(fd->mutex); @@ -2256,7 +2291,7 @@ String TextServerFallback::_font_get_supported_chars(const RID &p_font_rid) cons } void TextServerFallback::_font_render_range(const RID &p_font_rid, const Vector2i &p_size, int64_t p_start, int64_t p_end) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); ERR_FAIL_COND_MSG((p_start >= 0xd800 && p_start <= 0xdfff) || (p_start > 0x10ffff), "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_start, 16) + "."); ERR_FAIL_COND_MSG((p_end >= 0xd800 && p_end <= 0xdfff) || (p_end > 0x10ffff), "Unicode parsing error: Invalid unicode codepoint " + String::num_int64(p_end, 16) + "."); @@ -2291,7 +2326,7 @@ void TextServerFallback::_font_render_range(const RID &p_font_rid, const Vector2 } void TextServerFallback::_font_render_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_index) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2322,7 +2357,7 @@ void TextServerFallback::_font_render_glyph(const RID &p_font_rid, const Vector2 } void TextServerFallback::_font_draw_glyph(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2414,7 +2449,7 @@ void TextServerFallback::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca } void TextServerFallback::_font_draw_glyph_outline(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, int64_t p_outline_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2506,7 +2541,7 @@ void TextServerFallback::_font_draw_glyph_outline(const RID &p_font_rid, const R } bool TextServerFallback::_font_is_language_supported(const RID &p_font_rid, const String &p_language) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -2518,7 +2553,7 @@ bool TextServerFallback::_font_is_language_supported(const RID &p_font_rid, cons } void TextServerFallback::_font_set_language_support_override(const RID &p_font_rid, const String &p_language, bool p_supported) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2526,7 +2561,7 @@ void TextServerFallback::_font_set_language_support_override(const RID &p_font_r } bool TextServerFallback::_font_get_language_support_override(const RID &p_font_rid, const String &p_language) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -2534,7 +2569,7 @@ bool TextServerFallback::_font_get_language_support_override(const RID &p_font_r } void TextServerFallback::_font_remove_language_support_override(const RID &p_font_rid, const String &p_language) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2542,7 +2577,7 @@ void TextServerFallback::_font_remove_language_support_override(const RID &p_fon } PackedStringArray TextServerFallback::_font_get_language_support_overrides(const RID &p_font_rid) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, PackedStringArray()); MutexLock lock(fd->mutex); @@ -2554,7 +2589,7 @@ PackedStringArray TextServerFallback::_font_get_language_support_overrides(const } bool TextServerFallback::_font_is_script_supported(const RID &p_font_rid, const String &p_script) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -2566,7 +2601,7 @@ bool TextServerFallback::_font_is_script_supported(const RID &p_font_rid, const } void TextServerFallback::_font_set_script_support_override(const RID &p_font_rid, const String &p_script, bool p_supported) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2574,7 +2609,7 @@ void TextServerFallback::_font_set_script_support_override(const RID &p_font_rid } bool TextServerFallback::_font_get_script_support_override(const RID &p_font_rid, const String &p_script) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, false); MutexLock lock(fd->mutex); @@ -2582,7 +2617,7 @@ bool TextServerFallback::_font_get_script_support_override(const RID &p_font_rid } void TextServerFallback::_font_remove_script_support_override(const RID &p_font_rid, const String &p_script) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2592,7 +2627,7 @@ void TextServerFallback::_font_remove_script_support_override(const RID &p_font_ } PackedStringArray TextServerFallback::_font_get_script_support_overrides(const RID &p_font_rid) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, PackedStringArray()); MutexLock lock(fd->mutex); @@ -2604,7 +2639,7 @@ PackedStringArray TextServerFallback::_font_get_script_support_overrides(const R } void TextServerFallback::_font_set_opentype_feature_overrides(const RID &p_font_rid, const Dictionary &p_overrides) { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL(fd); MutexLock lock(fd->mutex); @@ -2614,7 +2649,7 @@ void TextServerFallback::_font_set_opentype_feature_overrides(const RID &p_font_ } Dictionary TextServerFallback::_font_get_opentype_feature_overrides(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Dictionary()); MutexLock lock(fd->mutex); @@ -2626,7 +2661,7 @@ Dictionary TextServerFallback::_font_supported_feature_list(const RID &p_font_ri } Dictionary TextServerFallback::_font_supported_variation_list(const RID &p_font_rid) const { - FontFallback *fd = font_owner.get_or_null(p_font_rid); + FontFallback *fd = _get_font_data(p_font_rid); ERR_FAIL_NULL_V(fd, Dictionary()); MutexLock lock(fd->mutex); @@ -2904,7 +2939,7 @@ bool TextServerFallback::_shaped_text_add_string(const RID &p_shaped, const Stri ERR_FAIL_COND_V(p_size <= 0, false); for (int i = 0; i < p_fonts.size(); i++) { - ERR_FAIL_COND_V(!font_owner.get_or_null(p_fonts[i]), false); + ERR_FAIL_COND_V(!_get_font_data(p_fonts[i]), false); } if (p_text.is_empty()) { diff --git a/modules/text_server_fb/text_server_fb.h b/modules/text_server_fb/text_server_fb.h index c44b45fc27..3b0b10ec35 100644 --- a/modules/text_server_fb/text_server_fb.h +++ b/modules/text_server_fb/text_server_fb.h @@ -245,6 +245,11 @@ class TextServerFallback : public TextServerExtension { } }; + struct FontFallbackLinkedVariation { + RID base_font; + int extra_spacing[4] = { 0, 0, 0, 0 }; + }; + struct FontFallback { Mutex mutex; @@ -451,9 +456,19 @@ class TextServerFallback : public TextServerExtension { // Common data. double oversampling = 1.0; + mutable RID_PtrOwner<FontFallbackLinkedVariation> font_var_owner; mutable RID_PtrOwner<FontFallback> font_owner; mutable RID_PtrOwner<ShapedTextDataFallback> shaped_owner; + _FORCE_INLINE_ FontFallback *_get_font_data(const RID &p_font_rid) const { + RID rid = p_font_rid; + FontFallbackLinkedVariation *fdv = font_var_owner.get_or_null(rid); + if (unlikely(fdv)) { + rid = fdv->base_font; + } + return font_owner.get_or_null(rid); + } + struct SystemFontKey { String font_name; TextServer::FontAntialiasing antialiasing = TextServer::FONT_ANTIALIASING_GRAY; @@ -569,6 +584,7 @@ public: /* Font interface */ MODBIND0R(RID, create_font); + MODBIND1R(RID, create_font_linked_variation, const RID &); MODBIND2(font_set_data, const RID &, const PackedByteArray &); MODBIND3(font_set_data_ptr, const RID &, const uint8_t *, int64_t); |