build-web.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/sh
  2. # /////////////////////////////////////////////////////////////////
  3. #
  4. # build-web.sh
  5. # A shell script that builds the Hack web fonts from ttf files
  6. # Copyright 2017 Christopher Simpkins
  7. # MIT License
  8. #
  9. # Usage: ./build-web.sh (--install-dependencies)
  10. # Arguments:
  11. # --install-dependencies (optional) - installs all
  12. # build dependencies prior to the build script execution
  13. #
  14. # NOTE: If you change the source, you must build new ttf files
  15. # with build.sh PRIOR to execution of this script
  16. #
  17. # /////////////////////////////////////////////////////////////////
  18. # The build directory.
  19. BUILD="$HOME/sfnt2woff-zopfli-build"
  20. # sfnt2woff-zopfli version
  21. SFNTWOFF_VERSION="1.1.0"
  22. SFNTWOFF="sfnt2woff-zopfli-$SFNTWOFF_VERSION"
  23. # Path to sfnt2woff-zopfli executable
  24. SFNTWOFF_BIN="$BUILD/$SFNTWOFF/sfnt2woff-zopfli"
  25. # test for number of arguments
  26. if [ $# -gt 1 ]
  27. then
  28. echo "Inappropriate arguments included in your command." 1>&2
  29. echo "Usage: ./build-web.sh (--install-dependencies)" 1>&2
  30. exit 1
  31. fi
  32. # Optional build dependency install request with syntax `./build-web.sh --install-dependencies`
  33. if [ "$1" = "--install-dependencies" ]
  34. then
  35. if test -d "$BUILD" -o -f "$BUILD"; then
  36. echo "Build directory \`$BUILD' must not exist."
  37. exit 1
  38. fi
  39. mkdir "$BUILD"
  40. cd "$BUILD" || exit 1
  41. echo "#####"
  42. echo "Download archive."
  43. echo "#####"
  44. curl -L -O "https://github.com/bramstein/sfnt2woff-zopfli/archive/v$SFNTWOFF_VERSION.tar.gz"
  45. echo "#####"
  46. echo "Extract archives."
  47. echo "#####"
  48. tar -xzvf "v$SFNTWOFF_VERSION.tar.gz"
  49. cd "$SFNTWOFF" || exit 1
  50. echo "#####"
  51. echo "Build $SFNTWOFF."
  52. echo "#####"
  53. make
  54. fi
  55. if [ -f "$SFNTWOFF_BIN" ]; then
  56. echo "Beginning web font build with $SFNTWOFF"
  57. else
  58. echo "Unable to locate sfnt2woff-zopfli." 1>&2
  59. exit 1
  60. fi
  61. # TODO : implement woff build from ttf build files
  62. # TODO : move woff files to appropriate build directory
  63. # TODO : cleanup pulled tar.gz archive file