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

[SVG in OT] Fix rendering of some glyphs using "defs" with "#glyphXXXXX.X" id.

This commit is contained in:
Pāvels Nadtočajevs
2025-06-03 13:18:55 +03:00
parent e45cc68092
commit e928b2a5e5
2 changed files with 14 additions and 2 deletions

View File

@@ -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; String *p_xml = &xml_body_temp;
int64_t tag_count = -1; int64_t tag_count = -1;
bool is_in_defs = false;
while (parser->read() == OK) { 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"); const String &gl_name = parser->get_named_attribute_value("id");
if (gl_name.begins_with("glyph")) { if (gl_name.begins_with("glyph")) {
#ifdef GDEXTENSION #ifdef GDEXTENSION

View File

@@ -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; String *p_xml = &xml_body_temp;
int64_t tag_count = -1; int64_t tag_count = -1;
bool is_in_defs = false;
while (parser->read() == OK) { 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"); const String &gl_name = parser->get_named_attribute_value("id");
if (gl_name.begins_with("glyph")) { if (gl_name.begins_with("glyph")) {
#ifdef GDEXTENSION #ifdef GDEXTENSION