-
Notifications
You must be signed in to change notification settings - Fork 733
Open
Labels
Description
The https://drafts.csswg.org/css-fonts/#steak-marinade example applies font-variant-numeric: diagonal-fractions
to semantically-meaningful spans in a way that doesn't work with most actually-existing fonts.
Specifically, when the frac
feature is turned on, all but one of the fonts I can find do one of two things. Extending the example above:
<link href="https://fonts.googleapis.com/css2?family=Ubuntu+Mono&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans&display=swap" rel="stylesheet">
<style>
@font-face {font-family:'GimletDisplay Light'; src:url('https://www.axis-praxis.org/fonts/webfonts/Gimlet_Romans-VF.woff2');}
.amount { font-variant-numeric: diagonal-fractions; }
</style>
<p><span class="amount">1 3/4</span> C. sugar</p>
<p><span class="amount">13/42</span> tbs. salt</p>
- They format every digit as a numerator unless it follows a
/
, at which point it's formatted as a denominator.
p {font-family: "IBM Plex Sans";}
The "Times New Roman" and "Arial" fonts used as the default serif and sans-serif fonts on Windows 10 have this behavior.
- They special-case certain substrings to format as small fractions, but break the rendering of a larger fraction that happens to contain that substring.
p {font-family: "Ubuntu Mono";}
I did find one font that behaves sensibly, so the feature is possible:
p {font-family: "GimletDisplay Light";}
I'm not sure of the right thing for the WG to do at this point. A couple options might be:
- Change the example to use formatting-markup instead of semantic-markup: something like
This is probably safe as long as people only mark up a single digit on each side of the
<li>1 <span class="fraction">1/2</span> tbsp dry minced onion</li>
/
. With more than one digit included, fonts like Ubuntu Mono will break things. - Deprecate
diagonal-fractions
: if it's not usable in semantic markup, does it deserve a place infont-variant-numeric
? It'd still be accessible throughfont-feature-settings: "frac"
. - Go talk to font designers and encourage them to do whatever Gimlet is doing.