build.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #!/bin/bash
  2. # /////////////////////////////////////////////////////////////////
  3. #
  4. # build.sh
  5. # A shell script that builds the Hack fonts from UFO source
  6. # Copyright 2017 Christopher Simpkins
  7. # MIT License
  8. #
  9. # Usage: ./build.sh (--install-dependencies)
  10. # Arguments:
  11. # --install-dependencies (optional) - installs all
  12. # build dependencies prior to the build script execution
  13. #
  14. # /////////////////////////////////////////////////////////////////
  15. if [ $# -gt 1 ]
  16. then
  17. echo "Inappropriate arguments included in your command." 1>&2
  18. echo "Usage: ./build.sh (--install-dependencies)" 1>&2
  19. exit 1
  20. elif [ "$1" = "--install-dependencies" ]
  21. then
  22. # fontmake
  23. pip install fontmake
  24. # fontTools
  25. pip install fonttools
  26. # ttfautohint v1.6 (must be pinned to v1.6 and above)
  27. curl -L https://sourceforge.net/projects/freetype/files/ttfautohint/1.6/ttfautohint-1.6.tar.gz/download -o ttfautohint.tar.gz
  28. tar -xvzf ttfautohint.tar.gz
  29. ttfautohint-1.6/configure
  30. sudo ttfautohint-1.6/make && sudo ttfautohint-1.6/make install
  31. if [ -f "ttfautohint-1.6.tar.gz" ]
  32. then
  33. rm ttfautohint-1.6.tar.gz
  34. fi
  35. if [ -d "ttfautohint-1.6"]
  36. then
  37. rm -rf ttfautohint-1.6
  38. fi
  39. # confirm installs
  40. installflag = 0
  41. which fontmake
  42. if [ $? -ne 0 ]
  43. then
  44. echo "Unable to install fontmake with 'pip install fontmake'. Please attempt manual install and repeat build without the --install-dependencies flag." 1>&2
  45. $installflag = 1
  46. fi
  47. python -c "import fontTools"
  48. if [ $? -ne 0 ]
  49. then
  50. echo "Unable to install fontTools with 'pip install fonttools'. Please attempt manual install and repeat build without the --install-dependencies flag." 1>&2
  51. $installflag = 1
  52. fi
  53. which ttfautohint
  54. if [ $? -ne 0 ]
  55. then
  56. echo "Unable to install ttfautohint from source. Please attempt manual install and repeat build without the --install-dependencies flag." 1>&2
  57. $installflag = 1
  58. fi
  59. # if any of the dependency installs failed, exit and do not attempt build
  60. if [ $installflag -eq 1 ]
  61. then
  62. echo "Build canceled." 1>&2
  63. exit 1
  64. fi
  65. fi
  66. # Desktop ttf font build
  67. # remove any existing release files from the build directory
  68. if [ -f "build/ttf/Hack-Regular.ttf" ]; then
  69. rm build/ttf/Hack-Regular.ttf
  70. fi
  71. if [ -f "build/ttf/Hack-Italic.ttf" ]; then
  72. rm build/ttf/Hack-Italic.ttf
  73. fi
  74. if [ -f "build/ttf/Hack-Bold.ttf" ]; then
  75. rm build/ttf/Hack-Bold.ttf
  76. fi
  77. if [ -f "build/ttf/Hack-BoldItalic.ttf" ]; then
  78. rm build/ttf/Hack-BoldItalic.ttf
  79. fi
  80. # build regular set
  81. fontmake -u "source/Hack-Regular.ufo" -o ttf
  82. if [ $? -ne 0 ]
  83. then
  84. echo "Unable to build the Hack regular variant set. Build canceled." 1>&2
  85. exit 1
  86. fi
  87. # build bold set
  88. fontmake -u "source/Hack-Bold.ufo" -o ttf
  89. if [ $? -ne 0 ]
  90. then
  91. echo "Unable to build the Hack bold variant set. Build canceled." 1>&2
  92. exit 1
  93. fi
  94. # build italic set
  95. fontmake -u "source/Hack-Italic.ufo" -o ttf
  96. if [ $? -ne 0 ]
  97. then
  98. echo "Unable to build the Hack italic variant set. Build canceled." 1>&2
  99. exit 1
  100. fi
  101. # build bold italic set
  102. fontmake -u "source/Hack-BoldItalic.ufo" -o ttf
  103. if [ $? -ne 0 ]
  104. then
  105. echo "Unable to build the Hack bold italic variant set. Build canceled." 1>&2
  106. exit 1
  107. fi
  108. # Desktop ttf font hinting
  109. # TODO
  110. # Desktop ttf font post build fixes
  111. # TODO
  112. # Move release files to build directory
  113. mv master_ttf/Hack-Regular.ttf build/ttf/Hack-Regular.ttf
  114. echo "Hack-Regular.ttf was moved to release directory on path build/ttf/Hack-Regular.ttf"
  115. mv master_ttf/Hack-Italic.ttf build/ttf/Hack-Italic.ttf
  116. echo "Hack-Italic.ttf was moved to release directory on path build/ttf/Hack-Italic.ttf"
  117. mv master_ttf/Hack-Bold.ttf build/ttf/Hack-Bold.ttf
  118. echo "Hack-Bold.ttf was moved to release directory on path build/ttf/Hack-Bold.ttf"
  119. mv master_ttf/Hack-BoldItalic.ttf build/ttf/Hack-BoldItalic.ttf
  120. echo "Hack-BoldItalic.ttf was moved to release directory on path build/ttf/Hack-BoldItalic.ttf"
  121. # Remove master_ttf directory
  122. rm -rf master_ttf