1
1
mirror of https://github.com/i-tu/Hasklig.git synced 2024-09-11 10:36:46 +03:00
Hasklig/buildVFs.sh

63 lines
1.9 KiB
Bash
Raw Normal View History

#!/usr/bin/env sh
2019-06-10 08:36:44 +03:00
ro_name=SourceCodeVariable-Roman
it_name=SourceCodeVariable-Italic
# get absolute path to bash script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
# clean existing build artifacts
var_dir=$DIR/target/VAR
rm -rf $var_dir
mkdir -p $var_dir
2017-08-09 10:10:35 +03:00
2017-07-26 10:25:55 +03:00
2019-06-10 08:36:44 +03:00
function build_var_font {
# $1 is Master directory
# $2 is font name
echo $2
# build variable OTF
# --mkot gs is for using the makeotf option -gs, which omits glyphs not in the GOADB
buildmasterotfs --mkot gs -d $1/$2.designspace
buildcff2vf -d $1/$2.designspace
2019-06-10 08:36:44 +03:00
# extract and subroutinize the CFF2 table
echo 'Subroutinizing' $2.otf
tx -cff2 +S +b -std $1/$2.otf $1/.tb_cff2 2> /dev/null
2019-06-10 08:36:44 +03:00
# replace CFF2 table with subroutinized version
sfntedit -a CFF2=$1/.tb_cff2 $1/$2.otf
2019-06-10 08:36:44 +03:00
# comment out STAT feature file which cannot be digested by fontmake
sed -i '' 's/^/#/' $1/STAT.fea
2019-06-10 08:36:44 +03:00
# build variable TTF
fontmake -m $1/$2.designspace -o variable --production-names --output-path $1/$2.ttf
2019-06-10 08:36:44 +03:00
# use DSIG, name, OS/2, hhea, post, 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,STAT=$1/.tb_STAT,fvar=$1/.tb_fvar $1/$2.otf
sfntedit -a DSIG=$1/.tb_DSIG,name=$1/.tb_name,OS/2=$1/.tb_os2,hhea=$1/.tb_hhea,post=$1/.tb_post,STAT=$1/.tb_STAT,fvar=$1/.tb_fvar $1/$2.ttf
2019-06-10 08:36:44 +03:00
# 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 $1/$2.ttf
sfntedit -a cmap=$1/.tb_cmap,GDEF=$1/.tb_GDEF,GPOS=$1/.tb_GPOS,GSUB=$1/.tb_GSUB $1/$2.otf
2019-06-10 08:36:44 +03:00
# move font files to target directory
mv $1/$2.otf $var_dir
mv $1/$2.ttf $var_dir
2019-06-10 08:36:44 +03:00
# delete build artifacts
rm $1/.tb_*
rm $1/master_*/*.*tf
# undo changes to STAT feature file
sed -i '' 's/#//' $1/STAT.fea
2019-06-10 08:36:44 +03:00
echo "Done with $2"
echo ""
echo ""
2019-06-10 08:36:44 +03:00
}
2017-07-26 10:25:55 +03:00
build_var_font $DIR/Roman/Masters $ro_name
build_var_font $DIR/Italic/Masters $it_name