davesnx / styled-ppx

Type-safe styled components for ReScript, Melange and native with type-safe CSS
https://styled-ppx.vercel.app
BSD 2-Clause "Simplified" License
402 stars 33 forks source link

Add unicodeRange to fontFace #513

Closed pedrobslisboa closed 2 months ago

pedrobslisboa commented 2 months ago

Description

It was missing the unicode-range property on fontFace. This PR adds it. It also ran the make format

The unicode-range works under this type:

  type t =
    [ `single of string
    (* E.g. `single "1234" U+1234 *)
    | `range of string * string
    (* E.g. `range ("1234", "5678") U+1234-U+5678 *)
    | `wildcard of string * string
    (* E.g. `wildcard ("12", "??") U+12?? *)
    ]
    array

@davesnx I'm not so happy with `wildcard ("12", "??"). Do you have a better idea?

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **styled-ppx** | ⬜️ Ignored ([Inspect](https://vercel.com/david-sanchos-projects-8c534635/styled-ppx/G5KXFU2LWg6ahvTkzYuHN5ArEHLu)) | [Visit Preview](https://styled-ppx-git-fork-pedr-4c2fe9-david-sanchos-projects-8c534635.vercel.app) | | Sep 30, 2024 8:14pm |
davesnx commented 2 months ago

@davesnx I'm not so happy with `wildcard ("12", "??"). Do you have a better idea?

what about `wildcard ("12") and render ?? directly?

pedrobslisboa commented 2 months ago

@davesnx I'm not so happy with `wildcard ("12", "??"). Do you have a better idea?

what about `wildcard ("12") and render ?? directly?

I wonder if U+4? matches: U+40, U+400, U+4000, U+4000... . If don't, adding ?? dynamically may not be possible.

davesnx commented 2 months ago

U+4?? means include all characters in the range U+400 to U+4FF.

https://drafts.csswg.org/css-fonts/#unicode-range-desc

Your design is probably right:

Wildcard ranges specified with ‘?’ that lack an initial digit (e.g. "U+???") are valid and equivalent to a wildcard range with an initial zero digit (e.g. "U+0???" = "U+0000-0FFF"). Wildcard ranges that extend beyond the range of Unicode codepoints are invalid. Because of this, the maximum number of trailing '?' wildcard characters is five, even though the [UNICODE-RANGE](https://www.w3.org/TR/CSS21/syndata.html#tokenization) token accepts six.