Skip to content

Commit

Permalink
fix(website): generate css using subsets if no unicode keys found (#930)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuhito committed Jan 11, 2024
1 parent cd47292 commit 58c2a85
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions website/app/routes/fonts.$id._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,17 @@ export const loader = async ({ params }: LoaderFunctionArgs) => {
}
}

const { family, weights, unicodeRange, styles } = metadata;
const { family, weights, unicodeRange, styles, subsets } = metadata;

const unicodeKeys = Object.keys(unicodeRange).map((key) =>
let unicodeKeys = Object.keys(unicodeRange).map((key) =>
key.replace('[', '').replace(']', ''),
);

// Non-google fonts have no unicode keys stored, thus we need to use the subsets
if (unicodeKeys.length === 0) {
unicodeKeys = subsets;
}

// Generate static CSS
let staticCSS = getCSSCache(`s:${id}`) as string;
if (!staticCSS) {
Expand Down

0 comments on commit 58c2a85

Please sign in to comment.