Last active
January 4, 2016 13:57
-
-
Save pklaus/77168984dff2b667b8ea to your computer and use it in GitHub Desktop.
small command line app to dump font name from ttf/otf file? http://opensuse.opensuse.narkive.com/vtvR0uxL/small-command-line-app-to-dump-font-name-from-ttf-otf-file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ttfinfo() { | |
ttf2pt1 -pft -Gf -Ouost "$1" - 2>/dev/null | \ | |
gawk '/\/FullName/ { | |
print gensub(".*/FullName.*\\(([^)]*)\\)([[:space:]]readonly)?[[:space:]]+def[[:space:]]*.*", "\\1", 1, $0); | |
}' | |
} | |
type1info() { | |
tr '\r' '\n' < "$1" | gawk '/\/FullName/ { | |
print gensub(".*/FullName.*\\(([^)]*)\\)([[:space:]]readonly)?[[:space:]]+def[[:space:]]*.*", "\\1", 1, $0); | |
}' | |
} | |
bdfinfo() { | |
gawk ' | |
/^FACE_NAME/{ | |
$1=""; | |
gsub("\"",""); | |
sub("^[[:space:]]",""); | |
if($1) { face="[" $0 "]"; }; | |
} | |
/^FONT[[:space:]]/{ | |
split($2, name, "-"); | |
for(i=2; i < 7; i++) { | |
printf("%s ", name[i]); | |
} | |
for(i=14; i <= length(name); i++) { | |
enc=enc "-" name[i]; | |
} | |
sub("^-", "", enc); | |
sub("-$", "", enc); | |
} | |
END { | |
printf("%s %s\n", enc, face); | |
}' "$1" | |
} | |
for f; do | |
case "$f" in | |
*.[bB][dD][fF]) printf "%s: %s\n" "$f" "$(bdfinfo "$f")";; | |
*.[oOtT][tT][fF]) printf "%s: %s\n" "$f" "$(ttfinfo "$f")";; | |
*.[pP][fF][aAbB]) printf "%s: %s\n" "$f" "$(type1info "$f")";; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment