mirror of
https://github.com/penpot/penpot.git
synced 2026-09-14 16:09:01 +00:00
* 🐛 Fix font-family sample not showing for numeric font names Setting style.fontFamily to a raw, unquoted family name (e.g. "Micro 5") parses it against CSS's <family-name> grammar: a whitespace- separated sequence of <custom-ident>s. "Micro" tokenizes fine, but a bare "5" isn't a valid CSS identifier (idents can't start with a digit) — it tokenizes as a number instead, so the whole property is invalid CSS and the browser silently drops it. Every other font in the list happened to avoid this because none of their names have a token that's purely numeric. Quote the family name, matching what font-item-preview* (the font selector's own preview, a few lines down in the same file) already does, so it's parsed as a CSS string instead of unquoted identifiers. Also falls back to the live fontsdb entry's family when the typography record's own :font-family is blank — a font that was unloaded when a typography's font/variant was last changed can leave that field nil (the same failure mode remove-nil-style-attrs already repairs for shape text spans) — and loads the font unconditionally in the collapsed asset row, matching the expanded editor, since the optical-offset cache can otherwise skip loading it entirely. AI-assisted-by: claude-sonnet-5 * 🐛 Fix flaky typography sample position in automated tests The optical-centering offset for the "Ag" sample (and the font selector's fallback name label) resolves asynchronously: first paint is unshifted, then an idle-scheduled Canvas measurement lands and the sample jumps to its final position. Any test that checks position or takes a screenshot shortly after paint races that jump — whether it runs before or after is a timing accident, not a deterministic outcome, which is exactly the "sometimes a few pixels up, sometimes down" flakiness QA hit. use-optical-offset now returns [offset ready?], with both lazily initialized from the cache so a cache hit needs no async round-trip at all. sample-text-style hides the glyphs until ready?, so the sample only ever appears already in its final, correct position instead of visibly moving there after the fact. The font selector's own name label uses the same hook but always shows real text content rather than a decorative sample, so it keeps the old behavior instead: hiding it would blank out font names while scrolling, worse than the minor positional nicety it's fixing. AI-assisted-by: claude-sonnet-5