Skip to content

Commit

Permalink
load all fonts locally
Browse files Browse the repository at this point in the history
  • Loading branch information
Holtz Yan authored and Holtz Yan committed Sep 26, 2023
1 parent 4b55c2a commit 9052d18
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
40 changes: 40 additions & 0 deletions gatsby-ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,45 @@ export const onRenderBody = ({ setHeadComponents }) => {
crossOrigin="anonymous"
key="robotoRegular"
/>,
<link
rel="preload"
href="/fonts/roboto-v30-latin/roboto-v30-latin-italic.woff2"
as="font"
type="font/woff2"
crossOrigin="anonymous"
key="robotoItalic"
/>,
<link
rel="preload"
href="/fonts/roboto-v30-latin/roboto-v30-latin-700.woff2"
as="font"
type="font/woff2"
crossOrigin="anonymous"
key="roboto700"
/>,
<link
rel="preload"
href="/fonts/bitter-v33-latin/bitter-v33-latin-regular.woff2"
as="font"
type="font/woff2"
crossOrigin="anonymous"
key="bitterRegular"
/>,
<link
rel="preload"
href="/fonts/bitter-v33-latin/bitter-v33-latin-italic.woff2"
as="font"
type="font/woff2"
crossOrigin="anonymous"
key="bitterItalic"
/>,
<link
rel="preload"
href="/fonts/bitter-v33-latin/bitter-v33-latin-700.woff2"
as="font"
type="font/woff2"
crossOrigin="anonymous"
key="bitter700"
/>,
]);
};
14 changes: 8 additions & 6 deletions src/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ gatsby tutorial: https://www.gatsbyjs.com/docs/how-to/styling/using-local-fonts/
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(fonts/roboto-v30-latin/roboto-v30-latin-regular.woff2)
src: url(/fonts/roboto-v30-latin/roboto-v30-latin-regular.woff2)
format('woff2');
}
/* roboto-italic - latin */
Expand All @@ -48,23 +48,24 @@ gatsby tutorial: https://www.gatsbyjs.com/docs/how-to/styling/using-local-fonts/
font-family: 'Roboto';
font-style: italic;
font-weight: 400;
src: url(fonts/roboto-v30-latin/roboto-v30-latin-italic.woff2) format('woff2');
src: url(/fonts/roboto-v30-latin/roboto-v30-latin-italic.woff2)
format('woff2');
}
/* roboto-700 - latin */
@font-face {
font-display: swap;
font-family: 'Roboto';
font-style: normal;
font-weight: 700;
src: url(fonts/roboto-v30-latin/roboto-v30-latin-700.woff2) format('woff2');
src: url(/fonts/roboto-v30-latin/roboto-v30-latin-700.woff2) format('woff2');
}
/* bitter-regular - latin */
@font-face {
font-display: swap;
font-family: 'Bitter';
font-style: normal;
font-weight: 400;
src: url(fonts/bitter-v33-latin/bitter-v33-latin-regular.woff2)
src: url(/fonts/bitter-v33-latin/bitter-v33-latin-regular.woff2)
format('woff2');
}
/* bitter-italic - latin */
Expand All @@ -73,15 +74,16 @@ gatsby tutorial: https://www.gatsbyjs.com/docs/how-to/styling/using-local-fonts/
font-family: 'Bitter';
font-style: italic;
font-weight: 400;
src: url(fonts/bitter-v33-latin/bitter-v33-latin-italic.woff2) format('woff2');
src: url(/fonts/bitter-v33-latin/bitter-v33-latin-italic.woff2)
format('woff2');
}
/* bitter-700 - latin */
@font-face {
font-display: swap;
font-family: 'Bitter';
font-style: normal;
font-weight: 700;
src: url(fonts/bitter-v33-latin/bitter-v33-latin-700.woff2) format('woff2');
src: url(/fonts/bitter-v33-latin/bitter-v33-latin-700.woff2) format('woff2');
}

/* ---------- Global CSS ----------------- */
Expand Down

0 comments on commit 9052d18

Please sign in to comment.