Re: [csswg-drafts] [css-fonts] font-variant-numeric: diagonal-fractions, in most fonts, doesn't work with semantic markup (#5756)

One popular place that might benefit from a more refined definition in either CSS or OT is [Wikipedia’s `{{frac}}` template](https://en.wikipedia.org/wiki/Template:Fraction), which currently generates HTML code like this:

~~~~ html
<span class="frac" role="math">12<span class="sr-only">+</span><span class="num">34</span>&frasl;<span class="den">56</span></span>`
~~~~

It then synthesizes the desired look with [some style](https://en.wikipedia.org/wiki/Template:Fraction/styles.css) like this:

~~~~ css
.frac {
 white-space: nowrap;
}
.frac .num,
.frac .den {
 font-size: 80%;
 line-height: 0;
 vertical-align: super;
}
.frac .den {
 vertical-align: sub;
}
~~~~

The template has always put out U+2044 Factor Slash. 
Replacing `<span class="sr-only">+</span>` with U+2064 Invisible Plus has been discussed but rejected; earlier versions used a (narrow?, non-breaking?) space character there. 
It was also (ab)using `<sup>` for numerator and `<sub>` for denominator until a couple of years ago. 
Replacing some recognized vulgar fractions with precomposed ligature characters like ⅔ was also considered but rejected. 

This template is, arguably, also supposed to work with more complex cases, e.g.:

* `1234⁄56789`
  * `1.234⁄56.789`
  * `1,234⁄56,789`
  * `1’234⁄56’789`
  * `1'234⁄56'789`
* `π⁄3`
  * `2π⁄3`
  * `2*π⁄3`
  * `2·π⁄3`
  * `2&#x2062;π⁄3` Invisible Times
* `1⁄√2` Radical Symbol
* `1⁄2n`
  * `1⁄2&#x2062;n`
* `1⁄<var>n</var>`
* `km⁄h`, `€⁄kg`
* `२⁄३`
* `۲⁄۳`
* (The spacing after, as in `2⁄3 π`, is out of scope.)

It would be informative to know whether authors could ever expect `font-variant-numeric: diagonal-fractions` and `stacked-fractions` to work with any fractions like these, which go beyond simple digits `[0123456789]`, when using U+2044 or when using U+002F Solidus. 
Vulgar fraction units are probably out of scope as are (single-)letter constants and variables, but local digits (like the Devanagari and Arabic examples above) are perhaps in scope. I’m not sure about things like the square root symbol. 

-- 
GitHub Notification of comment by Crissov
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5756#issuecomment-1826715516 using your GitHub account


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

Received on Sunday, 26 November 2023 07:57:38 UTC