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

xWidthAvg: Add subset support for non-latin character sets #177

Merged
merged 53 commits into from
Mar 8, 2024

Conversation

michaeltaranto
Copy link
Contributor

@michaeltaranto michaeltaranto commented Feb 27, 2024

xWidthAvg: Add subset support for non-latin character sets

Previously the xWidthAvg metric was calculated based on the character frequency as measured from English text only.
This resulted in the xWidthAvg metric being incorrect for languages that use a different unicode subset range, e.g. Thai.

Supporting Thai now enables adding support for other unicode ranges in the future.

What's changed?

@capsizecss/metrics

The subsets field has been added to the metrics object, providing the xWidthAvg metric for each subset — calculated against the relevant character frequency data.

 {
   "familyName": "Abril Fatface",
   ...
+  "subsets": {
+    "latin": {
+      "xWidthAvg": 512
+    },
+    "thai": {
+      "xWidthAvg": 200
+    }
+  }
 }

There are no changes to any of the other existing metrics.

@capsizecss/core

Fallback font stacks can now be generated per subset, allowing the correct xWidthAvg metric to be used for the relevant subset.

The createFontStack API now accepts subset as an option:

const { fontFamily, fontFaces } = createFontStack(
  [lobster, arial],
  {
    subset: 'thai',
  },
);

@michaeltaranto michaeltaranto requested a review from a team as a code owner February 27, 2024 02:51
Copy link

changeset-bot bot commented Feb 27, 2024

🦋 Changeset detected

Latest commit: 9d7ae2f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@capsizecss/core Minor
@capsizecss/metrics Minor
@capsizecss/unpack Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

@askoufis askoufis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

packages/unpack/README.md Outdated Show resolved Hide resolved
packages/unpack/scripts/generate-weightings.ts Outdated Show resolved Hide resolved
site/src/components/FontSelector/SystemFontSelector.tsx Outdated Show resolved Hide resolved
packages/metrics/scripts/analyse.ts Outdated Show resolved Hide resolved
packages/metrics/README.md Show resolved Hide resolved
packages/metrics/README.md Outdated Show resolved Hide resolved
.changeset/pink-plants-develop.md Outdated Show resolved Hide resolved
.changeset/pink-plants-develop.md Outdated Show resolved Hide resolved
packages/metrics/scripts/generate.ts Outdated Show resolved Hide resolved
michaeltaranto and others added 2 commits February 28, 2024 08:41
Co-authored-by: Adam Skoufis <askoufis@users.noreply.github.com>
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
packages/metrics/README.md Outdated Show resolved Hide resolved
packages/unpack/scripts/generate-weightings.ts Outdated Show resolved Hide resolved
Co-authored-by: Adam Skoufis <askoufis@users.noreply.github.com>
@michaeltaranto michaeltaranto merged commit 879208b into master Mar 8, 2024
6 checks passed
@michaeltaranto michaeltaranto deleted the add-subset-support branch March 8, 2024 03:33
@seek-oss-ci seek-oss-ci mentioned this pull request Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants