Update build scripts

This commit is contained in:
Miguel Sousa 2019-06-09 22:36:44 -07:00 committed by Miguel Sousa
parent 179f296d7e
commit db570b60e6
2 changed files with 108 additions and 65 deletions

View File

@ -1,35 +1,64 @@
#!/usr/bin/env sh
family=SourceCodePro
romanWeights='Black Bold ExtraLight Light Medium Regular Semibold'
italicWeights='BlackIt BoldIt ExtraLightIt LightIt MediumIt It SemiboldIt'
roman_weights=(Black Bold ExtraLight Light Medium Regular Semibold)
italic_weights=(BlackIt BoldIt ExtraLightIt LightIt MediumIt It SemiboldIt)
# path to Python script that adds the SVG table
addSVG=$(cd $(dirname "$0") && pwd -P)/addSVGtable.py
# path to UVS file
UVS=$(cd $(dirname "$0") && pwd -P)/uvs.txt
# get absolute path to bash script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
# clean existing build artifacts
rm -rf target/
otfDir="target/OTF"
ttfDir="target/TTF"
mkdir -p $otfDir $ttfDir
rm -rf "$DIR/target/"
otf_dir="$DIR/target/OTF"
ttf_dir="$DIR/target/TTF"
mkdir -p "$otf_dir" "$ttf_dir"
for w in $romanWeights
# path to Python script that adds the SVG table
addSVG="$DIR"/addSVGtable.py
# path to UVS file
UVS="$DIR"/uvs.txt
function build_font {
# $1 is Roman or Italic
# $2 is weight name
font_dir="$DIR"/$1/Instances/$2
font_ufo="$font_dir"/font.ufo
font_ttf="$font_dir"/font.ttf
ps_name=$family-$2
echo $ps_name
echo "Building OTF ..."
# -r is for "release mode" (subroutinization + applied glyph order)
makeotf -f "$font_ufo" -r -ci "$UVS"
echo "Building TTF ..."
makeotf -f "$font_ttf" -r -ci "$UVS" -ff "$font_ufo"/features.fea
echo "Adding SVG table ..."
"$addSVG" "$font_dir"/$ps_name.otf "$DIR"/svg
# copy SVG and DSIG tables from OTF to TTF
sfntedit -x DSIG="$font_dir"/.tb_DSIG,SVG="$font_dir"/.tb_SVG "$font_dir"/$ps_name.otf
sfntedit -a DSIG="$font_dir"/.tb_DSIG,SVG="$font_dir"/.tb_SVG "$font_dir"/$ps_name.ttf
# delete build artifacts
rm "$font_dir"/.tb_*
# move font files to target directory
mv "$font_dir"/$ps_name.otf "$otf_dir"
mv "$font_dir"/$ps_name.ttf "$ttf_dir"
echo "Done with $ps_name"
echo ""
echo ""
}
for w in ${roman_weights[@]}
do
font_path=Roman/Instances/$w/font
makeotf -f $font_path.ufo -r -ci "$UVS" -o $otfDir/$family-$w.otf
makeotf -f $font_path.ttf -r -ci "$UVS" -o $ttfDir/$family-$w.ttf -ff $font_path.ufo/features.fea
"$addSVG" $otfDir/$family-$w.otf svg
"$addSVG" $ttfDir/$family-$w.ttf svg
build_font Roman $w
done
for w in $italicWeights
for w in ${italic_weights[@]}
do
font_path=Italic/Instances/$w/font
makeotf -f $font_path.ufo -r -ci "$UVS" -o $otfDir/$family-$w.otf
makeotf -f $font_path.ttf -r -ci "$UVS" -o $ttfDir/$family-$w.ttf -ff $font_path.ufo/features.fea
"$addSVG" $otfDir/$family-$w.otf svg
"$addSVG" $ttfDir/$family-$w.ttf svg
build_font Italic $w
done

View File

