| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# This script copies the latest builds to the google fonts dir in order to run QA checks and prep for a PR |
| 4 |
# |
| 5 |
# USAGE: |
| 6 |
# Install requirements with `pip install -U -r googlefonts-qa/requirements.txt` |
| 7 |
# |
| 8 |
# call this script from the root of your fira code repo, with the absolute path your your local google/fonts repo |
| 9 |
# `move-check <your_username>/<path>/fonts` |
| 10 |
|
| 11 |
set -ex |
| 12 |
source venv/bin/activate |
| 13 |
gFontsDir=$1 |
| 14 |
|
| 15 |
if [[ -z "$gFontsDir" || $gFontsDir = "--help" ]] ; then |
| 16 |
echo 'Add absolute path to your Google Fonts Git directory, like:' |
| 17 |
echo 'googlefonts-qa/scripts/move-check.sh /Users/your-username/type-repos/google-font-repos/fonts' |
| 18 |
exit 2 |
| 19 |
fi |
| 20 |
|
| 21 |
firaCodeDir=$(pwd) |
| 22 |
|
| 23 |
firaCodeQADir=$firaCodeDir/googlefonts-qa |
| 24 |
|
| 25 |
firaCodeVF=$firaCodeDir/distr/variable_ttf/FiraCode-VF.ttf |
| 26 |
|
| 27 |
|
| 28 |
# ------------------------------------------------------------------- |
| 29 |
# get latest version ------------------------------------------------ |
| 30 |
|
| 31 |
ttx -t head $firaCodeVF |
| 32 |
fontVersion=v$(xml sel -t --match "//*/fontRevision" -v "@value" ${firaCodeVF/".ttf"/".ttx"}) |
| 33 |
rm ${firaCodeVF/".ttf"/".ttx"} |
| 34 |
|
| 35 |
# ------------------------------------------------------------------- |
| 36 |
# navigate to google/fonts repo, then fira code branch -------------- |
| 37 |
|
| 38 |
cd $gFontsDir |
| 39 |
git checkout master |
| 40 |
git pull upstream master |
| 41 |
git reset --hard |
| 42 |
git checkout -B firacode |
| 43 |
git clean -f -d |
| 44 |
|
| 45 |
# ------------------------------------------------------------------- |
| 46 |
# move fonts -------------------------------------------------------- |
| 47 |
|
| 48 |
mkdir -p ofl/firacode |
| 49 |
|
| 50 |
cp $firaCodeVF "ofl/firacode/FiraCode-Light.ttf" |
| 51 |
|
| 52 |
mkdir -p ofl/firacode/static |
| 53 |
statics=$(ls $firaCodeDir/distr/ttf/*.ttf) |
| 54 |
for ttf in $statics |
| 55 |
do |
| 56 |
cp $ttf ofl/firacode/static/$(basename $ttf) |
| 57 |
done |
| 58 |
|
| 59 |
# ------------------------------------------------------------------- |
| 60 |
# make or move basic metadata --------------------------------------- |
| 61 |
|
| 62 |
cp $firaCodeDir/googlefonts-qa/METADATA.pb ofl/firacode/METADATA.pb |
| 63 |
|
| 64 |
cp $firaCodeDir/LICENSE ofl/firacode/OFL.txt |
| 65 |
|
| 66 |
cp $firaCodeQADir/gfonts-description.html ofl/firacode/DESCRIPTION.en_us.html |
| 67 |
|
| 68 |
# ------------------------------------------------------------------- |
| 69 |
# run checks, saving to firacode/googlefonts-qa/checks ------------ |
| 70 |
|
| 71 |
set +e # otherwise, the script stops after the first fontbakery check output |
| 72 |
|
| 73 |
mkdir -p $firaCodeQADir/checks/static |
| 74 |
|
| 75 |
cd ofl/firacode |
| 76 |
|
| 77 |
ttfs=$(ls -R */*.ttf && ls *.ttf) # use this to statics and VFs |
| 78 |
# ttfs=$(ls *.ttf) # use this to check only the VFs |
| 79 |
# ttfs=$(ls -R */*.ttf ) # use this to check only statics |
| 80 |
|
| 81 |
for ttf in $ttfs |
| 82 |
do |
| 83 |
echo $ttf |
| 84 |
fontbakery check-googlefonts $ttf --ghmarkdown $firaCodeQADir/checks/${ttf/".ttf"/".checks.md"} |
| 85 |
done |
| 86 |
|
| 87 |
git add . |
| 88 |
git commit -m "fira code: $fontVersion added." |
| 89 |
|
| 90 |
git push --force upstream firacode |