Skip to content

Commit 153a06a

Browse files
committed
Merge pull request godotengine#107079 from bruvzg/svg_comp_glyph_fix
[SVG in OT] Fix rendering of some glyphs using "defs" with "#glyphXXXXX.X" id.
2 parents 757cf4c + e928b2a commit 153a06a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

modules/text_server_adv/thorvg_svg_in_ot.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,14 @@ FT_Error tvg_svg_in_ot_preset_slot(FT_GlyphSlot p_slot, FT_Bool p_cache, FT_Poin
170170
String *p_xml = &xml_body_temp;
171171
int64_t tag_count = -1;
172172

173+
bool is_in_defs = false;
173174
while (parser->read() == OK) {
174-
if (parser->has_attribute("id")) {
175+
if (parser->get_node_type() == XMLParser::NODE_ELEMENT && parser->get_node_name().to_lower() == "defs") {
176+
is_in_defs = true;
177+
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name().to_lower() == "defs") {
178+
is_in_defs = false;
179+
}
180+
if (!is_in_defs && parser->has_attribute("id")) {
175181
const String &gl_name = parser->get_named_attribute_value("id");
176182
if (gl_name.begins_with("glyph")) {
177183
#ifdef GDEXTENSION

modules/text_server_fb/thorvg_svg_in_ot.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,14 @@ FT_Error tvg_svg_in_ot_preset_slot(FT_GlyphSlot p_slot, FT_Bool p_cache, FT_Poin
170170
String *p_xml = &xml_body_temp;
171171
int64_t tag_count = -1;
172172

173+
bool is_in_defs = false;
173174
while (parser->read() == OK) {
174-
if (parser->has_attribute("id")) {
175+
if (parser->get_node_type() == XMLParser::NODE_ELEMENT && parser->get_node_name().to_lower() == "defs") {
176+
is_in_defs = true;
177+
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name().to_lower() == "defs") {
178+
is_in_defs = false;
179+
}
180+
if (!is_in_defs && parser->has_attribute("id")) {
175181
const String &gl_name = parser->get_named_attribute_value("id");
176182
if (gl_name.begins_with("glyph")) {
177183
#ifdef GDEXTENSION

0 commit comments

Comments
 (0)