build.sh 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/usr/bin/env bash
  2. set -e
  3. generate_vf () {
  4. # arg1: input.glyphs file, arg2: out.ttf
  5. fontmake -g $1 -o ufo --no-production-names
  6. cu2qu $(ls -d ./master_ufo/*.ufo) -i
  7. fontmake -m ./master_ufo/*.designspace -o variable --output-path $2
  8. }
  9. postprocess_vf () {
  10. # arg1: input.ttf, arg2: patchfile.ttx
  11. # Patch in STAT table
  12. ttx -m $1 $2
  13. mv "${2%.*}.ttf" $1
  14. # Drop MVAR
  15. ttx -x "MVAR" $1
  16. ttx -f "${1%.*}.ttx"
  17. rm "${1%.*}.ttx"
  18. postprocess_ttf $1
  19. }
  20. postprocess_ttf () {
  21. # arg 1: input.ttf
  22. gftools fix-dsig -f $1
  23. gftools fix-nonhinting $1 $1.fix
  24. mv $1.fix $1
  25. rm $(dirname "$1")/*gasp.ttf
  26. }
  27. instantiate_instance () {
  28. # arg 1: input.ttf arg2: wght_axis arg3: wdth_axis arg4: out
  29. fontTools varLib.mutator $1 wght=$2 wdth=$3
  30. mv "${1%.*}-instance.ttf" $4
  31. postprocess_ttf $1
  32. }
  33. # --------------
  34. VF_ROMAN_SRC="./OpenSans-Roman.glyphs"
  35. VF_ITALIC_SRC="./OpenSans-Italic.glyphs"
  36. VF_ROMAN_OUT="../fonts/vf/OpenSans[wdth,wght].ttf"
  37. VF_ITALIC_OUT="../fonts/vf/OpenSans-Italic[wdth,wght].ttf"
  38. rm -rf ../fonts
  39. mkdir -p ../fonts ../fonts/vf ../fonts/ttf
  40. echo "Generating VFs"
  41. generate_vf $VF_ROMAN_SRC $VF_ROMAN_OUT
  42. rm -rf ./master_ufo ./instance_ufo
  43. generate_vf $VF_ITALIC_SRC $VF_ITALIC_OUT
  44. rm -rf ./master_ufo ./instance_ufo
  45. echo "Post processing VFs"
  46. postprocess_vf $VF_ROMAN_OUT OpenSans-Roman-patch.ttx
  47. postprocess_vf $VF_ITALIC_OUT OpenSans-Italic-patch.ttx
  48. echo "Instantiating Instances"
  49. # Roman
  50. instantiate_instance $VF_ROMAN_OUT 300 100 ../fonts/ttf/OpenSans-Light.ttf
  51. instantiate_instance $VF_ROMAN_OUT 400 100 ../fonts/ttf/OpenSans-Regular.ttf
  52. instantiate_instance $VF_ROMAN_OUT 600 100 ../fonts/ttf/OpenSans-SemiBold.ttf
  53. instantiate_instance $VF_ROMAN_OUT 700 100 ../fonts/ttf/OpenSans-Bold.ttf
  54. instantiate_instance $VF_ROMAN_OUT 800 100 ../fonts/ttf/OpenSans-ExtraBold.ttf
  55. # Italic
  56. instantiate_instance $VF_ITALIC_OUT 300 100 ../fonts/ttf/OpenSans-LightItalic.ttf
  57. instantiate_instance $VF_ITALIC_OUT 400 100 ../fonts/ttf/OpenSans-Italic.ttf
  58. instantiate_instance $VF_ITALIC_OUT 600 100 ../fonts/ttf/OpenSans-SemiBoldItalic.ttf
  59. instantiate_instance $VF_ITALIC_OUT 700 100 ../fonts/ttf/OpenSans-BoldItalic.ttf
  60. instantiate_instance $VF_ITALIC_OUT 800 100 ../fonts/ttf/OpenSans-ExtraBoldItalic.ttf
  61. # Condensed Roman
  62. instantiate_instance $VF_ROMAN_OUT 300 75 ../fonts/ttf/OpenSansCondensed-Light.ttf
  63. instantiate_instance $VF_ROMAN_OUT 400 75 ../fonts/ttf/OpenSansCondensed-Regular.ttf
  64. instantiate_instance $VF_ROMAN_OUT 600 75 ../fonts/ttf/OpenSansCondensed-SemiBold.ttf
  65. instantiate_instance $VF_ROMAN_OUT 700 75 ../fonts/ttf/OpenSansCondensed-Bold.ttf
  66. instantiate_instance $VF_ROMAN_OUT 800 75 ../fonts/ttf/OpenSansCondensed-ExtraBold.ttf
  67. # Condensed Italic
  68. instantiate_instance $VF_ITALIC_OUT 300 75 ../fonts/ttf/OpenSansCondensed-LightItalic.ttf
  69. instantiate_instance $VF_ITALIC_OUT 400 75 ../fonts/ttf/OpenSansCondensed-Italic.ttf
  70. instantiate_instance $VF_ITALIC_OUT 600 75 ../fonts/ttf/OpenSansCondensed-SemiBoldItalic.ttf
  71. instantiate_instance $VF_ITALIC_OUT 700 75 ../fonts/ttf/OpenSansCondensed-BoldItalic.ttf
  72. instantiate_instance $VF_ITALIC_OUT 800 75 ../fonts/ttf/OpenSansCondensed-ExtraBoldItalic.ttf