More people need to know about the "tabular numbers" feature that modern fonts have
Use it to make numbers to line up with a UI font (or anything not monospace)
CSS: font-feature-settings: tnum
SwiftUI: .font(.body.monospacedDigit())
More people need to know about the "tabular numbers" feature that modern fonts have
Use it to make numbers to line up with a UI font (or anything not monospace)
CSS: font-feature-settings: tnum
SwiftUI: .font(.body.monospacedDigit())
Example with the same numbers. Doesn't really change much
Also, a better way to apply it in CSS (thanks for the replies):
font-variant-numeric: tabular-numbers;
@cassidy @kdrag0n if you add the `.numeric` style to a widget. the libadwaita stylesheet will ensure tabular numbers.
https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/style-classes.html
Really confusingš©
@kdrag0n this is awesome, thanks for putting me onto this! one small note:
from MDN:
font-variant shorthand property or an associated longhand property such as font-variant-ligatures, font-variant-caps, font-variant-east-asian, font-variant-alternates, font-variant-numeric or font-variant-position.font-feature-settings, which is a low-level feature designed to handle special cases where no other way exists to enable or access an OpenType font feature.here's how to enable tabular numbers using the MDN recommendations:.my-selector {
/* shorthand */
font-variant: tabular-nums;
/* longhand */
font-variant-numeric: tabular-nums;
}@kdrag0n
Getting numbers in tables right will definitely keep many eyeballs sane.
However, getting numbers in tables right in the right way is also important.
The recommended high-level way (which does not depend on OpenType implementation details) is:
font-variant-numeric: tabular-nums;
https://developer.mozilla.org/en-US/docs/Web/CSS/font-feature-settings
Font features or variants refer to different glyphs or character styles contained within an OpenType font. These include things like ligatures (special glyphs that combine characters like 'fi' or 'ffl'), kerning (adjustments to the spacing between specific letterform pairings), fractions, numeral styles, and several others. These are all referred to as OpenType Features, and are made available to use on the web via specific properties and low-level control properties ā font-feature-settings. This article provides you with all you need to know about using OpenType font features in CSS.
@kdrag0n Using tabular figures is even more important when displaying changing numbers, such as in progress indicators or clocks.
It's somewhat of a pet peeve of mine, so I once wrote a blog post on it: https://blog.horizon-eda.org/misc/2020/02/19/ui.html
Once you've seen it, it's everywhere!
LaTeX + fontspec
```
\addfontfeatures{Numbers=Monospaced}
```
bspw. in jeder Tabelle:
```
\AtBeginEnvironment{tabular}{\addfontfeatures{Numbers=Monospaced}}
```
@kdrag0n I AM BOOKMARKING THIS
And then I am probably going to adhd forget about it by the end of today