Skip to content

Commit

Permalink
fix(sass): correctly generate numeric unicode subset faces (#961)
Browse files Browse the repository at this point in the history
* fix: correctly generate numeric unicode subset faces [#949]

* fix: missing update of snapshot data

* style: indentation

* fix: missed use case + add comments

* fix: correctly generate numeric unicode subset faces [#949]

* fix: missing update of snapshot data

* style: indentation

* fix: missed use case + add comments

* fix: replace default subset by all

* fix: unit test

* chore: improve code documentation

* Create yellow-deers-hope.md

---------

Co-authored-by: Billy Rothstein - M306213 <billy.rothstein@merckgroup.com>
Co-authored-by: Ayu <hello@ayuhito.com>
  • Loading branch information
3 people committed Apr 16, 2024
1 parent 8d77a7f commit ae11885
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 115 deletions.
5 changes: 5 additions & 0 deletions .changeset/yellow-deers-hope.md
@@ -0,0 +1,5 @@
---
"@fontsource-utils/cli": patch
---

fix(sass): correctly generate numeric unicode subset faces
22 changes: 15 additions & 7 deletions packages/cli/src/sass/mixins.ts
Expand Up @@ -34,6 +34,7 @@ $displayVar: null !default;
// Deprecated
$displayVar: $displayVar
) {
@if $displayVar != null {
@warn "$displayVar is deprecated due to the limitation of using css variables in @font-face (https://github.com/fontsource/fontsource/issues/726).";
}
Expand All @@ -52,7 +53,7 @@ $displayVar: null !default;
$subsets: if(
$subsets,
if($subsets == all, map.get($metadata, subsets), $subsets),
map.get($metadata, defaults, subset)
map.get($metadata, subsets)
);
$weights: if(
$weights,
Expand All @@ -72,13 +73,20 @@ $displayVar: null !default;
@each $subset in $subsets {
@each $unicodeSubset, $unicodeRange in map.get($metadata, unicode) {
// If condition is true, generate faces for the current subset
@if (
($subset == $unicodeSubset) or
(
// Is numeric subset
($subset == map.get($metadata, defaults, subset)) and not
list.index(map.get($metadata, subsets), $unicodeSubset)
)
// If there is no unicode information for the font or
($unicodeSubset == null) or
// If the subset match a unicode subset or
($subset == $unicodeSubset) or
(
// If $unicodeSubset is a numeric unicode subset
// and current subset exists in the list of font subsets but does not match any unicode subset
// then generate faces for this numeric unicode subset as it is representing part of the current subset
list.index(map.get($metadata, subsets), $subset) and not
map.has-key($metadata, unicode, $subset) and not
list.index(map.get($metadata, subsets), $unicodeSubset)
)
) {
@each $weight in if($axes, null, $weights) {
@each $axis in $axes {
Expand Down
Expand Up @@ -44,6 +44,7 @@ $unicode: (
8: (U+98eb,U+98ed-98ee,U+98f0-98f1,U+98f3,U+98f6,U+9902,U+9907-9909,U+9911-9912,U+9914-9918,U+991a-9922,U+9924,U+9926-9927,U+992b-992c,U+992e,U+9931-9935,U+9939-993e,U+9940-9942,U+9945-9949,U+994b-994e,U+9950-9952,U+9954-9955,U+9958-9959,U+995b-995c,U+995e-9960,U+9963,U+9997-9998,U+999b,U+999d-999f,U+99a3,U+99a5-99a6,U+99a8,U+99ad-99ae,U+99b0-99b2,U+99b5,U+99b9-99ba,U+99bc-99bd,U+99bf,U+99c1,U+99c3,U+99c8-99c9,U+99d1,U+99d3-99d5,U+99d8-99df,U+99e1-99e2,U+99e7,U+99ea-99ee,U+99f0-99f2,U+99f4-99f5,U+99f8-99f9,U+99fb-99fe,U+9a01-9a05,U+9a08,U+9a0a-9a0c,U+9a0f-9a11,U+9a16,U+9a1a,U+9a1e,U+9a20,U+9a22-9a24,U+9a27,U+9a2b,U+9a2d-9a2e,U+9a31,U+9a33,U+9a35-9a38,U+9a3e,U+9a40-9a45,U+9a47,U+9a4a-9a4e,U+9a51-9a52,U+9a54-9a58,U+9a5b,U+9a5d,U+9a5f,U+9a62,U+9a64-9a65,U+9a69-9a6c,U+9aaa,U+9aac-9ab0,U+9ab2,U+9ab4-9ab7,U+9ab9,U+9abb-9ac1,U+9ac3,U+9ac6,U+9ac8,U+9ace-9ad3,U+9ad5-9ad7,U+9adb-9adc,U+9ade-9ae0,U+9ae2-9ae4),
9: (U+971d,U+9721-9724,U+9728,U+972a,U+9730-9731,U+9733,U+9736,U+9738-9739,U+973b,U+973d-973e,U+9741-9744,U+9746-974a,U+974d-974f,U+9751,U+9755,U+9757-9758,U+975a-975c,U+9760-9761,U+9763-9764,U+9766-9768,U+976a-976b,U+976e,U+9771,U+9773,U+9776-977d,U+977f-9781,U+9785-9786,U+9789,U+978b,U+978f-9790,U+9795-9797,U+9799-979a,U+979c,U+979e-97a0,U+97a2-97a3,U+97a6,U+97a8,U+97ab-97ac,U+97ae,U+97b1-97b6,U+97b8-97ba,U+97bc,U+97be-97bf,U+97c1,U+97c3-97ce,U+97d0-97d1,U+97d4,U+97d7-97d9,U+97db-97de,U+97e0-97e1,U+97e4,U+97e6,U+97ed-97ef,U+97f1-97f2,U+97f4-97f8,U+97fa,U+9804,U+9807,U+980a,U+980c-980f,U+9814,U+9816-9817,U+9819-981a,U+981c,U+981e,U+9820-9821,U+9823-9826,U+982b,U+982e-9830,U+9832-9835,U+9837,U+9839,U+983d-983e,U+9844,U+9846-9847,U+984a-984b,U+984f,U+9851-9853,U+9856-9857,U+9859-985b,U+9862-9863,U+9865-9866,U+986a-986c,U+986f-9871,U+9873-9875,U+98aa-98ab,U+98ad-98ae,U+98b0-98b1,U+98b4,U+98b6-98b8,U+98ba-98bc,U+98bf,U+98c2-98c8,U+98cb-98cc,U+98ce,U+98dc,U+98de,U+98e0-98e1,U+98e3,U+98e5-98e7,U+98e9-98ea),
10: (U+944a,U+944c,U+9452-9453,U+9455,U+9459-945c,U+945e-9463,U+9468,U+946a-946b,U+946d-9472,U+9475,U+9477,U+947c-947f,U+9481,U+9483-9485,U+9578-9579,U+957e-957f,U+9582,U+9584,U+9586-9588,U+958a,U+958c-958f,U+9592,U+9594,U+9596,U+9598-9599,U+959d-95a1,U+95a4,U+95a6-95a9,U+95ab-95ad,U+95b1,U+95b4,U+95b6,U+95b9-95bf,U+95c3,U+95c6,U+95c8-95cd,U+95d0-95d6,U+95d9-95da,U+95dc-95e2,U+95e4-95e6,U+95e8,U+961d-961e,U+9621-9622,U+9624-9626,U+9628,U+962c,U+962e-962f,U+9631,U+9633-9634,U+9637-963a,U+963c-963d,U+9641-9642,U+964b-964c,U+964f,U+9652,U+9654,U+9656-9658,U+965c-965f,U+9661,U+9666,U+966a,U+966c,U+966e,U+9672,U+9674,U+9677,U+967b-967c,U+967e-967f,U+9681-9684,U+9689,U+968b,U+968d,U+9691,U+9695-9698,U+969a,U+969d,U+969f,U+96a4-96aa,U+96ae-96b4,U+96b6,U+96b8-96bb,U+96bd,U+96c1,U+96c9-96cb,U+96cd-96ce,U+96d2,U+96d5-96d6,U+96d8-96da,U+96dc-96df,U+96e9,U+96ef,U+96f1,U+96f9-96fa,U+9702-9706,U+9708-9709,U+970d-970f,U+9711,U+9713-9714,U+9716,U+9719-971b),
latin: (U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD),
) !default;
"
`;
Expand Down

0 comments on commit ae11885

Please sign in to comment.