hexdump.sh 421 B

12345678910111213141516
  1. #!/bin/bash
  2. FILE=$1
  3. if [ ! -f "$FILE" ]
  4. then
  5. echo usage: bash scripts/hexdump.sh input.ttf
  6. exit 1
  7. fi
  8. NAME=$(basename "$FILE" | sed 's/[.-]/_/g')
  9. echo "// This is an automatically generated file. Do not edit."
  10. echo "const unsigned char _binary_$NAME[] ="
  11. od -v -An -tx1 "$FILE" | sed 's/ *//g;s/[0-9a-f][0-9a-f]/\\x&/g;s/.*/"&"/'
  12. echo ";"
  13. echo "const unsigned int _binary_${NAME}_size = sizeof(_binary_${NAME}) - 1;"