Skip to content

Place the caption outline outside the letter - #14

Merged
rponeawa merged 1 commit into
mainfrom
caption-outside-outline
Aug 20, 2026
Merged

rponeawa merged 1 commit into
mainfrom
caption-outside-outline

Conversation

@rponeawa

Copy link
Copy Markdown
Member

The previous change put the caption's centred stroke behind the fill, which stopped it eating the letterform but left it showing at half the authored width — and did nothing at all when the fill is a gradient, because a gradient fill is a background-clip: text background and paint-order only orders the text's own fill and stroke. Both are symptoms of the same thing: a text stroke is centred on the glyph edge, so half its width is inside the letter no matter what, and the only remaining choice is which half gets painted over.

Placing an outline needs Paint rather than style. Text Flow already has that vocabulary — a stroke layer carries placement, and the renderer builds the ring by dilating the glyph alpha and compositing the glyph out of it, so nothing of the letter is spent. Caption Fine could not reach it because it emits the plain text element, which had no Paint. That element now carries the same paints field Text Flow does: the same VisualTextPaintLayer type, the same assertTextPaint validation, the same filters. Caption Fine keeps its per-word elements, karaoke layers and Pill unchanged.

Measured

Rendered through the real pipeline at size 64, outline 8px, and counted from the framebuffer:

letter body outline ring total ink
no outline 2957 0 3678
outside outline (this change) 2957 9345 13024
centred stroke behind fill (before) 2957 3044 8558

The body is identical to the no-outline baseline to the pixel — the outline takes nothing from the letter — and the ring is three times what a centred stroke could show at the same width.

The emitted document contains feMorphology operator="dilate" radius="8" and the out composite, and no -webkit-text-stroke anywhere.

Also

  • A filter layer sets text-shadow:none. It shapes itself from its own alpha, so a shadow inherited from the element around it would be dilated into the outline. This applies to Text Flow too, where it was latent.
  • A plain text element may not declare Paint beside a raw stroke style — two ways to say one thing, and both would draw.
  • The manifest said an outline past a tenth of size closes the counters of a, e and o. That was describing the centred stroke; the outline now grows outward and what a heavy one closes is the gap between letters.

Known limit

Shadow, glow and long shadow stay as CSS text-shadow. Long shadow is up to 32 stacked shadows and the IR shadow Paint is a single offset, so they cannot move across without losing it. They therefore paint above the ring rather than beneath it. Every recipe in the repository uses a dark outline with a dark shadow, so it does not show; a light shadow over a dark outline would.

Verification

pnpm check, pnpm test (544, 0 failures), pnpm test:release (8), and pnpm test:browser-visual (12 against a real browser) all pass.

🤖 Generated with Claude Code

A text stroke is centred on the glyph edge. Half its width is inside the letter,
always, and the only thing left to decide is which half gets painted over —
either the outline eats the letterform, or it shows at half the width the author
asked for. Neither is an outline around the outside of a word.

Placing it needs Paint rather than style, and Text Flow already has that
vocabulary: a stroke layer carries `placement`, and the renderer builds the ring
by dilating the glyph's alpha and subtracting the glyph from it. Nothing of the
letter is spent. Plain text elements could not say this, so they now carry the
same `paints` the Text Flow element does — the same type, validated by the same
assertion, drawn by the same filters. Caption Fine keeps its per-word elements,
its karaoke layers and its Pill exactly as they were.

Measured on "Coffee" at size 64 through the real pipeline, with the outline at
8px: the letter body is 2957 pixels with the outline and 2957 without it, to the
pixel, while the ring adds 9345 outside. The centred stroke it replaces showed
3044 — half the width, because that is all a centred stroke can show.

Two smaller things fall out. A filter layer now sets `text-shadow:none`, because
it shapes itself from its own alpha and an inherited shadow would be dilated
into the outline. And a plain text element may not declare Paint beside a raw
stroke style, since that is two ways to say one thing and both would draw.

Known limit: shadow, glow and long shadow stay CSS text-shadow — long shadow is
up to 32 stacked shadows and the IR shadow Paint is one offset — so they paint
above the ring rather than beneath it. Outline and shadow are both dark in every
recipe here, so it does not show; a light shadow over a dark outline would.

Co-Authored-By: Claude <[email protected]>
@rponeawa
rponeawa merged commit 03a1357 into main Aug 20, 2026
2 checks passed
overlordkim pushed a commit that referenced this pull request Sep 9, 2026
Place the caption outline outside the letter
overlordkim pushed a commit that referenced this pull request Sep 9, 2026
Place the caption outline outside the letter
SanHsien referenced this pull request in SanHsien/hypit Oct 24, 2026
SanHsien referenced this pull request in SanHsien/hypit Oct 24, 2026
* fix: remove ReDoS in markup references and double unescaping in video attributes

- markup: REFERENCE's character class already contains ".", so the
  trailing (\.X*)* group only added exponential backtracking. The
  simplified pattern accepts exactly the same strings (exhaustively
  checked for all strings up to length 6 over a small alphabet).
- provider-hyperframes-local: decode &amp; last so "&amp;lt;" yields
  "&lt;" instead of "<".
- Record both fixes in docs/fork/DECISIONS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LzPwoJBKJ97mwPJq3Uohmv

* test(markup): express the original reference grammar without a regex

The oracle regex in the test reintroduced the js/redos pattern that
CodeQL flags; check the same language character by character instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LzPwoJBKJ97mwPJq3Uohmv

* docs(fork): record CodeQL alert numbers #12 and #14

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(fork): keep CodeQL alert numbers only in the table

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant