Lines 1-681
Link Here
|
1 |
--- modules/abiword.ttfm.orig Sun Jun 2 14:22:27 2002 |
|
|
2 |
+++ modules/abiword.ttfm Sun Jun 2 14:22:57 2002 |
3 |
@@ -1,82 +1,56 @@ |
4 |
#!/bin/sh |
5 |
-# |
6 |
-# TTFM's module for AbiWord 0.7.12. |
7 |
-# |
8 |
-# This script is distributed under the revised BSD license. |
9 |
-# |
10 |
-# For any problem reports or suggestions, please contact |
11 |
-# Jing-Tang Keith Jang <keith@FreeBSD.org>. |
12 |
-# |
13 |
- |
14 |
-# |
15 |
-# AbiWord searches the following subdirectories under fonts/ for fonts.dir: |
16 |
-# $country, $country-$region, $encoding, $country-$region.$encoding. For |
17 |
-# example, fonts/{zh, zh-TW, Big5, zh-TW.Big5} are all valid directories. |
18 |
-# However, this module will only generate fonts/$encoding/fonts.dir for the |
19 |
-# sake of simplicity. |
20 |
-# |
21 |
-# Here are the sample lines of a font in AbiWord's fonts.dir: |
22 |
-# |
23 |
-# Kai-Medium, -default-kai-medium-r-normal--0-0-0-0-c-0-big5-0, 880, 120, 1000 |
24 |
-# Kai-Medium, -default-kai-bold-r-normal--0-0-0-0-c-0-big5-0, 880, 120, 1000 |
25 |
-# Kai-Medium, -default-kai-medium-i-normal--0-0-0-0-c-0-big5-0, 880, 120, 1000 |
26 |
-# Kai-Medium, -default-kai-bold-i-normal--0-0-0-0-c-0-big5-0, 880, 120, 1000 |
27 |
-# |
28 |
-# AbiWord uses the first field for printing, second field for displaying. |
29 |
-# The last three fields are font's ascent, descent, and width, used when |
30 |
-# printing. |
31 |
-# |
32 |
-# Because AbiWord follows normal X convention, there's no need that the font |
33 |
-# must be TTF. But we'll only accept TTF here, since it's better in scaling. |
34 |
-# CID fonts may be supported in the future, depending on the demanding. |
35 |
-# |
36 |
- |
37 |
-# Name & version |
38 |
-export NAME; NAME="AbiWord Font Manager" |
39 |
-export VERSION; VERSION=0.9.3 |
40 |
+#/* |
41 |
+# * Copyrighy (c) 2001 CLE Project. All rights reserved. |
42 |
+# * Copyright (c) 2001 Chung-Yen Chang. All rights reserved. |
43 |
+# * with Big5-HKSCS font support added by Anthony Fok |
44 |
+# * thanks to ThizLinux Laboratory Ltd., Thiz Technology Group |
45 |
+# * |
46 |
+# * Redistribution and use in source and binary forms, with or without |
47 |
+# * modification, are permitted provided that the following conditions |
48 |
+# * are met: |
49 |
+# * 1. Redistributions of source code must retain the above copyright |
50 |
+# * notice, this list of conditions and the following disclaimer. |
51 |
+# * 2. Redistributions in binary form must reproduce the above copyright |
52 |
+# * notice, this list of conditions and the following disclaimer in the |
53 |
+# * documentation and/or other materials provided with the distribution. |
54 |
+# * 3. All advertising materials mentioning features or use of this software |
55 |
+# * must display the following acknowledgement: |
56 |
+# * This product includes software developed by |
57 |
+# * Chih-Wei Huang and contributors for CLE Project |
58 |
+# * 4. Neither the name of the Author nor the names of contributors |
59 |
+# * may be used to endorse or promote products derived from this software |
60 |
+# * without specific prior written permission. |
61 |
+# * |
62 |
+# * |
63 |
+# * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
64 |
+# * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
65 |
+# * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
66 |
+# * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
67 |
+# * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
68 |
+# * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
69 |
+# * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
70 |
+# * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
71 |
+# * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
72 |
+# * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
73 |
+# * SUCH DAMAGE. |
74 |
+# */ |
75 |
|
76 |
# Global constants |
77 |
+export TWABIFONTPATH; TWABIFONTPATH="/usr/X11R6/share/AbiSuite/fonts/zh-TW" |
78 |
+export CNABIFONTPATH; CNABIFONTPATH="/usr/X11R6/share/AbiSuite/fonts/zh-CN" |
79 |
+export HKABIFONTPATH; HKABIFONTPATH="/usr/X11R6/share/AbiSuite/fonts/zh-HK" |
80 |
+export TEMPFILE; TEMPFILE="`mktemp /tmp/ttfm.tmpXXXXXX`" |
81 |
+export DEFAULTPATH; DEFAULTPATH="/usr/local/share/fonts/TrueType" |
82 |
+ |
83 |
+for i in $TWABIFONTPATH $CNABIFONTPATH $CNABIFONTPATH.GBK $HKABIFONTPATH; do |
84 |
+ test -d $i || mkdir $i |
85 |
+ test -f $i/fonts.dir || mkfontdir $i |
86 |
+ touch $i/.already-in-fp |
87 |
+done |
88 |
|
89 |
-export PREFIX; PREFIX=/usr/local |
90 |
-export X11BASE; X11BASE=/usr/X11R6 |
91 |
-export PATH; PATH=/bin:/sbin:/usr/bin:/usr/sbin:$PREFIX/bin:$PREFIX/sbin:$X11BASE/bin |
92 |
-export TEMPFILE; TEMPFILE="`mktemp /tmp/ttfm.tmpXXX`" |
93 |
-export ABIFontPath; ABIFontPath=$PREFIX/AbiSuite/fonts |
94 |
-export DefaultFontPath; DefaultFontPath=$PREFIX/share/fonts/TrueType |
95 |
-export TTFM; TTFM=$PREFIX/bin/ttfm.sh |
96 |
-export XTTFFONTPATH; XTTFFONTPATH="$X11BASE/lib/X11/fonts/TrueType" |
97 |
-export GSMODULE; GSMODULE="ghostscript6" |
98 |
-export XMODULE; XMODULE="xttfm" |
99 |
-export TTFINFOPATH; TTFINFOPATH="$PREFIX/bin/ttfinfo" |
100 |
-export DEFAULTMING_NAME; DEFAULTMING_NAME="default_ming" |
101 |
-export DEFAULTKAI_NAME; DEFAULTKAI_NAME="default_kai" |
102 |
-export PRINTPARAM; PRINTPARAM="880, 120, 1000" |
103 |
- |
104 |
- |
105 |
-# |
106 |
-# Encoding/Directory table, used to convert the XLFD of a font to AbiWord's |
107 |
-# charset directories, and vice versa. Used by add_fonts(). |
108 |
-# |
109 |
-export ed_table; ed_table=\ |
110 |
-"Big5,big5-0\n |
111 |
-GB2312,gb2312.1980-0\n |
112 |
-KSC5601,ksc5601.1987-0\n |
113 |
-JISX0208,jisx0208.1983-0\n |
114 |
-JISX0212,jisx0212.1990-0\n" |
115 |
- |
116 |
- |
117 |
-# |
118 |
-# Encoding/Postscript name table, used to convert a font's XLFD encoding |
119 |
-# to its frequently used Postscript name. I'm not sure if the entries |
120 |
-# are correct, except Big5. |
121 |
-# |
122 |
-export ep_table; ep_table=\ |
123 |
-"big5-0,B5pc-H\n |
124 |
-gb2312.1980-0,GBpc-EUC-H\n |
125 |
-ksc5601.1987-0,KSCpc-EUC-H\n |
126 |
-jisx0208.1983-0,EUC-H\n |
127 |
-jisx0212.1990-0,Hojo-EUC-H\n" |
128 |
- |
129 |
+# Name & version |
130 |
+export NAME; NAME="AbiWord 1.0.1 TrueType Font Manager" |
131 |
+export VERSION; VERSION=1.0 |
132 |
|
133 |
# Who am I? |
134 |
print_name() |
135 |
@@ -84,7 +58,6 @@ |
136 |
echo "$NAME $VERSION" |
137 |
} |
138 |
|
139 |
- |
140 |
# Usage |
141 |
Usage() |
142 |
{ |
143 |
@@ -96,204 +69,275 @@ |
144 |
echo " --add <file>... install ttf font" |
145 |
echo " --remove <file>... remove ttf font from the system" |
146 |
echo " --list list all ttf fonts on the system" |
147 |
- echo " --setdefault <file> " |
148 |
- echo " set default font to file" |
149 |
- echo " --setdefault_kai <file> " |
150 |
- echo " set default \kai font to file" |
151 |
- echo " --setdefault_ming <file> " |
152 |
- echo " set default \ming font to file" |
153 |
echo " --help show this info" |
154 |
echo |
155 |
} |
156 |
|
157 |
|
158 |
-check_abiword() |
159 |
-{ |
160 |
- if [ ! -d $ABIFontPath ]; then |
161 |
- mkdir -p $ABIFontPath |
162 |
- fi |
163 |
- fontsdirlist=`find $ABIFontPath -name fonts.dir` |
164 |
-} |
165 |
- |
166 |
- |
167 |
-# |
168 |
-# List all fonts installed under $AbiFontPath |
169 |
-# |
170 |
-# I'm not sure if font filenames should also be displayed, since the XLFD |
171 |
-# may be provided from xfs. |
172 |
-# |
173 |
+# List all ttf fonts installed in $ABIFONTPATH |
174 |
list_fonts() |
175 |
{ |
176 |
- if [ "X$fontsdirlist" = "X" ]; then |
177 |
- echo "No fonts installed." |
178 |
+ if [ -f ${TWABIFONTPATH}/fonts.dir -o -f ${CNABIFONTPATH}/fonts.dir \ |
179 |
+ -o -f ${HKABIFONTPATH}/fonts.dir ]; then |
180 |
+ echo "Installed TTF fonts:" |
181 |
+ if [ -f ${TWABIFONTPATH}/fonts.dir ]; then |
182 |
+ awk -F, 'FNR>1 {print $1,$2}' ${TWABIFONTPATH}/fonts.dir |
183 |
+ fi |
184 |
+ if [ -f ${CNABIFONTPATH}/fonts.dir ]; then |
185 |
+ awk -F, 'FNR>1 {print $1,$2}' ${CNABIFONTPATH}/fonts.dir |
186 |
+ fi |
187 |
+ if [ -f ${CNABIFONTPATH}.GBK/fonts.dir ]; then |
188 |
+ awk -F, 'FNR>1 {print $1,$2}' ${CNABIFONTPATH}.GBK/fonts.dir |
189 |
+ fi |
190 |
+ if [ -f ${HKABIFONTPATH}/fonts.dir ]; then |
191 |
+ awk -F, 'FNR>1 {print $1,$2}' ${HKABIFONTPATH}/fonts.dir |
192 |
+ fi |
193 |
+ echo |
194 |
else |
195 |
- for f in $fontsdirlist; do |
196 |
- echo "In `dirname $f`:" |
197 |
- sed -e '1d' $f |cut -d ',' -f 1 |sort |uniq |
198 |
- echo |
199 |
- done |
200 |
+ echo "No TTF fonts installed!" |
201 |
fi |
202 |
} |
203 |
|
204 |
+# Get ttfinfo |
205 |
+get_ttfinfo() |
206 |
+{ |
207 |
+ TTFINFO="/usr/local/bin/ttfinfo" |
208 |
+ if [ "z$TTFINFO" = "z" ]; then |
209 |
+ echo "ttfinfo not found, aborted!" |
210 |
+ exit 3 |
211 |
+ fi |
212 |
+ eval `$TTFINFO $1` |
213 |
+} |
214 |
|
215 |
-# |
216 |
-# Remove ttf fonts. It accepts PS or TTF arguments, eg. |
217 |
-# remove_fonts DefaultMingB5-Regular(series), or |
218 |
-# remove_fonts /usr/local/share/fonts/TrueType/bsmi00lp.ttf. |
219 |
-# |
220 |
-# We won't delete font files, since the AbiWord module solely |
221 |
-# depends on other modules like xttfm or ghostscript6, font |
222 |
-# files should be managed by them, not here. |
223 |
-# |
224 |
-remove_fonts() |
225 |
+# Get Unicode fontmap |
226 |
+get_unicode_fontmap() |
227 |
{ |
228 |
- for f in $@; do |
229 |
- case $f in |
230 |
- *.[Tt][Tt][CcFf]) |
231 |
- i=`basename $f` |
232 |
- psnamelist=`$TTFM --list $GSMODULE |grep $i |cut -d '(' -f 1` |
233 |
- if [ -z "$psnamelist" ]; then |
234 |
- echo "$f is not installed" |
235 |
- continue |
236 |
- else |
237 |
- for psname in $psnamelist; do |
238 |
- for fontsdir in $fontsdirlist; do |
239 |
- sed -e "/^$psname/d" $fontsdir > $TEMPFILE |
240 |
- num=`cat $TEMPFILE |wc -l` |
241 |
- num=`expr $num - 1` |
242 |
- sed -e "1s/.*/$num/g" $TEMPFILE > $fontsdir |
243 |
- done |
244 |
- done |
245 |
- fi |
246 |
- ;; |
247 |
- *) |
248 |
- for fontsdir in $fontsdirlist; do |
249 |
- sed -e "/$f/d" $fontsdir > $TEMPFILE |
250 |
- num=`cat $TEMPFILE |wc -l` |
251 |
- num=`expr $num - 1` |
252 |
- sed -e "1s/.*/$num/g" $TEMPFILE > $fontsdir |
253 |
- done |
254 |
- ;; |
255 |
- esac |
256 |
+ j=1; n=0 |
257 |
+ while [ $j -le $TTFINFO_MAPNUM ]; do |
258 |
+ eval "fontmap=\$TTFINFO_FONTMAP$j" |
259 |
+ if (echo $fontmap | grep -q big5); then |
260 |
+ eval "NAMEEXT$n=_big5; TBL$n=UBig5"; n=$(($n+1)) |
261 |
+ elif (echo $fontmap | grep -q gb); then |
262 |
+ eval "NAMEEXT$n=_gb; TBL$n=UGB"; n=$(($n+1)) |
263 |
+ elif (echo $fontmap | grep -q jisx0208); then |
264 |
+ eval "NAMEEXT$n=_jis; TBL$n=UJIS"; n=$(($n+1)) |
265 |
+ elif (echo $fontmap | grep -q ksc5601); then |
266 |
+ eval "NAMEEXT$n=_ksc; TBL$n=UKS"; n=$(($n+1)) |
267 |
+ fi |
268 |
+ j=$(($j+1)) |
269 |
+ done |
270 |
+ # do not append ext if only one fontmap found |
271 |
+ [ $n -eq 1 ] && NAMEEXT0="" |
272 |
+ |
273 |
+ j=0 |
274 |
+ while [ $j -lt $n ]; do |
275 |
+ eval "NAME$j=$font\$NAMEEXT$j" |
276 |
+ j=$(($j+1)) |
277 |
done |
278 |
} |
279 |
|
280 |
|
281 |
-# |
282 |
# Add ttf fonts |
283 |
-# |
284 |
-# This script won't do the low-level work for both X Window or Ghostscript, |
285 |
-# such as adding fonts.dir or ps font entries. It just calls $TTFM with |
286 |
-# appropriate modules. All file handlings will be managed by those modules. |
287 |
-# |
288 |
add_fonts() |
289 |
{ |
290 |
- for addfile in $@; do |
291 |
- # Some sanity checking |
292 |
- if [ ! -r "$addfile" ]; then |
293 |
- echo "$addfile does not exist, skipped." |
294 |
- continue |
295 |
- fi |
296 |
- if [ -z "`echo $addfile |grep -i -e ".*tt[cf]$"`" ]; then |
297 |
- echo "$addfile is not a TTF, skipped." |
298 |
- continue |
299 |
- fi |
300 |
- # Those modules will manage if fonts are already installed. |
301 |
- $TTFM --add $XMODULE $addfile |
302 |
- $TTFM --add $GSMODULE $addfile |
303 |
- |
304 |
- f="`basename "$addfile"`" |
305 |
- xlfd="`$TTFM --list $XMODULE |grep $f |sed -e "/iso/d" -e "s/$f //g" |sort |uniq`" |
306 |
- encoding=`echo $xlfd |cut -d '-' -f 14-15` |
307 |
- subdir="`printf "$ed_table" |awk -F "," -v i=$encoding '{dir[$2]=$1} END {print dir[i]}'`" |
308 |
- cidname="`$TTFM --list $GSMODULE |grep $f |cut -d '(' -f 1 |sed -e "/^Default/d"`" |
309 |
- psname="$cidname"-"`printf "$ep_table" |awk -F "," -v i=$encoding '{ps[$1]=$2} END {print ps[i]}'`" |
310 |
- |
311 |
- if [ ! -d $ABIFontPath/$subdir ]; then |
312 |
- mkdir -p $ABIFontPath/$subdir |
313 |
- fi |
314 |
- touch $ABIFontPath/$subdir/.already-in-fp |
315 |
- if [ ! -r $ABIFontPath/$subdir/fonts.dir ]; then |
316 |
- echo 0 > $ABIFontPath/$subdir/fonts.dir |
317 |
- fi |
318 |
- num=`head -1 $ABIFontPath/$subdir/fonts.dir` |
319 |
- cp $ABIFontPath/$subdir/fonts.dir $TEMPFILE |
320 |
- # There may be spaces in $xlfd, quote it. |
321 |
- abifont="$psname, $xlfd, $PRINTPARAM" |
322 |
- echo $abifont >> $TEMPFILE |
323 |
- echo $abifont |sed -e "s/-medium-r-/-bold-r-/g" >> $TEMPFILE |
324 |
- echo $abifont |sed -e "s/-medium-r-/-medium-i-/g" >> $TEMPFILE |
325 |
- echo $abifont |sed -e "s/-medium-r-/-bold-i-/g" >> $TEMPFILE |
326 |
- num=`cat $TEMPFILE |wc -l` |
327 |
- num=`expr $num - 1` |
328 |
- sed -e "1s/.*/$num/g" $TEMPFILE > $ABIFontPath/$subdir/fonts.dir |
329 |
+ error=0 |
330 |
+ for f in "$@"; do |
331 |
+ if [ ! -e "$f" ]; then |
332 |
+ if [ -e "$DEFAULTPATH/$f" ]; then |
333 |
+ f="$DEFAULTPATH/$f" |
334 |
+ else |
335 |
+ echo "Cannot find font $f, ignored!" |
336 |
+ error=$(($error+1)) |
337 |
+ continue |
338 |
+ fi |
339 |
+ fi |
340 |
+ |
341 |
+ fontfile=`basename $f` |
342 |
+ eval `echo $fontfile | awk -F. '{ printf "font=%s;ext=%s",\$1,\$2 }'` |
343 |
+ |
344 |
+ get_ttfinfo $f |
345 |
+ i=1 |
346 |
+ while [ $i -le $TTFINFO_MAPNUM ]; do |
347 |
+ eval I1=\$TTFINFO_FONTMAP${i} |
348 |
+ I2=`echo $I1|sed -e s/medium-r/bold-r/` |
349 |
+ I3=`echo $I1|sed -e s/medium-r/medium-i/` |
350 |
+ I4=`echo $I1|sed -e s/medium-r/bold-i/` |
351 |
+ J1=`echo $I1|cut -c2-` |
352 |
+ J2=`echo $I2|cut -c2-` |
353 |
+ J3=`echo $I3|cut -c2-` |
354 |
+ J4=`echo $I4|cut -c2-` |
355 |
+ MYENC=`echo $I1 | awk -F- '{print $14}'` |
356 |
+ case $MYENC in |
357 |
+ big5) |
358 |
+ # zh-TW |
359 |
+ grep -v "$J1" $TWABIFONTPATH/fonts.dir |grep -v "$J2" |grep -v "$J3" |grep -v "$J4" |sed -e "1d" > $TEMPFILE.1 |
360 |
+ echo "${TTFINFO_FONT_PSNAME}-ETen-B5-H, $I1, 880, 120, 1000" > $TEMPFILE.2 |
361 |
+ echo "${TTFINFO_FONT_PSNAME}-Bold-ETen-B5-H, $I2, 880, 120, 1000" >> $TEMPFILE.2 |
362 |
+ echo "${TTFINFO_FONT_PSNAME}-Italic-ETen-B5-H, $I3, 880, 120, 1000" >> $TEMPFILE.2 |
363 |
+ echo "${TTFINFO_FONT_PSNAME}-BoldItalic-ETen-B5-H, $I4, 880, 120, 1000" >> $TEMPFILE.2 |
364 |
+ if [ "$TTFINFO_FONT_PSNAME" = "ShanHeiSun-Light" ]; then |
365 |
+ cat $TEMPFILE.2 $TEMPFILE.1 > $TEMPFILE |
366 |
+ else |
367 |
+ cat $TEMPFILE.1 $TEMPFILE.2 > $TEMPFILE |
368 |
+ fi |
369 |
+ LINE=`wc -l < $TEMPFILE` |
370 |
+ echo $LINE > $TWABIFONTPATH/fonts.dir |
371 |
+ cat $TEMPFILE >> $TWABIFONTPATH/fonts.dir |
372 |
+ # zh-HK |
373 |
+ I1=`echo $I1 | sed -e 's/-big5-0$/-big5hkscs-0/'` |
374 |
+ I2=`echo $I2 | sed -e 's/-big5-0$/-big5hkscs-0/'` |
375 |
+ I3=`echo $I3 | sed -e 's/-big5-0$/-big5hkscs-0/'` |
376 |
+ I4=`echo $I4 | sed -e 's/-big5-0$/-big5hkscs-0/'` |
377 |
+ J1=`echo $I1|cut -c2-` |
378 |
+ J2=`echo $I2|cut -c2-` |
379 |
+ J3=`echo $I3|cut -c2-` |
380 |
+ J4=`echo $I4|cut -c2-` |
381 |
+ grep -v "$J1" $HKABIFONTPATH/fonts.dir |grep -v "$J2" |grep -v "$J3" |grep -v "$J4" |sed -e "1d" > $TEMPFILE |
382 |
+ grep -i '[[:space:]]\+-[^-]\+-[^-]\+HKSCS-' $TEMPFILE > $TEMPFILE.1 |
383 |
+ grep -vi '[[:space:]]\+-[^-]\+-[^-]\+HKSCS-' $TEMPFILE > $TEMPFILE.2 |
384 |
+ echo "${TTFINFO_FONT_PSNAME}-HKscs-B5-H, $I1, 880, 120, 1000" > $TEMPFILE.3 |
385 |
+ echo "${TTFINFO_FONT_PSNAME}-Bold-HKscs-B5-H, $I2, 880, 120, 1000" >> $TEMPFILE.3 |
386 |
+ echo "${TTFINFO_FONT_PSNAME}-Italic-HKscs-B5-H, $I3, 880, 120, 1000" >> $TEMPFILE.3 |
387 |
+ echo "${TTFINFO_FONT_PSNAME}-BoldItalic-HKscs-B5-H, $I4, 880, 120, 1000" >> $TEMPFILE.3 |
388 |
+ if ( echo $I1 | grep -qi '^-[^-]\+-[^-]*HKSCS-' ); then |
389 |
+ if [ "$TTFINFO_FONT_PSNAME" = "InnMing-Light" ]; then |
390 |
+ cat $TEMPFILE.3 $TEMPFILE.1 $TEMPFILE.2 > $TEMPFILE |
391 |
+ else |
392 |
+ cat $TEMPFILE.1 $TEMPFILE.3 $TEMPFILE.2 > $TEMPFILE |
393 |
+ fi |
394 |
+ elif [ "$TTFINFO_FONT_PSNAME" = "ShanHeiSun-Light" ]; then |
395 |
+ cat $TEMPFILE.1 $TEMPFILE.3 $TEMPFILE.2 > $TEMPFILE |
396 |
+ else |
397 |
+ cat $TEMPFILE.1 $TEMPFILE.2 $TEMPFILE.3 > $TEMPFILE |
398 |
+ fi |
399 |
+ LINE=`wc -l < $TEMPFILE` |
400 |
+ echo $LINE > $HKABIFONTPATH/fonts.dir |
401 |
+ cat $TEMPFILE >> $HKABIFONTPATH/fonts.dir |
402 |
+ ;; |
403 |
+ gb2312.1980) |
404 |
+ # zh-CN |
405 |
+ grep -v "$J1" $CNABIFONTPATH/fonts.dir|grep -v "$J2"|grep -v "$J3"|grep -v "$J4"|sed -e "1d" > $TEMPFILE |
406 |
+ echo "${TTFINFO_FONT_PSNAME}-GB-EUC-H, $I1, 880, 120, 1000" >> $TEMPFILE |
407 |
+ echo "${TTFINFO_FONT_PSNAME}-Bold-GB-EUC-H, $I2, 880, 120, 1000" >> $TEMPFILE |
408 |
+ echo "${TTFINFO_FONT_PSNAME}-Italic-GB-EUC-H, $I3, 880, 120, 1000" >> $TEMPFILE |
409 |
+ echo "${TTFINFO_FONT_PSNAME}-BoldItalic-GB-EUC-H, $I4, 880, 120, 1000" >> $TEMPFILE |
410 |
+ LINE=`wc -l < $TEMPFILE` |
411 |
+ echo $LINE > $CNABIFONTPATH/fonts.dir |
412 |
+ cat $TEMPFILE >> $CNABIFONTPATH/fonts.dir |
413 |
+ # zh-CN.GBK |
414 |
+ I1=`echo $I1 | sed -e 's/-gb2312.1980-0$/-gbk-0/'` |
415 |
+ I2=`echo $I2 | sed -e 's/-gb2312.1980-0$/-gbk-0/'` |
416 |
+ I3=`echo $I3 | sed -e 's/-gb2312.1980-0$/-gbk-0/'` |
417 |
+ I4=`echo $I4 | sed -e 's/-gb2312.1980-0$/-gbk-0/'` |
418 |
+ J1=`echo $I1|cut -c2-` |
419 |
+ J2=`echo $I2|cut -c2-` |
420 |
+ J3=`echo $I3|cut -c2-` |
421 |
+ J4=`echo $I4|cut -c2-` |
422 |
+ grep -v "$J1" $CNABIFONTPATH.GBK/fonts.dir |grep -v "$J2" |grep -v "$J3" |grep -v "$J4" |sed -e "1d" > $TEMPFILE |
423 |
+ echo "${TTFINFO_FONT_PSNAME}-GBK-EUC-H, $I1, 880, 120, 1000" >> $TEMPFILE |
424 |
+ echo "${TTFINFO_FONT_PSNAME}-Bold-GBK-EUC-H, $I2, 880, 120, 1000" >> $TEMPFILE |
425 |
+ echo "${TTFINFO_FONT_PSNAME}-Italic-GBK-EUC-H, $I3, 880, 120, 1000" >> $TEMPFILE |
426 |
+ echo "${TTFINFO_FONT_PSNAME}-BoldItalic-GBK-EUC-H, $I4, 880, 120, 1000" >> $TEMPFILE |
427 |
+ LINE=`wc -l < $TEMPFILE` |
428 |
+ echo $LINE > $CNABIFONTPATH.GBK/fonts.dir |
429 |
+ cat $TEMPFILE >> $CNABIFONTPATH.GBK/fonts.dir |
430 |
+ ;; |
431 |
+# ksc5601.1987) |
432 |
+# echo |
433 |
+# ;; |
434 |
+# jisx0208.1983|jisx0201.1976) |
435 |
+# echoC "todo" |
436 |
+# ;; |
437 |
+ esac |
438 |
+ i=$(($i+1)) # Linux should use bash...:) |
439 |
+ done |
440 |
done |
441 |
+ return $error |
442 |
} |
443 |
|
444 |
|
445 |
-# |
446 |
-# Set default font, accept kai or ming(default) only, all others will be |
447 |
-# treated as ming, eg. |
448 |
-# "setdefault kai /usr/local/share/fonts/TrueType/bkai00mp.ttf". |
449 |
-# |
450 |
-# setdefault() causes chain effects, ie. setdefault() in AbiWord WILL |
451 |
-# make that font default both in X Window or Ghostscript. While we can |
452 |
-# make AbiWord's default font an ordinary TTF in X Window, it's hard |
453 |
-# to do so do so with Ghostscript. |
454 |
-# |
455 |
-# One implication of this behaviour is that the default fonts of Abiword, |
456 |
-# Ghostscript, and X Window have to be the same. If they're not in sync, |
457 |
-# strange problems may arise. |
458 |
-# |
459 |
-setdefault() |
460 |
+# Remove ttf fonts |
461 |
+remove_fonts() |
462 |
{ |
463 |
- face=$1 |
464 |
- addfile=$2 |
465 |
- # Some sanity checking |
466 |
- if [ ! -r "$addfile" ]; then |
467 |
- echo "$addfile does not exist, skipped." |
468 |
- continue |
469 |
- fi |
470 |
- if [ -z "`echo $addfile |grep -i -e ".*tt[cf]$"`" ]; then |
471 |
- echo "$addfile is not a TTF, skipped." |
472 |
- continue |
473 |
- fi |
474 |
- # Those modules will manage if fonts are already installed. |
475 |
- $TTFM --add $XMODULE $addfile |
476 |
- $TTFM --add $GSMODULE $addfile |
477 |
- if [ "$face" = "kai" ]; then |
478 |
- $TTFM --setdefault_kai $XMODULE $addfile |
479 |
- $TTFM --setdefault_kai $GSMODULE $addfile |
480 |
- else |
481 |
- $TTFM --setdefault $XMODULE $addfile |
482 |
- $TTFM --setdefault $GSMODULE $addfile |
483 |
- fi |
484 |
- |
485 |
- f="`basename "$addfile"`" |
486 |
- # We know it's default, but which encoding is unknown. |
487 |
- xlfd="`$TTFM --list $XMODULE |grep $f |sed -e "/iso/d" -e "s/$f //g" |sort |uniq`" |
488 |
- encoding=`echo $xlfd |cut -d '-' -f 14-15` |
489 |
- subdir="`printf "$ed_table" |awk -F "," -v i=$encoding '{dir[$2]=$1} END {print dir[i]}'`" |
490 |
- cidname="`$TTFM --list $GSMODULE |grep -e "^Default.*$f" |cut -d '(' -f 1`" |
491 |
- psname="$cidname"-"`printf "$ep_table" |awk -F "," -v i=$encoding '{ps[$1]=$2} END {print ps[i]}'`" |
492 |
- |
493 |
- if [ ! -d $ABIFontPath/$subdir ]; then |
494 |
- mkdir -p $ABIFontPath/$subdir |
495 |
- fi |
496 |
- touch $ABIFontPath/$subdir/.already-in-fp |
497 |
- if [ ! -r $ABIFontPath/$subdir/fonts.dir ]; then |
498 |
- echo 0 > $ABIFontPath/$subdir/fonts.dir |
499 |
- fi |
500 |
- cp $ABIFontPath/$subdir/fonts.dir $TEMPFILE |
501 |
- # There may be spaces in $xlfd, quote it. |
502 |
- abifont="$psname, $xlfd, $PRINTPARAM" |
503 |
- echo $abifont >> $TEMPFILE |
504 |
- echo $abifont |sed -e "s/-medium-r-/-bold-r-/g" >> $TEMPFILE |
505 |
- echo $abifont |sed -e "s/-medium-r-/-medium-i-/g" >> $TEMPFILE |
506 |
- echo $abifont |sed -e "s/-medium-r-/-bold-i-/g" >> $TEMPFILE |
507 |
- num=`cat $TEMPFILE |wc -l` |
508 |
- num=`expr $num - 1` |
509 |
- sed -e "1s/.*/$num/g" $TEMPFILE > $ABIFontPath/$subdir/fonts.dir |
510 |
+ error=0 |
511 |
+ for f in "$@"; do |
512 |
+ if [ ! -e "$f" ]; then |
513 |
+ if [ -e "$DEFAULTPATH/$f" ]; then |
514 |
+ f="$DEFAULTPATH/$f" |
515 |
+ else |
516 |
+ echo "Cannot find font $f, ignored!" |
517 |
+ error=$(($error+1)) |
518 |
+ continue |
519 |
+ fi |
520 |
+ fi |
521 |
+ |
522 |
+ fontfile=`basename $f` |
523 |
+ eval `echo $fontfile | awk -F. '{ printf "font=%s;ext=%s",\$1,\$2 }'` |
524 |
+ |
525 |
+ get_ttfinfo $f |
526 |
+ i=1 |
527 |
+ while [ $i -le $TTFINFO_MAPNUM ]; do |
528 |
+ eval I1=\$TTFINFO_FONTMAP${i} |
529 |
+ I2=`echo $I1|sed -e s/medium-r/bold-r/` |
530 |
+ I3=`echo $I1|sed -e s/medium-r/medium-i/` |
531 |
+ I4=`echo $I1|sed -e s/medium-r/bold-i/` |
532 |
+ J1=`echo $I1|cut -c2-` |
533 |
+ J2=`echo $I2|cut -c2-` |
534 |
+ J3=`echo $I3|cut -c2-` |
535 |
+ J4=`echo $I4|cut -c2-` |
536 |
+ MYENC=`echo $I1 | awk -F- '{print $14}'` |
537 |
+ case $MYENC in |
538 |
+ big5) |
539 |
+ # zh-TW |
540 |
+ grep -v "$J1" $TWABIFONTPATH/fonts.dir |grep -v "$J2" |grep -v "$J3" |grep -v "$J4" |sed -e "1d" > $TEMPFILE |
541 |
+ LINE=`wc -l < $TEMPFILE` |
542 |
+ echo $LINE > $TWABIFONTPATH/fonts.dir |
543 |
+ cat $TEMPFILE >> $TWABIFONTPATH/fonts.dir |
544 |
+ # zh-HK |
545 |
+ I1=`echo $I1 | sed -e 's/-big5-0$/-big5hkscs-0/'` |
546 |
+ I2=`echo $I2 | sed -e 's/-big5-0$/-big5hkscs-0/'` |
547 |
+ I3=`echo $I3 | sed -e 's/-big5-0$/-big5hkscs-0/'` |
548 |
+ I4=`echo $I4 | sed -e 's/-big5-0$/-big5hkscs-0/'` |
549 |
+ J1=`echo $I1|cut -c2-` |
550 |
+ J2=`echo $I2|cut -c2-` |
551 |
+ J3=`echo $I3|cut -c2-` |
552 |
+ J4=`echo $I4|cut -c2-` |
553 |
+ grep -v "$J1" $HKABIFONTPATH/fonts.dir |grep -v "$J2" |grep -v "$J3" |grep -v "$J4" |sed -e "1d" > $TEMPFILE |
554 |
+ LINE=`wc -l < $TEMPFILE` |
555 |
+ echo $LINE > $HKABIFONTPATH/fonts.dir |
556 |
+ cat $TEMPFILE >> $HKABIFONTPATH/fonts.dir |
557 |
+ ;; |
558 |
+ gb2312.1980) |
559 |
+ # zh-CN |
560 |
+ grep -v "$J1" $CNABIFONTPATH/fonts.dir|grep -v "$J2"|grep -v "$J3"|grep -v "$J4"|sed -e "1d" > $TEMPFILE |
561 |
+ LINE=`wc -l < $TEMPFILE` |
562 |
+ echo $LINE > $CNABIFONTPATH/fonts.dir |
563 |
+ cat $TEMPFILE >> $CNABIFONTPATH/fonts.dir |
564 |
+ # zh-CN.GBK |
565 |
+ I1=`echo $I1 | sed -e 's/-gb2312.1980-0$/-gbk-0/'` |
566 |
+ I2=`echo $I2 | sed -e 's/-gb2312.1980-0$/-gbk-0/'` |
567 |
+ I3=`echo $I3 | sed -e 's/-gb2312.1980-0$/-gbk-0/'` |
568 |
+ I4=`echo $I4 | sed -e 's/-gb2312.1980-0$/-gbk-0/'` |
569 |
+ J1=`echo $I1|cut -c2-` |
570 |
+ J2=`echo $I2|cut -c2-` |
571 |
+ J3=`echo $I3|cut -c2-` |
572 |
+ J4=`echo $I4|cut -c2-` |
573 |
+ grep -v "$J1" $CNABIFONTPATH.GBK/fonts.dir |grep -v "$J2" |grep -v "$J3" |grep -v "$J4" |sed -e "1d" > $TEMPFILE |
574 |
+ LINE=`wc -l < $TEMPFILE` |
575 |
+ echo $LINE > $CNABIFONTPATH.GBK/fonts.dir |
576 |
+ cat $TEMPFILE >> $CNABIFONTPATH.GBK/fonts.dir |
577 |
+ ;; |
578 |
+# ksc5601.1987) |
579 |
+# echo |
580 |
+# ;; |
581 |
+# jisx0208.1983|jisx0201.1976) |
582 |
+# echoC "todo" |
583 |
+# ;; |
584 |
+ esac |
585 |
+ i=$(($i+1)) # Linux should use bash...:) |
586 |
+ done |
587 |
+ done |
588 |
+ return $error |
589 |
} |
590 |
|
591 |
|
592 |
@@ -306,8 +350,6 @@ |
593 |
exit 1 |
594 |
fi |
595 |
|
596 |
-check_abiword |
597 |
- |
598 |
ARG=$1 |
599 |
shift 1 |
600 |
|
601 |
@@ -316,52 +358,36 @@ |
602 |
Usage |
603 |
;; |
604 |
--name) |
605 |
+ echo |
606 |
echo "$NAME $VERSION" |
607 |
+ echo |
608 |
;; |
609 |
--list) |
610 |
list_fonts |
611 |
;; |
612 |
--add) |
613 |
if [ $# -lt 1 ]; then |
614 |
- echo "Missing font filename argument." |
615 |
+ echo "Missing font filename argument!" |
616 |
Usage |
617 |
exit 1 |
618 |
fi |
619 |
add_fonts $@ |
620 |
- echo "Adding $@." |
621 |
+ echo "Done!" |
622 |
;; |
623 |
--remove) |
624 |
if [ $# -lt 1 ]; then |
625 |
- echo "Missing font filename argument." |
626 |
+ echo "Missing font filename argument!" |
627 |
Usage |
628 |
exit 1 |
629 |
fi |
630 |
remove_fonts $@ |
631 |
- echo "Removing $@." |
632 |
+ echo "Done!" |
633 |
;; |
634 |
--setdefault|--setdefault_ming) |
635 |
- if [ $# -lt 1 ]; then |
636 |
- echo "Missing font filename arguments." |
637 |
- Usage |
638 |
- exit 1 |
639 |
- elif [ $# -gt 1 ]; then |
640 |
- echo "Only need one font filename." |
641 |
- Usage |
642 |
- exit 1 |
643 |
- fi |
644 |
- setdefault ming $1 |
645 |
+ echo "No need to set default fonts" |
646 |
;; |
647 |
--setdefault_kai) |
648 |
- if [ $# -lt 1 ]; then |
649 |
- echo "Missing font filename arguments." |
650 |
- Usage |
651 |
- exit 1 |
652 |
- elif [ $# -gt 1 ]; then |
653 |
- echo "Only need one font filename." |
654 |
- Usage |
655 |
- exit 1 |
656 |
- fi |
657 |
- setdefault kai $1 |
658 |
+ echo "No need to set default fonts" |
659 |
;; |
660 |
*) |
661 |
Usage |
662 |
@@ -369,7 +395,18 @@ |
663 |
;; |
664 |
esac |
665 |
|
666 |
-rm -f $TEMPFILE |
667 |
+rm -f $TEMPFILE $TEMPFILE.1 $TEMPFILE.2 $TEMPFILE.3 |
668 |
exit 0 |
669 |
|
670 |
|
671 |
+# ChangeLog |
672 |
+# |
673 |
+# * Fri Jan 12 2001 Chung-Yen Chang <candyz@cle.linux.org.tw> |
674 |
+# - first release |
675 |
+# |
676 |
+# * Tue Sep 4 2001 Anthony Fok <anthony@thizlinux.com> |
677 |
+# - Added Big5-HKSCS font support thanks to ThizLinux Laboratory Ltd., Thiz |
678 |
+# Technology Group. Also added preliminary GBK support |
679 |
+# - Use the _real_ PostScript font names, and with Bold, Italic and BoldItalic |
680 |
+# - List InnMing-Light / HKSCS (zh_HK) or ShanHeiSun-Light (zh_TW) first |
681 |
+# |