Skip to content

fix: centre the highlighted-lines chip text - #86

Merged
mcanouil merged 2 commits into
mainfrom
fix/chip-text-centring
Nov 5, 2026
Merged

mcanouil merged 2 commits into
mainfrom
fix/chip-text-centring

Conversation

@mcanouil

@mcanouil mcanouil commented Nov 5, 2026

Copy link
Copy Markdown
Owner

The highlighted-lines chip in the title bar had its text off centre.
Its line box keeps room for descenders that a label such as "L3" or "L1-3" never uses.
In Chromium the text sat about 1px above the middle of the chip.

The chip now uses text-box: trim-both cap alphabetic inside @supports.
This trims the line box to the cap height and the baseline, and a padding of 0.3em sets the space above and below.
Firefox doesn't support text-box yet, so it keeps the old layout and the old size.

Before After
Chip label L3 in Chromium, sitting closer to the top border Chip label L3 in Chromium, centred between the borders

I measured the gap below the text minus the gap above it, averaged over 8 sub-pixel positions.
In HTML it went from +0.99px to -0.55px in Chromium.
In WebKit (Playwright's 26.5 build) it went from -0.55px to -1.06px, so the text there now sits about half a pixel lower than before.
I haven't checked real Safari yet.
Reveal.js slides use the same rule, and Typst needs no change, because Typst already trims text to the cap height and the baseline.

The chip's line box keeps room for descenders that a label such as
"L1-3" never uses, so in Chromium the text sat about 1px above the
middle. Browsers that support text-box now trim the line box to the
cap height and the baseline, and the padding sets the space instead.
Firefox does not support text-box yet and keeps the old layout.
@mcanouil mcanouil added the Type: Bug 🐛 Issues related to bugs, errors, or mistakes label Nov 5, 2026
@mcanouil mcanouil self-assigned this Nov 5, 2026
@mcanouil
mcanouil marked this pull request as ready for review November 5, 2026 14:52
@mcanouil
mcanouil merged commit 044a198 into main Nov 5, 2026
@mcanouil
mcanouil deleted the fix/chip-text-centring branch November 5, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug 🐛 Issues related to bugs, errors, or mistakes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant