Skip to content

Commit

Permalink
feat(fonts): Prioritize woff2
Browse files Browse the repository at this point in the history
  • Loading branch information
jrood committed Jan 6, 2025
1 parent eacdd5c commit cab68fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions packages/gamut-styles/src/AssetProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { webFonts } from './remoteAssets/fonts';

export const createFontLinks = () =>
webFonts.flatMap(({ filePath, extensions }) =>
extensions.map((ext) => (
webFonts
.filter((f) => f.extensions.includes('woff2'))
.map(({ filePath }) => (
<link
key={`${filePath}-${ext}`}
key={filePath}
rel="preload"
href={`${filePath}.${ext}`}
href={`${filePath}.woff2`}
crossOrigin="anonymous"
as="font"
type={`font/${ext}`}
type="font/woff2"
/>
))
);
));

export const AssetProvider = () => {
return <>{createFontLinks()}</>;
Expand Down
12 changes: 6 additions & 6 deletions packages/gamut-styles/src/remoteAssets/fonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,37 @@ export const FONT_ASSET_PATH = `https://www.codecademy.com/gamut`;
export const webFonts = [
{
filePath: `${FONT_ASSET_PATH}/apercu-regular-pro`,
extensions: ['woff', 'woff2'],
extensions: ['woff2', 'woff'],
name: 'Apercu',
},
{
filePath: `${FONT_ASSET_PATH}/apercu-italic-pro`,
extensions: ['woff', 'woff2'],
extensions: ['woff2', 'woff'],
name: 'Apercu',
style: 'italic',
},
{
filePath: `${FONT_ASSET_PATH}/apercu-bold-pro`,
extensions: ['woff', 'woff2'],
extensions: ['woff2', 'woff'],
name: 'Apercu',
weight: 'bold',
},
{
filePath: `${FONT_ASSET_PATH}/apercu-bold-italic-pro`,
extensions: ['woff', 'woff2'],
extensions: ['woff2', 'woff'],
name: 'Apercu',
weight: 'bold',
style: 'italic',
},
{
filePath: `${FONT_ASSET_PATH}/SuisseIntlMono-Bold-WebS`,
extensions: ['woff', 'woff2'],
extensions: ['woff2', 'woff'],
name: 'Suisse',
weight: 'bold',
},
{
filePath: `${FONT_ASSET_PATH}/SuisseIntlMono-Regular-WebS`,
extensions: ['woff', 'woff2'],
extensions: ['woff2', 'woff'],
name: 'Suisse',
},
];

0 comments on commit cab68fb

Please sign in to comment.