Fix lettering id-error and trims (#2711)

pull/2722/head
Kaalleen 2024-02-10 20:17:36 +01:00 zatwierdzone przez GitHub
rodzic 0fb7d82f72
commit 0825da15db
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 3 dodań i 10 usunięć

Wyświetl plik

@ -365,7 +365,7 @@ class Font(object):
line_break_indices = [i for i, t in enumerate(text) if t == "\n"]
for group in destination_group.iterdescendants(SVG_GROUP_TAG):
# make sure we are only looking at glyph groups
if group.get("id") != "glyph":
if not group.get("id", "").startswith("glyph"):
continue
i += 1

Wyświetl plik

@ -14,20 +14,13 @@ def get_document(node):
return node.getroottree().getroot()
def generate_unique_id(document_or_element, prefix="path"):
def generate_unique_id(document_or_element, prefix="path", blocklist=None):
if isinstance(document_or_element, etree._ElementTree):
document = document_or_element.getroot()
else:
document = get_document(document_or_element)
doc_ids = {node.get('id') for node in document.iterdescendants() if 'id' in node.attrib}
i = 1
while True:
new_id = "%s%d" % (prefix, i)
if new_id not in doc_ids:
break
i += 1
new_id = document.get_unique_id(prefix, blacklist=blocklist)
return new_id