Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-text] Decimal digit transforms #9877

Open
Crissov opened this issue Jan 30, 2024 · 2 comments
Open

[css-text] Decimal digit transforms #9877

Crissov opened this issue Jan 30, 2024 · 2 comments

Comments

@Crissov
Copy link
Contributor

Crissov commented Jan 30, 2024

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:

  • global-digits: Use the respective glyph of U+0030…9 (09) for any Nd character with an integer Numeric Value of 0, …, 9. Note that font-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.

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
Copy link
Member

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
Copy link
Contributor Author

Crissov commented Jan 31, 2024

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 openui/open-ui#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:

  • [css-text] Provide CSS support for automatic spacing (or other separators) in text input field #4875 is about adding grouping characters to numbers, but probably also to arbitrary (alphanumeric) strings.
  • Authors should also be able to replace grouping characters (including to remove them), regardless whether they existed in content or were added by CSS. This should be in scope of text-transform.
  • … and decimal separators in numbers, i.e. comma vs. dot (but not remove them).
  • Zero-padding and truncating numbers may be considered styling, so although it’s out of scope for text-transform it’s in scope of CSS.
    • I’d then also consider to propose deprecating the never-implemented text-align: <string> in table cells in favor of leading (or trailing) invisible zeros.
    • Applications may select shorter representations of the same data with possibly reduced precision, especially in tables, e.g. for dates (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.
  • Grouping and separating is similar to splitting up a number into separate parts which can be formatted individually, but this is a slippery slope towards full unit conversion: 123.456789°123°27′24.44″, 123456.789 s = 1 d 10 h 17 m 36.789 s = 34:17:36.7891.429 d, 12.345 m = 12,345 mm486 in = 40.5 yd = 40′ 6″

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants