2019-01-08 00:11:20 -05:00
|
|
|
#!/bin/bash
|
|
|
|
# Prepares build environment
|
|
|
|
#
|
|
|
|
# Copyright (C) 2019 Mike Gerwitz
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
# This will also download any necessary third-party files. Note that all
|
|
|
|
# downloads are proxied over Tor (using `torify').
|
|
|
|
##
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
Source Sans Pro => Open Sans
This goes back to Open Sans, which is what I was using previously.
I really like Source Sans Pro. Unfortunately, the font rendered far too
small relative to other sans-serif fonts, which caused an unpleasent
experience for both slow page loads (e.g. over Tor or slower
connections) and for users with web fonts disabled (e.g. via NoScript).
Further, the font is huge: the WOFF is over 100KiB per font, and I was
using regular and light versions. Open Sans, in contrast, is <20KiB per
font, allowing me to use Regular, Light, and SemiBold and still be about
half the size of the single Source Sans Pro Regular.
As a bonus, users may also already have Open Sans installed on their
system.
I settled with WOFF instead of WOFF2 for browser support.
The site now looks pretty close on fallback, which is good. For
example, I use DejaVu Sans as my default font, and it even has a Light
version that renders correctly.
As with all resources on my site, I host this from my own domain rather
than via Google's servers. That means that the font won't be cached for
users when they first visit the site, but that's okay---privacy is more
important.
I should note that, since I use NoScript, I almost never load web fonts
for other sites. But I still wanted to try to provide a consistent look
across systems for those who do wish to load fonts.
2019-01-11 01:54:01 -05:00
|
|
|
# Source fonts (Apache 2.0)
|
|
|
|
declare -rA fonts=(
|
|
|
|
[OpenSans-Regular.woff]=https://fonts.gstatic.com/s/opensans/v15/mem8YaGs126MiZpBA-UFVZ0d.woff
|
|
|
|
[OpenSans-Light.woff]=https://fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN_r8OUuhv.woff
|
|
|
|
[OpenSans-SemiBold.woff]=https://fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UNirkOUuhv.woff
|
2019-01-08 00:11:20 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
declare -r tpimagesdir=images/tp
|
|
|
|
declare -r fontdir=fonts
|
|
|
|
|
|
|
|
|
|
|
|
# Download third-party images. This not only keeps them out of the
|
|
|
|
# repository, but explicitly states in a reproducible manner how the images
|
|
|
|
# were manipulated (if at all).
|
|
|
|
get-images()
|
|
|
|
{
|
|
|
|
echo 'retrieving third-party images...'
|
|
|
|
|
|
|
|
( cd "$tpimagesdir" && ./gen-makefile > Makefile )
|
|
|
|
make -C "$tpimagesdir" all check
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Download and verify fonts and license.
|
|
|
|
get-fonts()
|
|
|
|
{
|
Source Sans Pro => Open Sans
This goes back to Open Sans, which is what I was using previously.
I really like Source Sans Pro. Unfortunately, the font rendered far too
small relative to other sans-serif fonts, which caused an unpleasent
experience for both slow page loads (e.g. over Tor or slower
connections) and for users with web fonts disabled (e.g. via NoScript).
Further, the font is huge: the WOFF is over 100KiB per font, and I was
using regular and light versions. Open Sans, in contrast, is <20KiB per
font, allowing me to use Regular, Light, and SemiBold and still be about
half the size of the single Source Sans Pro Regular.
As a bonus, users may also already have Open Sans installed on their
system.
I settled with WOFF instead of WOFF2 for browser support.
The site now looks pretty close on fallback, which is good. For
example, I use DejaVu Sans as my default font, and it even has a Light
version that renders correctly.
As with all resources on my site, I host this from my own domain rather
than via Google's servers. That means that the font won't be cached for
users when they first visit the site, but that's okay---privacy is more
important.
I should note that, since I use NoScript, I almost never load web fonts
for other sites. But I still wanted to try to provide a consistent look
across systems for those who do wish to load fonts.
2019-01-11 01:54:01 -05:00
|
|
|
local font src dest
|
2019-01-08 00:11:20 -05:00
|
|
|
|
|
|
|
echo 'retrieving font files...'
|
Source Sans Pro => Open Sans
This goes back to Open Sans, which is what I was using previously.
I really like Source Sans Pro. Unfortunately, the font rendered far too
small relative to other sans-serif fonts, which caused an unpleasent
experience for both slow page loads (e.g. over Tor or slower
connections) and for users with web fonts disabled (e.g. via NoScript).
Further, the font is huge: the WOFF is over 100KiB per font, and I was
using regular and light versions. Open Sans, in contrast, is <20KiB per
font, allowing me to use Regular, Light, and SemiBold and still be about
half the size of the single Source Sans Pro Regular.
As a bonus, users may also already have Open Sans installed on their
system.
I settled with WOFF instead of WOFF2 for browser support.
The site now looks pretty close on fallback, which is good. For
example, I use DejaVu Sans as my default font, and it even has a Light
version that renders correctly.
As with all resources on my site, I host this from my own domain rather
than via Google's servers. That means that the font won't be cached for
users when they first visit the site, but that's okay---privacy is more
important.
I should note that, since I use NoScript, I almost never load web fonts
for other sites. But I still wanted to try to provide a consistent look
across systems for those who do wish to load fonts.
2019-01-11 01:54:01 -05:00
|
|
|
for font in "${!fonts[@]}"; do
|
|
|
|
src=${fonts[$font]}
|
|
|
|
dest="$fontdir/$font"
|
2019-01-08 00:11:20 -05:00
|
|
|
|
|
|
|
test ! -f "$dest" || continue
|
Source Sans Pro => Open Sans
This goes back to Open Sans, which is what I was using previously.
I really like Source Sans Pro. Unfortunately, the font rendered far too
small relative to other sans-serif fonts, which caused an unpleasent
experience for both slow page loads (e.g. over Tor or slower
connections) and for users with web fonts disabled (e.g. via NoScript).
Further, the font is huge: the WOFF is over 100KiB per font, and I was
using regular and light versions. Open Sans, in contrast, is <20KiB per
font, allowing me to use Regular, Light, and SemiBold and still be about
half the size of the single Source Sans Pro Regular.
As a bonus, users may also already have Open Sans installed on their
system.
I settled with WOFF instead of WOFF2 for browser support.
The site now looks pretty close on fallback, which is good. For
example, I use DejaVu Sans as my default font, and it even has a Light
version that renders correctly.
As with all resources on my site, I host this from my own domain rather
than via Google's servers. That means that the font won't be cached for
users when they first visit the site, but that's okay---privacy is more
important.
I should note that, since I use NoScript, I almost never load web fonts
for other sites. But I still wanted to try to provide a consistent look
across systems for those who do wish to load fonts.
2019-01-11 01:54:01 -05:00
|
|
|
torify wget "$src" -O "$dest"
|
2019-01-08 00:11:20 -05:00
|
|
|
done
|
|
|
|
|
|
|
|
# Verify that we haven't been served bad files. This should only happen
|
|
|
|
# in the case of network failure or a malicious host, since the above URLs
|
|
|
|
# reference the commit hash.
|
|
|
|
echo 'verifying font files...'
|
|
|
|
( cd "$fontdir" && sha512sum -c SHA512SUM )
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Bootstrap.
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
get-images
|
|
|
|
get-fonts
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
main "$@"
|