Skip to content

Replace Google Font with local variable font #1910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<link rel="stylesheet" href="/css/sintax.css?_={{ site.time | date: '%s' }}">

<link rel="stylesheet" href="/css/font-awesome.min.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700&amp;amp;subset=latin,latin-ext">
<link rel="stylesheet" href="/css/langs/{{ page.lang }}.css">

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Expand Down
120 changes: 120 additions & 0 deletions css/fonts/fonts.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 300;
src: url('open-sans-latin-ext-300-normal.woff2') format('woff2'),
url('open-sans-latin-300-normal.woff2') format('woff2'),
url('open-sans-latin-ext-300-normal.woff') format('woff'),
url('open-sans-latin-300-normal.woff') format('woff');
font-display: swap;
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 300;
src: url('open-sans-latin-ext-300-italic.woff2') format('woff2'),
url('open-sans-latin-300-italic.woff2') format('woff2'),
url('open-sans-latin-ext-300-italic.woff') format('woff'),
url('open-sans-latin-300-italic.woff') format('woff');
font-display: swap;
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: url('open-sans-latin-ext-400-normal.woff2') format('woff2'),
url('open-sans-latin-400-normal.woff2') format('woff2'),
url('open-sans-latin-ext-400-normal.woff') format('woff'),
url('open-sans-latin-400-normal.woff') format('woff');
font-display: swap;
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 400;
src: url('open-sans-latin-ext-400-italic.woff2') format('woff2'),
url('open-sans-latin-400-italic.woff2') format('woff2'),
url('open-sans-latin-ext-400-italic.woff') format('woff'),
url('open-sans-latin-400-italic.woff') format('woff');
font-display: swap;
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 500;
src: url('open-sans-latin-ext-500-normal.woff2') format('woff2'),
url('open-sans-latin-500-normal.woff2') format('woff2'),
url('open-sans-latin-ext-500-normal.woff') format('woff'),
url('open-sans-latin-500-normal.woff') format('woff');
font-display: swap;
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 500;
src: url('open-sans-latin-ext-500-italic.woff2') format('woff2'),
url('open-sans-latin-500-italic.woff2') format('woff2'),
url('open-sans-latin-ext-500-italic.woff') format('woff'),
url('open-sans-latin-500-italic.woff') format('woff');
font-display: swap;
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 600;
src: url('open-sans-latin-ext-600-normal.woff2') format('woff2'),
url('open-sans-latin-600-normal.woff2') format('woff2'),
url('open-sans-latin-ext-600-normal.woff') format('woff'),
url('open-sans-latin-600-normal.woff') format('woff');
font-display: swap;
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 600;
src: url('open-sans-latin-ext-600-italic.woff2') format('woff2'),
url('open-sans-latin-600-italic.woff2') format('woff2'),
url('open-sans-latin-ext-600-italic.woff') format('woff'),
url('open-sans-latin-600-italic.woff') format('woff');
font-display: swap;
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
src: url('open-sans-latin-ext-700-normal.woff2') format('woff2'),
url('open-sans-latin-700-normal.woff2') format('woff2'),
url('open-sans-latin-ext-700-normal.woff') format('woff'),
url('open-sans-latin-700-normal.woff') format('woff');
font-display: swap;
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 700;
src: url('open-sans-latin-ext-700-italic.woff2') format('woff2'),
url('open-sans-latin-700-italic.woff2') format('woff2'),
url('open-sans-latin-ext-700-italic.woff') format('woff'),
url('open-sans-latin-700-italic.woff') format('woff');
font-display: swap;
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 800;
src: url('open-sans-latin-ext-800-normal.woff2') format('woff2'),
url('open-sans-latin-800-normal.woff2') format('woff2'),
url('open-sans-latin-ext-800-normal.woff') format('woff'),
url('open-sans-latin-800-normal.woff') format('woff');
font-display: swap;
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 800;
src: url('open-sans-latin-ext-800-italic.woff2') format('woff2'),
url('open-sans-latin-800-italic.woff2') format('woff2'),
url('open-sans-latin-ext-800-italic.woff') format('woff'),
url('open-sans-latin-800-italic.woff') format('woff');
font-display: swap;
}
Binary file added css/fonts/open-sans-latin-300-italic.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-300-italic.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-300-normal.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-300-normal.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-400-italic.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-400-italic.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-400-normal.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-400-normal.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-500-italic.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-500-italic.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-500-normal.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-500-normal.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-600-italic.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-600-italic.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-600-normal.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-600-normal.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-700-italic.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-700-italic.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-700-normal.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-700-normal.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-800-italic.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-800-italic.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-800-normal.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-800-normal.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-300-italic.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-300-italic.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-300-normal.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-300-normal.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-400-italic.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-400-italic.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-400-normal.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-400-normal.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-500-italic.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-500-italic.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-500-normal.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-500-normal.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-600-italic.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-600-italic.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-600-normal.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-600-normal.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-700-italic.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-700-italic.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-700-normal.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-700-normal.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-800-italic.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-800-italic.woff2
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-800-normal.woff
Binary file not shown.
Binary file added css/fonts/open-sans-latin-ext-800-normal.woff2
Binary file not shown.
2 changes: 2 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import url("../fonts/open-sans/fonts.css");
Copy link
Member

