Repository navigation
Labels centred on their capitals: the kit's pk-label, and a renderer check - #190
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Active issues cause mixed prose to inherit identifier typography and scaled labels to be measured with inconsistent coordinates, requiring fixes to font targeting and measurement logic.
2 open issues
What changed in this PR
This PR adds the renderer kit’s pk-label primitive to centre text on its capitals, applies it across built-in renderers, and introduces a structural check for label alignment.
Changes:
- Adds shared label trimming, font handling and inset styles.
- Updates renderer labels, chips, headers and buttons, with matching markup assertions.
- Adds the
labelsprobe,label-centringcheck, regression coverage and documentation.
| File | Description |
|---|---|
| packages/renderers/text-diff/test/view.test.mjs | Updates label markup assertions. |
| packages/renderers/text-diff/src/view.tsx | Applies labels to gutters, text and captions. |
| packages/renderers/testing/test/helpers.test.mjs | Tests check registration and failure reporting. |
| packages/renderers/testing/src/types.ts | Defines label probe and check types. |
| packages/renderers/testing/src/probe.ts | Registers the labels probe. |
| packages/renderers/testing/src/measure/styles/box.ts | Excludes font-derived padding from spacing checks. |
| packages/renderers/testing/src/measure/labels.ts | Measures capital alignment against label surfaces. |
| packages/renderers/testing/src/measure.ts | Exports label measurement. |
| packages/renderers/testing/src/checks/runner.ts | Registers the label check. |
| packages/renderers/testing/src/checks/labels.ts | Reports and groups alignment failures. |
| packages/renderers/testing/src/checks/catalog.ts | Adds check title and description. |
| packages/renderers/testing/README.md | Documents alignment and spacing checks. |
| packages/renderers/runtime-policy/test/runtime-policy.test.mjs | Updates chip and heading assertions. |
| packages/renderers/runtime-policy/src/styles.css | Centres chips and adjusts heading padding. |
| packages/renderers/runtime-policy/src/row.tsx | Labels headings and warnings. |
| packages/renderers/runtime-policy/src/chips.tsx | Labels chip signs, prefixes and text. |
| packages/renderers/kit/test/table.test.mjs | Updates value-pill assertions. |
| packages/renderers/kit/test/group.test.mjs | Updates group label assertions. |
| packages/renderers/kit/test/diff.test.mjs | Updates change-pill assertions. |
| packages/renderers/kit/styles/status.css | Defines the shared label primitive. |
| packages/renderers/kit/styles/layout.css | Preserves group label insets. |
| packages/renderers/kit/styles/diff.css | Avoids trimming containers of value-change pills. |
| packages/renderers/kit/src/react/status-tab.tsx | Wraps status-tab text in labels. |
| packages/renderers/kit/src/react/layout-components.tsx | Labels group titles and metadata. |
| packages/renderers/kit/src/react/graph-canvas/graph-footer.tsx | Labels footer button text. |
| packages/renderers/kit/src/react/diff-components.tsx | Labels values and change-pill content. |
| packages/renderers/kit/src/react/components.tsx | Labels badges and status words. |
| packages/renderers/harness/browser/labels.spec.ts | Tests detection after disabling label trimming. |
| packages/renderers/gallery/src/view.tsx | Labels revision button text. |
| packages/renderers/gallery/src/styles.css | Centres revision button contents. |
| packages/renderers/database/test/transition.test.mjs | Updates status and identifier assertions. |
| packages/renderers/database/src/tags.tsx | Labels measured and displayed tags. |
| packages/renderers/database/src/table.tsx | Labels names, types, keys and headings. |
| packages/renderers/database/src/styles.css | Enables trimming and adjusts row padding. |
| packages/renderers/code-statistics/test/statistics.test.mjs | Updates status-word markup assertion. |
| packages/renderers/api/test/api.test.mjs | Updates signature and marker assertions. |
| packages/renderers/api/src/styles.css | Sets signature insets and marker positioning. |
| packages/renderers/api/src/signature-view.tsx | Labels signatures and change markers. |
| packages/renderers/agentic-workflows/src/styles.css | Adjusts lock alignment and matrix glyph centring. |
| packages/renderers/agentic-workflows/src/matrix.tsx | Adds centred label wrappers for matrix glyphs. |
| docs/guides/renderer-kit.md | Documents label usage and insets. |
| docs/guides/develop-a-renderer.md | Adds label alignment guidance. |
Review effort: Balanced
This was referenced Nov 22, 2026
…check Polish step (c). Text centred by its line box sits a little high or low of its chip, bar or button, by how its font's ascent, descent and cap height compare, and differently in Chromium and WebKit. That is the user's capital-E rule, so it moves into the kit and a renderer check. - Kit `pk-label`: trims the text box to the capitals and the alphabetic baseline (`text-box: trim-both cap alphabetic`), then pads it back to its line height, so it keeps its size and whatever centres it centres the capitals. Extra room goes in `--pk-label-inset`. A label holding one identifier takes the identifier's font. Without `text-box` it is an ordinary line. - The kit uses it in change pills and value changes, badges, status words and status tabs, group titles and meta, and the graph footer's buttons. - `label-centring` (probe call `labels`): each HTML chip, bar or button (up to 48px tall, painting a background or edges above and below, one line of its own text) must have as much room above its capitals as below its baseline, within half a pixel. The metrics come from the engine's own layout: each font's ascent and `1cap`, laid out once on a hidden line, because canvas metrics are rounded in WebKit and glyph ink differs between engines. A collapsed table rule counts half to each cell, and a box stretched by its row past its own line (a line number beside a wrapped line) isn't a label. - `spacing` counts only a trimmed label's inset as spacing; the rest of its padding is its font's. Violations found and fixed (Chromium and WebKit, desktop and mobile): group headers, change pills, status tabs (kit); runtime-policy chips, head rows and warnings; database headers, tags, value pills and column, key and enum rows; text-diff line numbers, marks, text and captions; agentic-workflows matrix cells and the stale-lock pill (its icon set the baseline); code-statistics pills; api signatures (and their +/− mark, which WebKit put on the trimmed line's top); gallery revision buttons; the graph footer. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
agorischek
force-pushed
the
agorischek/cap-labels
branch
from
November 23, 2026 00:07
b3e00b6 to
4da3a73
Compare
…ks code values - A one-line pk-label is at least its line height (its inset either side), with its trimmed text centred in it (align-content), padded half a pixel short of centring it alone. Its box no longer depends on the capitals an engine trims to or how it rounds the padding: Linux WebKit's left bands and the frames around them a fraction of a pixel off, and a changed region at a frame's foot then drew off-centre from its border (frames.spec, runtime-policy). - labels.spec holds every one-line label's box to that height, in every scenario; spacing counts only its inset (its min-height less its line height). - ValueChange's code prop marks its values as identifiers, so database no longer sets a font size itself (the SDK style lint's warning). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…e label keeps the UI font Review follow-ups: - A text fragment's rect is drawn (transformed) while the font's metrics are measured untransformed: the metrics and the surface's borders are scaled by the surface's drawn scale, and the gaps compared in its laid-out pixels, so a renderer that fits its drawing with a transform (database) measures true. - labels.spec: a scaled stage stays clean; a label of mixed prose (words with a code span) keeps the UI font, as runtime-policy's warning notes do. Only a ValueChange marked code sets its values in mono (the CSS :only-child rule this replaced is gone). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Polish step (c): text centred on its capitals in every chip, bar and button, as a kit primitive with a renderer check.
Why
A line of text centred by its line box sits a little high or low in its chip, bar or button. How far depends on how the font's ascent, descent and cap height compare, and it differs between Chromium (whole-pixel metrics) and WebKit (fractional ones). The rule is the capital-E test: a capital E has as much room above it as below it.
Kit:
pk-labelpk-labeltrims the text box to the capitals and the alphabetic baseline (text-box: trim-both cap alphabetic), then pads it back to its line height. The box keeps its size, and whatever centres it centres the capitals.--pk-label-inset.text-boxsupport, it is an ordinary line.Check:
label-centring(probe calllabels)1cap, laid out once on a hidden line. Canvas metrics don't work: WebKit rounds them, but not its layout, and glyph ink differs between engines. On trimmed labels the model matches the trimmed box within 0.01px in both engines.spacingcounts only a trimmed label's inset as spacing; the rest of its padding comes from the font.labels.specshows the probe works: it finds the original violations once the trim is undone.Violations found and fixed
Measured on chromium-desktop, webkit-desktop and chromium-mobile:
After the fixes,
checks.specpasses 26/26 on all three projects.Before and after (2×)
The differences are fractions of a pixel by design. In the pills, the database header and the captions, the capitals now sit evenly between the edges.
Follow-ups (CI)
EntityCardrelationship rows are labels too. The CLI starter renderer draws them, and no harness scenario did.label-centringcentres a box on its main text, meaning the runs in its largest font size. A title outweighs its smaller meta, and a database name outweighs its key's smaller mono, which Linux's fonts set lower.pk-label.