|
6 | 6 | # Source: https://github.com/source-foundry/alt-hack |
7 | 7 | # --------------------------------------------------- |
8 | 8 |
|
9 | | -# 1. Set the path to the downloaded Hack repo here first |
10 | | -HACK_PATH="" |
| 9 | +# 1. Set the path to the downloaded Hack repo, or set HACK_PATH environment variable |
| 10 | +HACK_PATH="${HACK_PATH:=""}" |
11 | 11 |
|
12 | | -# 2. List your alternate glyphs here |
| 12 | +# 2. List your alternate glyphs here, or specify them on the command line |
13 | 13 | declare -a alternates=( |
14 | | -# "zero-dotted" |
15 | | - "zero-forwardslash" |
16 | | -# "zero-backslash" |
17 | | -# "zero-diamond" |
18 | | - "one-noslab" |
19 | | -# "three-flattop" |
20 | | - "g-loop" |
| 14 | + "ampersand-nogap" |
| 15 | +# "angle-brackets-wider" |
21 | 16 | # "f-knife" |
| 17 | + "g-loop" |
22 | 18 | "i-slab" |
23 | 19 | "l-slab" |
24 | | - "percent-traditional" |
25 | | - "ampersand-nogap" |
| 20 | + "one-noslab" |
26 | 21 | # "parentheses-curved" |
27 | 22 | "parentheses-rounder" |
28 | | -# "angle-brackets-wider" |
| 23 | + "percent-traditional" |
29 | 24 | # "square-brackets-oldv3" |
| 25 | +# "three-flattop" |
| 26 | +# "zero-dotted" |
| 27 | + "zero-forwardslash" |
| 28 | +# "zero-backslash" |
| 29 | +# "zero-diamond" |
30 | 30 | ) |
31 | 31 |
|
32 | 32 | # 3. Run this script and enjoy! |
33 | 33 |
|
34 | 34 | # ------------------------------------------------------------------------------------------------ # |
35 | 35 |
|
36 | | -if [ -z $HACK_PATH ]; then |
37 | | - echo "❌ Set the HACK_PATH variable in this script to your downloaded Hack repo root." |
| 36 | +# If arguments provided, use them as alternates instead |
| 37 | +if [ $# -gt 0 ]; then |
| 38 | + alternates=("$@") |
| 39 | +fi |
| 40 | + |
| 41 | +if [ -z "$HACK_PATH" ]; then |
| 42 | + echo "❌ Set the HACK_PATH variable in this script or via an environment variable to your"\ |
| 43 | + "downloaded Hack repo root." |
38 | 44 | exit 1 |
39 | 45 | fi |
40 | 46 |
|
|
48 | 54 | lowercaseStyle=$(echo "$style" | tr '[:upper:]' '[:lower:]') |
49 | 55 | alternatePath="./glyphs/${alternate}/${lowercaseStyle}" |
50 | 56 |
|
51 | | - if ! cp "$alternatePath"/*.glif "$stylePath"; then |
| 57 | + if ! cp "${alternatePath}"/*.glif "${stylePath}"; then |
52 | 58 | echo "❌ Aborting patching of Hack, check errors above." |
53 | 59 | exit 1 |
54 | 60 | fi |
| 61 | + |
| 62 | + # Extract the unicode hex values from each glif |
| 63 | + while read -r hexcode |
| 64 | + do |
| 65 | + # Remove hinting of patched glyphs |
| 66 | + sed -i "s/^\(uni${hexcode}\)/#\1/" \ |
| 67 | + "${HACK_PATH}"/postbuild_processing/tt-hinting/Hack-"${style}"-TA.txt |
| 68 | + done < <(grep "unicode hex=" "${alternatePath}"/*.glif | sed 's/.*"\(.*\)".*/\1/' | sort -u) |
55 | 69 | done |
56 | 70 |
|
57 | | - echo "✅ Patched $alternate" |
| 71 | + echo "✅ Patched ${alternate}" |
58 | 72 | done |
59 | 73 |
|
60 | 74 | echo |
|
0 commit comments