kopia lustrzana https://github.com/inkstitch/inkstitch
Fix lettering id-error and trims (#2711)
rodzic
0fb7d82f72
commit
0825da15db
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue