mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-11 16:30:12 -06:00
shape_text deduped spans into styles by scanning the styles already collected - O(spans x styles), so a styled text's dedupe grew with the square of its runs. Now the last two styles again (spans run in blocks), then buckets keyed by a cheap fingerprint (family and style bytes, size bits with -0.0 folded onto 0.0, the enums, fill count and solid colours, variation count), each bucket resolved with the full equality: the result is the scan's, never worse than it, and O(spans) when names and sizes differ. The fingerprint seed comes from the address space, so document-supplied names can't precompute collisions; the worst an adversarial document does is fall back to the scan it started with. The font-db write lock is untouched: find() loads faces, which needs the write. layout_dedupe_tests covers blocks, excluded fields (links, style ids, gradient stops), -0.0 and pathological alternation.