[csswg-drafts] [css-values] Proposal: `sp` and `rsp` space glyph units (#10534)

jbasoo has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values] Proposal: `sp` and `rsp` space glyph units ==
## Background
There is currently no reliable way of knowing the advance measure of a space glyph. It can be estimated using `ch` unit, however this is not very precise and will change depending on whichever font from the stack is being rendered. An `sp` unit would improve ergonomics and could potentially open up new design possibilities, as outlined in the "Use Cases" section. Given that glyph metric units already exist (`ex`, `ch`), perhaps some of the technical details for this proposal have already been implemented.
## Proposal
Add `sp` and `rsp` units which represent the advance measure of the space (U+0020) glyph. It may be desirable to follow the same logic as the `ch` unit spec, including fallbacks where it is impossible or impractical to determine the measure of the space glyph.
## Use Cases
- Accurately increase word spacing `word-spacing: 1sp;`
- Accurately remove word spacing `word-spacing: -1sp;`
- Add spaces between letters `letter-spacing: 3sp;`
- Space glyph relative gap in flex/grid contexts `gap: 1sp;`

Initial exploration of these uses can be found on [Codepen](https://codepen.io/jbasoo/pen/vYqBmyK).
## Questions & Concerns
- Is the advance measure of the space character different in non-European languages such as CJK? If so what challenges does this pose?
- Is the proposed unit any more of a fingerprinting concern than existing units?
- While adding space glyph advance measure unit could be helpful, does this open the door to requests for units for other glyphs? If so, should an additional function to return the advance measure of any glyph be explored?
 - `margin: am('M'); /* advance measure of the "M" glyph */`
 - `margin: am(' '); /* advance measure of the space glyph */`
 - `inline-size: max(am('W'), am('o'), am('r'), am('d')); /* faux-monospace using the largest advance measure from a list of glyphs */`

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10534 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 5 July 2024 18:52:49 UTC