File tree 2 files changed +68
-0
lines changed
2 files changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,7 @@ File scripts to print a given `ls` field:
184
184
185
185
* ` font-file-to-family ` : Parse a font file to the preferred family string.
186
186
* ` font-file-to-full-name ` : Parse a font file to the full name string.
187
+ * ` font-unzip ` : Unzip a font zip file and move fonts to a family directory
187
188
188
189
189
190
### sysadmin
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ #
3
+ # font-unzip:
4
+ # unzip a font zip file and move fonts to a family directory.
5
+ #
6
+ # Syntax:
7
+ #
8
+ # font-unzip <file> [destination]
9
+ #
10
+ # Example:
11
+ #
12
+ # font-unzip example.zip ~/fonts/
13
+ #
14
+ # This script is implemented on OS X by using `otfinfo`.
15
+ # To get this, use `brew install lcdf-typetools`.
16
+ #
17
+ # To Do:
18
+ #
19
+ # * Implement on Linux and Windows
20
+ # * Get other font fields
21
+ #
22
+ # Command: font-unzip
23
+ # Version: 1.1.0
24
+ # Created: 2015-12-19
25
+ # Updated: 2016-04-24
26
+ # Command: font-zip-to-family
27
+ # License: GPL
28
+ # Contact: Joel Parker Henderson ([email protected] )
29
+ # #
30
+ set -euf
31
+ me=` basename $0 `
32
+ font_zip_file=" $1 "
33
+ font_top_dir=${2:- .}
34
+ font_tmp_dir=$( mktemp -d -t " $me " )
35
+ unzip -qq " $font_zip_file " -d " $font_tmp_dir "
36
+
37
+ # Find font files that we want to process.
38
+ find_font_files (){
39
+ find " $1 " -type f \( -name " *.otf" -o -name " *.ttf" \) -exec printf %s\\ 0 ' {}' \;
40
+ }
41
+
42
+ # Remove any superfluous files that we know about and don't need to move.
43
+ scrub_font_remnants (){
44
+ rm -f " $1 /Font Bundles - The Best Free and Premium Fonts.url"
45
+ rm -f " $1 /FontBundlesLicense.pdf"
46
+ }
47
+
48
+ # Warn the user about any remaining files, so the user can take action.
49
+ print_font_remnants (){
50
+ find " $1 " -type f
51
+ }
52
+
53
+ each_font_file (){
54
+ font_file=" $1 "
55
+ font_base_dir=" $2 "
56
+ family=$( font-file-to-family " $font_file " )
57
+ dst=" $font_base_dir /$family /"
58
+ mkdir -p " $dst "
59
+ echo " mv \" $font_file \" \" $dst \" "
60
+ mv " $font_file " " $dst "
61
+ }
62
+
63
+ find_font_files " $font_tmp_dir " | while read -d $' \0' file; do
64
+ each_font_file " $file " " $font_top_dir "
65
+ done
66
+ scrub_font_remnants " $font_tmp_dir "
67
+ print_font_remnants " $font_tmp_dir "
You can’t perform that action at this time.
0 commit comments