w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.52k stars 672 forks source link

[css-text] Decimal digit transforms #9877

Open Crissov opened 9 months ago

Crissov commented 9 months ago

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 and No 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-specific kansuji 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:

The former could be done with #3132, but the latter couldn’t.

Vulgar fractions, roman numerals etc. would be unaffected by these transformations.

`Nd` Ranges =========== * U+003x Digit * U+066x Arabic-Indic Digit * U+06Fx Extended Arabic-Indic Digit * U+07Cx Nko Digit * U+096y Devanagari Digit * U+09Ey Bengali Digit * U+0A6y Gurmukhi Digit * U+0AEy Gujarati Digit * U+0B6y Oriya Digit * U+0BEy Tamil Digit * U+0C6y Telugu Digit * U+0CEy Kannada Digit * U+0D6y Malayalam Digit * U+0DEy Sinhala Lith Digit * U+0E5x Thai Digit * U+0EDx Lao Digit * U+0F2x Tibetan Digit * U+104x Myanmar Digit * U+109x Myanmar Shan Digit * U+17Ex Khmer Digit * U+181x Mongolian Digit * U+194y Limbu Digit * U+19Dx New Tai Lue Digit * U+1A8x Tai Tham Hora Digit * U+1B5x Balinese Digit * U+1BBx Sundanese Digit * U+1C4x Lepcha Digit * U+1C5x Ol Chiki Digit * U+A62x Vai Digit * U+A8Dx Saurashtra Digit * U+A90x Kayah Li Digit * U+A9Dx Javanese Digit * U+A9Fx Myanmar Tai Laing Digit * U+AA5x Cham Digit * U+ABFx Meetei Mayek Digit * U+FF1x Fullwidth Digit * U+104Ax Osmanya Digit * U+10D3x Hanifi Rohingya Digit * U+1106y Brahmi Digit * U+110Fx Sora Sompeng Digit * U+1113y Chakma Digit * U+111Dx Sharada Digit * U+112Fx Kudawadi Digit * U+1145x Newa Digit * U+114Dx Tirhuta Digit * U+1165x Modi Digit * U+116Cx Takri Digit * U+1173x Ahom Digit * U+118Ex Warang Citi Digit * U+1195x Dives Akuru Digit * U+11C5x Bhaiksuki Digit * U+11D5x Masaram Gondi Digit * U+11DAx Gunjala Gondi Digit * U+16A6x Mro Digit * U+16ACx Tangsa Digit * U+16B5x Pahawh Hmong Digit * U+1E14x Nyiakeng Puachue Hmong Digit * U+1E2Fx Wancho Digit * U+1E95x Adlam Digit * U+1FBFx Segmented Digit * without Mathematical sets around U+1D7__ _x_ in [0…9], _y_ in [6…F]
tabatkins commented 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?

Crissov commented 9 months ago

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.

Background and plans

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: