Skip to content

Commit 3107a19

Browse files
Use system fonts everywhere except for code & self host Inconsolata (jakearchibald#339)
Co-authored-by: Jake Archibald <[email protected]>
1 parent d1fff8b commit 3107a19

File tree

13 files changed

+40
-16
lines changed

13 files changed

+40
-16
lines changed

gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const allJs = gulp.parallel(
9797

9898
function copy() {
9999
return gulp.src([
100-
'src/{.well-known,imgs,test-svgs}/**',
100+
'src/{.well-known,imgs,test-svgs,fonts}/**',
101101
// Exclude the test-svgs files except for `car-lite.svg`
102102
// which is used in the demo
103103
'!src/test-svgs/!(car-lite.svg)',
@@ -118,7 +118,7 @@ const mainBuild = gulp.parallel(
118118
function watch() {
119119
gulp.watch(['src/css/**/*.scss'], gulp.series(css, html));
120120
gulp.watch(['src/js/**/*.js'], allJs);
121-
gulp.watch(['src/*.{html,json}', 'src/**/*.svg'], gulp.parallel(html, copy, allJs));
121+
gulp.watch(['src/*.{html,json}', 'src/**/*.{svg,woff2}'], gulp.parallel(html, copy, allJs));
122122
}
123123

124124
function serve() {

src/css/_fonts.scss

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@font-face {
2+
font-family: Inconsolata;
3+
font-style: normal;
4+
font-weight: 400;
5+
font-stretch: 100%;
6+
src: url('fonts/code-vietnamese.woff2') format('woff2');
7+
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
8+
}
9+
10+
@font-face {
11+
font-family: Inconsolata;
12+
font-style: normal;
13+
font-weight: 400;
14+
font-stretch: 100%;
15+
src: url('fonts/code-latin-ext.woff2') format('woff2');
16+
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
17+
}
18+
19+
@font-face {
20+
font-family: Inconsolata;
21+
font-style: normal;
22+
font-weight: 400;
23+
font-stretch: 100%;
24+
src: url('fonts/code-latin.woff2') format('woff2');
25+
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
26+
}

src/css/_global.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ body {
77
}
88

99
html {
10-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
11-
line-height: 1.25;
10+
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Liberation Sans', sans-serif;
11+
font-size: 1rem;
12+
line-height: 1.3;
1213
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
1314

1415
// <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 2"><path d="M1 2V0h1v1H0v1z" fill-opacity=".05"/></svg>
@@ -21,8 +22,7 @@ code,
2122
kbd,
2223
samp,
2324
tt {
24-
// stylelint-disable-next-line font-family-no-duplicate-names
25-
font-family: monospace, monospace;
25+
font-family: SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
2626
font-size: 1em;
2727
}
2828

src/css/components/_code-output.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
}
2121

2222
code {
23-
font-family: Inconsolata, monospace;
23+
font-family: Inconsolata, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
2424
line-height: 1.5;
2525
font-size: 0.9rem;
2626
display: block;

src/css/components/_main-menu.scss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
bottom: 0;
66
right: 0;
77
z-index: 3;
8-
font-family: sans-serif;
98

109
&.hidden {
1110
pointer-events: none;
@@ -170,7 +169,7 @@
170169
}
171170

172171
h1 {
173-
font-size: inherit;
172+
font-size: 1rem;
174173
margin: 0;
175174
}
176175

@@ -194,5 +193,5 @@
194193
.title-text {
195194
display: grid;
196195
grid-template-rows: max-content max-content;
197-
gap: 0.1em;
196+
gap: 0.2em;
198197
}

src/css/components/_material-slider.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
text-align: center;
4848
width: 100%;
4949
line-height: 1;
50-
font-size: 0.8rem;
50+
font-size: 0.85rem;
5151
opacity: 0;
5252
transition: opacity 0.1s ease-out;
5353
transform: translateZ(0);

src/css/components/_preloader.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
z-index: 3;
99
color: #fff;
1010
opacity: 0;
11-
font-family: sans-serif;
1211
display: flex;
1312
flex-flow: column;
1413
align-items: center;

src/css/head.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@import 'fonts';
12
@import 'utils';
23
@import 'global';
34
@import 'components/main-menu';

src/fonts/code-latin-ext.woff2

9.91 KB
Binary file not shown.

src/fonts/code-latin.woff2

11.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)