mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 02:57:52 +08:00
b49523345e
Upsides: - Removing the render-blocking fonts.css allows the page to be visible while the font is being loaded. - The original WOFF2 files are smaller than the base64-encoded version in fonts.css. - Browsers may be smart enough to not download fonts that are not needed. The only downside is that this requires the browser to make more requests - up to 6 for all 6 font files. But this is not a problem with modern browsers.
30 lines
1.1 KiB
Plaintext
30 lines
1.1 KiB
Plaintext
# Download the fonts needed by the website and downsize them by subsetting.
|
|
#
|
|
# External dependencies:
|
|
# curl: for downloading files
|
|
# fonttools: for processing font files
|
|
|
|
# Subset of glyphs to include, other than ASCII. Discovered with:
|
|
#
|
|
# cat **.html | go run ./cmd/runefreq | sort -nr
|
|
var subset = …’“”
|
|
|
|
mkdir -p _fonts_tmp
|
|
pwd=_fonts_tmp {
|
|
@ssp-files-base = SourceSerif4-{Regular It Semibold SemiboldIt}
|
|
for base $ssp-files-base {
|
|
curl -C - -L -o $base.otf -s https://github.com/adobe-fonts/source-serif/raw/release/OTF/$base.otf
|
|
}
|
|
@fm-files-base = FiraMono-{Regular Bold}
|
|
for base $fm-files-base {
|
|
curl -C - -L -o $base.otf -s https://github.com/mozilla/Fira/raw/master/otf/$base.otf
|
|
}
|
|
|
|
for base [$@ssp-files-base $@fm-files-base] {
|
|
# For some reason I don't understand, without U+386, the space (U+20) in
|
|
# Fira Mono will be more narrow than other glyphs, so we keep it.
|
|
fonttools subset $base.otf --output-file=../fonts/$base.woff2 --flavor=woff2 --with-zopfli ^
|
|
--unicodes=00-7f,386 --text=$subset --layout-features-=dnom,frac,locl,numr --name-IDs=
|
|
}
|
|
}
|