-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xWidthAvg: Add
subset
support for non-latin character sets (#177)
- Loading branch information
1 parent
9ac622e
commit 879208b
Showing
14 changed files
with
29,048 additions
and
1,654 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
'@capsizecss/core': minor | ||
'@capsizecss/metrics': minor | ||
'@capsizecss/unpack': minor | ||
--- | ||
|
||
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. | ||
|
||
```diff | ||
{ | ||
"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: | ||
|
||
```ts | ||
const { fontFamily, fontFaces } = createFontStack( | ||
[lobster, arial], | ||
{ | ||
subset: 'thai', | ||
}, | ||
); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.