mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-17 15:26:12 +00:00
A font's SVG table can keep many glyphs in one document. Each glyph's art was read by handing the importer the whole document, with every other glyph moved into defs. The importer now gets the glyph's element and only what it refers to: elements named by its effective link (plain href, else xlink:href) or by url(#id) in attributes, style attributes and sheets, what those refer to in turn, the start and end tags of the elements holding them, and every <style> sheet. A document whose references or sheets cannot be followed this way (a DTD, xml:base, an id used twice, a missing or escaped reference, a link to another file, a sheet with sibling, attribute or pseudo-class selectors or at-rules) is read whole, as before. Each element is queued at most once. The color check now runs on the reduced text, so a glyph with fixed colors no longer counts as using the text's color because another glyph of its document uses currentColor. A glyph nested under an element that gives a namespace prefix (or the default namespace) another URI than the root does keeps its own after it is lifted out. For 50 glyphs of a 2,000-glyph document (278 KB), thread CPU time went from 547 ms to 113 ms (medians of 9 runs, the two paths alternating in one process).