-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcustomize.sh
195 lines (175 loc) · 6.3 KB
/
customize.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
. ${SH:=$MODPATH/ohmyfont}
gfi_dl() {
#local family=`echo $@ | sed 's| |%20|g'`
font=`echo $@ | sed 's|_||g'`
#local link="https://fonts.google.com/download?family=$family"
local zipfile=`echo $@ | sed 's| |_|g'`.zip
local zip=$OMFDIR/$zipfile
#local time=`valof GF_timeout`
[ -f $zip ] && unzip -l $zip >/dev/null || {
#ui_print " Downloading $font (≤${time:=60}s)"
#ui_print " $link"
#wget --spider --no-check-certificate $link || {
# ui_print "! $@: no font match, make sure font name is correct"
# return
#}
#timeout $time $MAGISKBIN/busybox wget --no-check-certificate -O $zip $link || {
#ui_print "! Download failed"
ui_print " Please download $@ font manually"
abort " Then move/rename the downloaded zip to $zip"
#}
}
ui_print " Extracting $zipfile"
unzip -q $zip -d $gfidir
}
gfi_ren() {
local fa=${1:-$SA} i
case $fa in $SA) i=u ;; $SC) i=c ;; $SE) i=s ;; $MO) i=m ;; $SO) i=o ;; esac
set bl $Bl eb $EBo b $Bo sb $SBo m $Me r $Re l $Li el $ELi t $Th
while [ $2 ]; do
[ $i = u ] && {
$find $gfidir -type f -name "$font*\_$Cn$2$X" -exec mv -n {} $CFI/c$1$X \;
cp $CFI/c$1$X $CFI
}
find $gfidir -type f -name "$font*-$2$X" ! \( -name "*$Cn*" -o -name "*Expanded-*" \) \
-exec mv -n {} $CFI/$i$1$X \;
find $gfidir -type f -name "$font-$2$X" -exec mv -n {} $CFI/$i$1$X \;
cp $CFI/$i$1$X $CFI
shift 2
done
case $fa in $SA) i=i ;; $SC) i=d ;; $SE) i=t ;; $MO) i=n ;; $SO) i=p ;; esac
set bl $Bl$It eb $EBo$It b $Bo$It sb $SBo$It m $Me$It r $It l $Li$It el $ELi$It t $Th$It
while [ $2 ]; do
[ $i = i ] && {
find $gfidir -type f -name "$font*\_$Cn$2$X" -exec mv -n {} $CFI/d$1$X \;
cp $CFI/d$1$X $CFI
}
find $gfidir -type f -name "$font*-$2$X" ! \( -name "*$Cn*" -o -name "*Expanded-*" \) \
-exec mv -n {} $CFI/$i$1$X \;
find $gfidir -type f -name "$font-$2$X" -exec mv -n {} $CFI/$i$1$X \;
cp $CFI/$i$1$X $CFI
shift 2
done
[ $gfidir ] && rm -rf $gfidir/*
}
gfi() {
$SANS || $SERF || $MONO || $SRMO || return
GF=`valof GF` GF_condensed=`valof GF_condensed` GF_mono=`valof GF_mono`
GF_serif=`valof GF_serif` GF_serif_mono=`valof GF_serif_mono`
[ "$GF" ] || [ "$GF_mono" ] || [ "$GF_serif" ] || [ "$GF_serif_mono" ] && \
[ -d $CFI ] || return
ui_print "+ Google Font Installer"
local font gfidir=$FONTS/gfi; mkdir $gfidir
$SANS && {
[ "$GF" ] && {
ui_print "> Sans Serif"
[ -f $CFI/ur$XY -o -f $CFI/$Re$XY -o -f $CFI/ss$X ] && {
ui_print " Fonts exist in $CFI. Do nothing!"
} || {
gfi_dl $GF
ui_print " Preparing $font"
gfi_ren $SA
[ -f $CFI/ur$X ] && {
ui_print " $font has been saved to $CFI!"
} || {
ui_print "! Failed: there is no Regular font style"
abort " Please rename fonts manually in $CFI"
}
}
}
[ "$GF_condensed" ] && {
ui_print "> Sans Serif Condensed"
[ -f $CFI/cr$XY -o -f $CFI/$Cn$Re$XY ] && {
ui_print " Fonts exist in $CFI. Do nothing!"
} || {
gfi_dl $GF_condensed
ui_print " Preparing $font"
gfi_ren $SC
[ -f $CFI/cr$X ] && {
ui_print " $font has been saved to $CFI!"
} || {
ui_print "! Failed: there is no Regular font style"
abort " Please rename fonts manually in $CFI"
}
}
}
}
$MONO && [ "$GF_mono" ] && {
ui_print "> Monospace"
[ -f $CFI/mr$XY -o -f $CFI/$Mo$Re$XY -o -f $CFI/ms$X ] && {
ui_print " Fonts exist in $CFI. Do nothing!"
} || {
gfi_dl $GF_mono
ui_print " Preparing $font"
gfi_ren $MO
[ -f $CFI/mr$X ] && {
ui_print " $font has been saved to $CFI!"
} || {
ui_print "! Failed: there is no Regular font style"
abort " Please rename fonts manually in $CFI"
}
}
}
$SERF && [ "$GF_serif" ] && {
ui_print "> Serif"
[ -f $CFI/sr$XY -o -f $CFI/$Se$Re$XY -o -f $CFI/ser$X ] && {
ui_print " Fonts exist in $CFI. Do nothing!"
} || {
gfi_dl $GF_serif
ui_print " Preparing $font"
gfi_ren $SE
[ -f $CFI/sr$X ] && {
ui_print " $font has been saved to $CFI!"
} || {
ui_print "! Failed: there is no Regular font style"
abort " Please rename fonts manually in $CFI"
}
}
}
$SRMO && [ "$GF_serif_mono" ] && {
ui_print "> Serif Monospace"
[ -f $CFI/or$XY -o -f $CFI/$So$Re$XY -o -f $CFI/srm$X ] && {
ui_print " Fonts exist in $CFI. Do nothing!"
} || {
gfi_dl $GF_serif_mono
ui_print " Preparing $font"
gfi_ren $SO
[ -f $CFI/or$X ] && {
ui_print " $font has been saved to $CFI!"
} || {
ui_print "! Failed: there is no Regular font style"
abort " Please rename fonts manually in $CFI"
}
}
}
ver gfi
}
### INSTALLATION ###
ui_print '- Installing'
ui_print '+ Prepare'
prep
ui_print '+ Configure'
config
mkdir $FONTS ${CFI:=$OMFDIR/CFI}
gfi
ui_print '+ Font'
cp $CFI/*$XY $FONTS || ui_print "! $CFI: no font found"
[ -f $FONTS/$SS ] || SS=
[ -f $FONTS/`valof SSI` ] || { [ "`valof IR`" ] && SSI=$SS; } || SSI=
[ -f $FONTS/$SER ] || SER=; [ -f $FONTS/$SERI ] || SERI=
[ -f $FONTS/$MS ] || MS=; [ -f $FONTS/$MSI ] || MSI=
[ -f $FONTS/$SRM ] || SRM=; [ -f $FONTS/$SRMI ] || SRMI=
ORISS=$SS ORISSI=$SSI ORISER=$SER ORISERI=$SERI
ORIMS=$MS ORIMSI=$MSI ORISRM=$SRM ORISRMI=$SRMI
install_font
[ $Sa ] && rm $FONTS/[cd]*$XY
cpf *$XY
$SANS || $SERF || $MONO || $SRMO || $EMOJ || rm $SYSXML $PRDXML
src
ui_print '+ Rom'
rom
ui_print '- Finalizing'
fontspoof
svc
finish
[ -d $SYSFONT ] || abort "! No font installed"