Open Crissov opened 9 months ago
AH's property presumably has use-cases to justify what it's doing. Could you elaborate on the use-cases for your altered proposal?
It’s mostly the same use cases but limited to what is actually in scope of text-transform
, i.e. digits and not numbers. I’m no i18n expert, but my understanding is that at least in some locales European digits are preferred in forms, formulas and tables, but native digits are preferred in prose – the data source may be the same.
Several system APIs provide similar functions, e.g. Win32 calls it native digit shapes and provides unidirectional conversion towards local forms only.
I’m trying to explore how numeric data is presented: How much of it is styling and which part of CSS is best suited to deal with it, if any. Ultimately, I want CSS to be able to express various number and value formatting to support things like https://github.com/openui/open-ui/issues/499 declaratively without the need for scripting. If this proposal is seen as valid by the WG, it should be followed by others to style more parts of an actual number:
text-transform
.text-transform
it’s in scope of CSS.
text-align: <string>
in table cells in favor of leading (or trailing) invisible zeros.JAN31
vs. 2024-01-31
vs. Wednesday, 31st January of 2024 AD
) or file sizes (1,234,567 B
vs. 1,235 kB
vs. 1.2 MB
) – perhaps in scope of text-overflow
.123.456789°
≈ 123°27′24.44″
, 123456.789 s
= 1 d 10 h 17 m 36.789 s
= 34:17:36.789
≈ 1.429 d
, 12.345 m
= 12,345 mm
≈ 486 in
= 40.5 yd
= 40′ 6″
…
Unicode has a character property to record its numeric value. This is mostly used for script-specific decimal digits, but also for precomposed vulgar fractions and other numerals. The relevant character classes are
Nd
Decimal Number,Nl
Letter Number andNo
Other Number.Antenna House Formatter supports a custom property
number-transform
. It does not just change the digit glyph, but the whole number. Besides Japanese-specifickansuji
keywords, it accordingly accepts<list-style-type>
as a value (and<string>
).I would like to propose something simpler, i.e. two new keywords – to be bikeshedded – for the
text-transform
property:global-digits
: Use the respective glyph of U+0030…9 (0
…9
) for anyNd
character with an integer Numeric Value of 0, …, 9. Note thatfont-variant-numeric
will have an effect on those.local-digits
: The inverse transformation, using the default digits of the native script derived from the language as returned by:lang()
. This should also convert digits from other scripts, not just the international “ASCII” ones.The former could be done with #3132, but the latter couldn’t.
Vulgar fractions, roman numerals etc. would be unaffected by these transformations.