From e928b2a5e52c83105b05997ebdf684dcbd2c79c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pa=CC=84vels=20Nadtoc=CC=8Cajevs?= <7645683+bruvzg@users.noreply.github.com> Date: Tue, 3 Jun 2025 13:18:55 +0300 Subject: [PATCH] [SVG in OT] Fix rendering of some glyphs using "defs" with "#glyphXXXXX.X" id. --- modules/text_server_adv/thorvg_svg_in_ot.cpp | 8 +++++++- modules/text_server_fb/thorvg_svg_in_ot.cpp | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/text_server_adv/thorvg_svg_in_ot.cpp b/modules/text_server_adv/thorvg_svg_in_ot.cpp index 47bed0aaafe..f9f6c8b8256 100644 --- a/modules/text_server_adv/thorvg_svg_in_ot.cpp +++ b/modules/text_server_adv/thorvg_svg_in_ot.cpp @@ -170,8 +170,14 @@ FT_Error tvg_svg_in_ot_preset_slot(FT_GlyphSlot p_slot, FT_Bool p_cache, FT_Poin String *p_xml = &xml_body_temp; int64_t tag_count = -1; + bool is_in_defs = false; while (parser->read() == OK) { - if (parser->has_attribute("id")) { + if (parser->get_node_type() == XMLParser::NODE_ELEMENT && parser->get_node_name().to_lower() == "defs") { + is_in_defs = true; + } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name().to_lower() == "defs") { + is_in_defs = false; + } + if (!is_in_defs && parser->has_attribute("id")) { const String &gl_name = parser->get_named_attribute_value("id"); if (gl_name.begins_with("glyph")) { #ifdef GDEXTENSION diff --git a/modules/text_server_fb/thorvg_svg_in_ot.cpp b/modules/text_server_fb/thorvg_svg_in_ot.cpp index 47bed0aaafe..f9f6c8b8256 100644 --- a/modules/text_server_fb/thorvg_svg_in_ot.cpp +++ b/modules/text_server_fb/thorvg_svg_in_ot.cpp @@ -170,8 +170,14 @@ FT_Error tvg_svg_in_ot_preset_slot(FT_GlyphSlot p_slot, FT_Bool p_cache, FT_Poin String *p_xml = &xml_body_temp; int64_t tag_count = -1; + bool is_in_defs = false; while (parser->read() == OK) { - if (parser->has_attribute("id")) { + if (parser->get_node_type() == XMLParser::NODE_ELEMENT && parser->get_node_name().to_lower() == "defs") { + is_in_defs = true; + } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name().to_lower() == "defs") { + is_in_defs = false; + } + if (!is_in_defs && parser->has_attribute("id")) { const String &gl_name = parser->get_named_attribute_value("id"); if (gl_name.begins_with("glyph")) { #ifdef GDEXTENSION