@ -1,55 +1,69 @@
#!/usr/bin/env sh
# path to Python script that adds the SVG table
addSVG=$(cd $(dirname "$0") && pwd -P)/addSVGtable.py
# path to UVS file
UVS=$(cd $(dirname "$0") && pwd -P)/uvs.txt
rom=Roman/Masters
itm=Italic/Masters
ro_name=SourceCodeVariable-Roman
it_name=SourceCodeVariable-Italic
# build variable OTFs
buildmasterotfs --mkot -ci,"$UVS" $rom/$ro_name.designspace
buildcff2vf $rom/$ro_name.designspace
buildmasterotfs --mkot -ci,"$UVS" $itm/$it_name.designspace
buildcff2vf $itm/$it_name.designspace
# get absolute path to bash script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
# extract and subroutinize the CFF2 table
echo 'Subroutinizing' $rom/$ro_name.otf
tx -cff2 +S +b -std $rom/$ro_name.otf $rom/.tb_cff2 2> /dev/null
echo 'Subroutinizing' $itm/$it_name.otf
tx -cff2 +S +b -std $itm/$it_name.otf $itm/.tb_cff2 2> /dev/null
# clean existing build artifacts
var_dir="$DIR"/target/VAR
rm -rf "$var_dir"
mkdir -p "$var_dir"
# replace CFF2 table with subroutinized version
sfntedit -a CFF2=$rom/.tb_cff2 $rom/$ro_name.otf 1> /dev/null
sfntedit -a CFF2=$itm/.tb_cff2 $itm/$it_name.otf 1> /dev/null
# path to Python script that adds the SVG table
addSVG="$DIR"/addSVGtable.py
# add SVG table to variable OTFs
"$addSVG" $rom/$ro_name.otf svg
"$addSVG" $itm/$it_name.otf svg
# path to UVS file
UVS="$DIR"/uvs.txt
# build variable TTFs
fontmake -m $rom/$ro_name.designspace -o variable --production-names
fontmake -m $itm/$it_name.designspace -o variable --production-names
# use cmap, DSIG, name, OS/2, hhea, post, SVG, and STAT tables from OTFs
sfntedit -x cmap=$rom/.tb_cmap,DSIG=$rom/.tb_DSIG,name=$rom/.tb_name,OS/2=$rom/.tb_os2,hhea=$rom/.tb_hhea,post=$rom/.tb_post,SVG=$rom/.tb_SVG,STAT=$rom/.tb_STAT $rom/$ro_name.otf 1> /dev/null
sfntedit -a cmap=$rom/.tb_cmap,DSIG=$rom/.tb_DSIG,name=$rom/.tb_name,OS/2=$rom/.tb_os2,hhea=$rom/.tb_hhea,post=$rom/.tb_post,SVG=$rom/.tb_SVG,STAT=$rom/.tb_STAT $rom/$ro_name.ttf 1> /dev/null
sfntedit -x cmap=$itm/.tb_cmap,DSIG=$itm/.tb_DSIG,name=$itm/.tb_name,OS/2=$itm/.tb_os2,hhea=$itm/.tb_hhea,post=$itm/.tb_post,SVG=$itm/.tb_SVG,STAT=$itm/.tb_STAT $itm/$it_name.otf 1> /dev/null
sfntedit -a cmap=$itm/.tb_cmap,DSIG=$itm/.tb_DSIG,name=$itm/.tb_name,OS/2=$itm/.tb_os2,hhea=$itm/.tb_hhea,post=$itm/.tb_post,SVG=$itm/.tb_SVG,STAT=$itm/.tb_STAT $itm/$it_name.ttf 1> /dev/null
function build_var_font {
# $1 is Master directory
# $2 is font name
echo $2
# use GDEF, GPOS, and GSUB tables from TTFs
sfntedit -x GDEF=$rom/.tb_GDEF,GPOS=$rom/.tb_GPOS,GSUB=$rom/.tb_GSUB $rom/$ro_name.ttf 1> /dev/null
sfntedit -a GDEF=$rom/.tb_GDEF,GPOS=$rom/.tb_GPOS,GSUB=$rom/.tb_GSUB $rom/$ro_name.otf 1> /dev/null
sfntedit -x GDEF=$itm/.tb_GDEF,GPOS=$itm/.tb_GPOS,GSUB=$itm/.tb_GSUB $itm/$it_name.ttf 1> /dev/null
sfntedit -a GDEF=$itm/.tb_GDEF,GPOS=$itm/.tb_GPOS,GSUB=$itm/.tb_GSUB $itm/$it_name.otf 1> /dev/null
otf_file="$1"/$2.otf
ttf_file="$1"/$2.ttf
dsp_file="$1"/$2.designspace
# delete build artifacts
rm */Masters/.tb_*
rm */Masters/master_*/*.*tf
# build variable OTF
buildmasterotfs --mkot -ci,"$UVS" "$dsp_file"
buildcff2vf --omit-mac-names -d "$dsp_file"
echo "Done"
# extract and subroutinize the CFF2 table
echo 'Subroutinizing' $2.otf
tx -cff2 +S +b -std "$otf_file" "$1"/.tb_cff2 2> /dev/null
# replace CFF2 table with subroutinized version
sfntedit -a CFF2="$1"/.tb_cff2 "$otf_file"
# add SVG table to variable OTF
"$addSVG" "$otf_file" "$DIR"/svg
# build variable TTF
fontmake -m "$dsp_file" -o variable --production-names --output-path "$ttf_file" --feature-writer None
# use DSIG, name, OS/2, hhea, post, SVG, and STAT tables from OTFs
sfntedit -x DSIG="$1"/.tb_DSIG,name="$1"/.tb_name,OS/2="$1"/.tb_os2,hhea="$1"/.tb_hhea,post="$1"/.tb_post,SVG="$1"/.tb_SVG,STAT="$1"/.tb_STAT "$otf_file"
sfntedit -a DSIG="$1"/.tb_DSIG,name="$1"/.tb_name,OS/2="$1"/.tb_os2,hhea="$1"/.tb_hhea,post="$1"/.tb_post,SVG="$1"/.tb_SVG,STAT="$1"/.tb_STAT "$ttf_file"
# use cmap, GDEF, GPOS, and GSUB tables from TTFs
sfntedit -x cmap="$1"/.tb_cmap,GDEF="$1"/.tb_GDEF,GPOS="$1"/.tb_GPOS,GSUB="$1"/.tb_GSUB "$ttf_file"
sfntedit -a cmap="$1"/.tb_cmap,GDEF="$1"/.tb_GDEF,GPOS="$1"/.tb_GPOS,GSUB="$1"/.tb_GSUB "$otf_file"
# move font files to target directory
mv "$otf_file" "$var_dir"
mv "$ttf_file" "$var_dir"
# delete build artifacts
rm "$1"/.tb_*
rm "$1"/master_*/*.*tf
echo "Done with $2"
echo ""
echo ""
}
build_var_font "$DIR"/Roman/Masters $ro_name
build_var_font "$DIR"/Italic/Masters $it_name