Skip to content

Commit

Permalink
fix(api): fallback missing unicode range keys to subsets (#857)
Browse files Browse the repository at this point in the history
* fix(api): fallback missing unicode range keys to subsets

* Create tall-planes-deny.md
  • Loading branch information
ayuhito committed Oct 2, 2023
1 parent ad624f9 commit 9a680f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/tall-planes-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fontsource-utils/cli": patch
---

fix(api): fallback missing unicode range keys to subsets
8 changes: 5 additions & 3 deletions packages/cli/src/google/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,15 @@ export const generateV2CSS = (
tag?: string,
): CSSGenerate => {
const cssGenerate: CSSGenerate = [];
const { id, family, styles, weights, variants, unicodeRange } = metadata;
const { id, family, styles, weights, variants, unicodeRange, subsets } =
metadata;

// Find the weight for index.css in the case weight 400 does not exist.
const indexWeight = findClosest(weights, 400);

// Generate CSS
const unicodeKeys = Object.keys(unicodeRange);
const hasUnicode = Object.keys(unicodeRange).length > 0;
const unicodeKeys = hasUnicode ? Object.keys(unicodeRange) : subsets;

for (const weight of weights) {
for (const style of styles) {
Expand All @@ -171,7 +173,7 @@ export const generateV2CSS = (
style,
display: 'swap',
weight,
unicodeRange: unicodeRange[subset],
unicodeRange: hasUnicode ? unicodeRange[subset] : undefined,
src: [
{
url: makeFontFilePath(
Expand Down

0 comments on commit 9a680f3

Please sign in to comment.