build.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/sh
  2. set -e
  3. # Go the sources directory to run commands
  4. SOURCE="${BASH_SOURCE[0]}"
  5. DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
  6. cd $DIR
  7. echo $(pwd)
  8. rm -rf master_ufo/ instance_ufo/ instance_ufos/*
  9. rm -rf ../fonts
  10. echo "Generating Static fonts"
  11. mkdir -p ../fonts
  12. fontmake --expand-features-to-instances -m OpenSans-Roman.designspace -i -o ttf --output-dir ../fonts/ttf/
  13. fontmake --expand-features-to-instances -m OpenSans-Italic.designspace -i -o ttf --output-dir ../fonts/ttf/
  14. echo "Generating VFs"
  15. mkdir -p ../fonts/variable
  16. fontmake -m OpenSans-Roman.designspace -o variable --output-path "../fonts/variable/OpenSans[wdth,wght].ttf"
  17. fontmake -m OpenSans-Italic.designspace -o variable --output-path "../fonts/variable/OpenSans-Italic[wdth,wght].ttf"
  18. rm -rf master_ufo/ instance_ufo/ instance_ufos
  19. echo "Discard Thin for now (extrapolated Hebrew)"
  20. rm ../fonts/ttf/*Thin*.ttf
  21. # rm ../fonts/otf/*Thin*.otf
  22. fonttools varLib.instancer -o ../fonts/variable/OpenSans[wdth,wght].ttf ../fonts/variable/OpenSans[wdth,wght].ttf "wght=300:800"
  23. fonttools varLib.instancer -o ../fonts/variable/OpenSans-Italic[wdth,wght].ttf ../fonts/variable/OpenSans-Italic[wdth,wght].ttf "wght=300:800"
  24. echo "Post processing Static fonts"
  25. ttfs=$(ls ../fonts/ttf/*.ttf)
  26. for ttf in $ttfs
  27. do
  28. gftools fix-dsig -f $ttf;
  29. # python3 -m ttfautohint $ttf "$ttf.fix"; readd this once libc issue on M1 mac is fixed
  30. ttfautohint $ttf "$ttf.fix";
  31. mv "$ttf.fix" $ttf;
  32. gftools fix-hinting $ttf;
  33. mv "$ttf.fix" $ttf;
  34. done
  35. vfs=$(ls ../fonts/variable/*.ttf)
  36. echo "Post processing VFs"
  37. for vf in $vfs
  38. do
  39. gftools fix-dsig -f $vf;
  40. # ./ttfautohint-vf --stem-width-mode nnn $vf "$vf.fix";
  41. #
  42. # mv "$vf.fix" $vf;
  43. done
  44. echo "Dropping MVAR"
  45. for vf in $vfs
  46. do
  47. # mv "$vf.fix" $vf;
  48. ttx -f -x "MVAR" $vf; # Drop MVAR. Table has issue in DW
  49. rtrip=$(basename -s .ttf $vf)
  50. new_file=../fonts/variable/$rtrip.ttx;
  51. rm $vf;
  52. ttx $new_file
  53. rm $new_file
  54. done
  55. echo "Fixing VF Meta"
  56. # gftools fix-vf-meta $vfs;
  57. gftools gen-stat ../fonts/variable/*.ttf --axis-order wdth wght ital --inplace
  58. echo "Subset fonts"
  59. mkdir -p ../fonts/noto-set/variable
  60. for vf in $vfs
  61. do pyftsubset $vf --drop-tables= --recalc-bounds --recalc-average-width --name-IDs='*' --name-legacy --glyph-names --glyphs-file=OpenSans-glyphset.txt --layout-features="aalt,rvrn,ccmp,dnom,frac,liga,lnum,locl,mark,mkmk,numr,onum,ordn,pnum,rtlm,salt,ss01,ss02,ss03,ss04,subs,sups,tnum,zero";
  62. mv $vf ../fonts/noto-set/variable/
  63. mv ${vf%.*}.subset.ttf $vf
  64. done
  65. mkdir -p ../fonts/noto-set/ttf
  66. for ttf in $ttfs
  67. do pyftsubset $ttf --drop-tables= --recalc-bounds --recalc-average-width --name-IDs='*' --name-legacy --glyph-names --glyphs-file=OpenSans-glyphset.txt --layout-features="aalt,rvrn,ccmp,dnom,frac,liga,lnum,locl,mark,mkmk,numr,onum,ordn,pnum,rtlm,salt,ss01,ss02,ss03,ss04,subs,sups,tnum,zero";
  68. mv $ttf ../fonts/noto-set/ttf/
  69. mv ${ttf%.*}.subset.ttf $ttf
  70. # recalculate hhea.advanceWidthMax
  71. python -c "from fontTools.ttLib import TTFont; import sys; filename=sys.argv[-1]; font=TTFont(filename); max_adv_width = max(adv for adv, lsb in font['hmtx'].metrics.values()); font['hhea'].advanceWidthMax = max_adv_width; font.save(filename)" $ttf
  72. done
  73. # Add hinting
  74. python -m vttLib mergefile vtt-hinting-roman.ttx "../fonts/variable/OpenSans[wdth,wght].ttf"
  75. python -m vttLib compile "../fonts/variable/OpenSans[wdth,wght].ttf" "../fonts/variable/OpenSans[wdth,wght].ttf" --ship
  76. python -m vttLib mergefile vtt-hinting-italic.ttx "../fonts/variable/OpenSans-Italic[wdth,wght].ttf"
  77. python -m vttLib compile "../fonts/variable/OpenSans-Italic[wdth,wght].ttf" "../fonts/variable/OpenSans-Italic[wdth,wght].ttf" --ship
  78. echo "Fixing Hinting"
  79. for vf in $vfs
  80. do
  81. gftools fix-hinting $vf;
  82. mv $vf.fix $vf;
  83. python fix_gasp.py $vf;
  84. echo "done $vf"
  85. done
  86. # rm -f ../fonts/ttf/*gasp.ttf