@bjohansebas bjohansebas May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must be imported from the head

using @import is considered bad practice.

Copy link
Member

@ShubhamOulkar ShubhamOulkar May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re right. I was initially planning to use the {page.lang}.css file to import fonts, similar to how it's done for the Korean font. However, since the font is shared across multiple languages, it doesn’t make sense to repeat the same @font-face rule in each language-specific CSS file.

I suggest defining @font-face directly in style.css instead. WDYT?

Edit:- It is better to write @font-face rule in ko.css file.

Copy link
Member

@bjohansebas bjohansebas May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d prefer to keep the font imports separate, that file is too large. The location of the file is fine in my opinion, but it should be in the HEAD.
Edit: By the way, @ShubhamOulkar wrap font-face in backticks (` `) so we don’t ping other people unnecessarily—GitHub stuff.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be in the HEAD.

Ok, then the only option is to use one more <link>.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ShubhamOulkar @bjohansebas I've added this in HTML file

    <link 
        rel="preload" 
        href="/fonts/open-sans/OpenSans.woff2" 
        as="font" 
        type="font/woff2" 
        crossorigin 
    />
    <link 
        rel="preload" 
        href="/fonts/open-sans/OpenSans-Italic.woff2" 
        as="font" 
        type="font/woff2" 
        crossorigin 
    />
    <link
        href="/fonts/open-sans/OpenSans.woff"
        as="font"
        type="font/woff"
        crossorigin
    />
    <link
        href="/fonts/open-sans/woff/OpenSans-Italic.woff"
        as="font"
        type="font/woff"
        crossorigin
    />

We can preload woff2 since the file since is smaller, and use woff as fallback. apart from that I have also removed @imports. I've kept the fonts separate from the main style.css (so only the import line is removed).


* {
box-sizing: border-box;
-webkit-tap-highlight-color: transparent;
Expand Down
102 changes: 102 additions & 0 deletions fonts/open-sans/fonts.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@

@font-face {
font-family: "Open Sans";
font-style: normal;
font-weight: 300;
src: url("./woff2/open-sans-latin-300-normal.woff2") format("woff2"),
url("./woff/open-sans-latin-300-normal.woff") format("woff");
font-display: swap;
}
@font-face {
font-family: "Open Sans";
font-style: italic;
font-weight: 300;
src: url("./woff2/open-sans-latin-300-italic.woff2") format("woff2"),
url("./woff/open-sans-latin-300-italic.woff") format("woff");
font-display: swap;
}

@font-face {
font-family: "Open Sans";
font-style: normal;
font-weight: 400;
src: url("./woff2/open-sans-latin-400-normal.woff2") format("woff2"),
url("./woff/open-sans-latin-400-normal.woff") format("woff");
font-display: swap;
}
@font-face {
font-family: "Open Sans";
font-style: italic;
font-weight: 400;
src: url("./woff2/open-sans-latin-400-italic.woff2") format("woff2"),
url("./woff/open-sans-latin-400-italic.woff") format("woff");
font-display: swap;
}

@font-face {
font-family: "Open Sans";
font-style: normal;
font-weight: 500;
src: url("./woff2/open-sans-latin-500-normal.woff2") format("woff2"),
url("./woff/open-sans-latin-500-normal.woff") format("woff");
font-display: swap;
}
@font-face {
font-family: "Open Sans";
font-style: italic;
font-weight: 500;
src: url("./woff2/open-sans-latin-500-italic.woff2") format("woff2"),
url("./woff/open-sans-latin-500-italic.woff") format("woff");
font-display: swap;
}

@font-face {
font-family: "Open Sans";
font-style: normal;
font-weight: 600;
src: url("./woff2/open-sans-latin-600-normal.woff2") format("woff2"),
url("./woff/open-sans-latin-600-normal.woff") format("woff");
font-display: swap;
}
@font-face {
font-family: "Open Sans";
font-style: italic;
font-weight: 600;
src: url("./woff2/open-sans-latin-600-italic.woff2") format("woff2"),
url("./woff/open-sans-latin-600-italic.woff") format("woff");
font-display: swap;
}

@font-face {
font-family: "Open Sans";
font-style: normal;
font-weight: 700;
src: url("./woff2/open-sans-latin-700-normal.woff2") format("woff2"),
url("./woff/open-sans-latin-700-normal.woff") format("woff");
font-display: swap;
}
@font-face {
font-family: "Open Sans";
font-style: italic;
font-weight: 700;
src: url("./woff2/open-sans-latin-700-italic.woff2") format("woff2"),
url("./woff/open-sans-latin-700-italic.woff") format("woff");
font-display: swap;
}

@font-face {
font-family: "Open Sans";
font-style: normal;
font-weight: 800;
src: url("./woff2/open-sans-latin-800-normal.woff2") format("woff2"),
url("./woff/open-sans-latin-800-normal.woff") format("woff");
font-display: swap;
}
@font-face {
font-family: "Open Sans";
font-style: italic;
font-weight: 800;
src: url("./woff2/open-sans-latin-800-italic.woff2") format("woff2"),
url("./woff/open-sans-latin-800-italic.woff") format("woff");
font-display: swap;
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading