aboutsummaryrefslogtreecommitdiffstats
path: root/chinese/moettf/pkg-install
blob: 7dafd5904d288f540dd01ba098655dcd0421bc0d (plain) (blame)
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
#!/bin/sh
FONTDIR=${PKG_PREFIX}/lib/X11/fonts/TrueType
if [ "$2" = "PRE-INSTALL" ]; then
  echo "Please add ${FONTDIR} to your /etc/XF86Config file"
  exit 0
fi
cd ${FONTDIR}

echo "Updating fonts.dir & fonts.alias. This may take a while..."
# Update fonts.dir
touch fonts.dir
sed -e '/ -moe-/d' -e '/ -twmoe-/d' fonts.dir > fonts.dir.tmp
# Add 12 new fonts
numfonts=$(echo $(cat fonts.dir.tmp |wc -l) - 1 + 12 |bc)
if [ ${numfonts} -le 12 ]; then # fonts.dir.tmp is empty
  echo 12 > fonts.dir
else
  echo ${numfonts} > fonts.dir
  sed -e 1d fonts.dir.tmp >> fonts.dir
fi
rm -f fonts.dir.tmp

# Write font information to fonts.dir
for FAMILY in kai lishu sung
do
  echo moe_${FAMILY}.ttf -twmoe-${FAMILY}-medium-r-normal--0-0-0-0-c-0-big5-0 >> fonts.dir
  echo ab=y:moe_${FAMILY}.ttf -twmoe-${FAMILY}-bold-r-normal--0-0-0-0-c-0-big5-0 >> fonts.dir
  echo ai=0.3:moe_${FAMILY}.ttf -twmoe-${FAMILY}-medium-i-normal--0-0-0-0-c-0-big5-0 >> fonts.dir
  echo ab=y:ai=0.3:moe_${FAMILY}.ttf -twmoe-${FAMILY}-bold-i-normal--0-0-0-0-c-0-big5-0 >> fonts.dir
done

# Update fonts.alias, font size ranges from 8 to 128.
# Medium/Bold & Roman/Italic variations are also added.
SIZE=8
touch fonts.alias
sed -e '/^-moe-/d' -e '/^-twmoe-/d' fonts.alias > fonts.alias.tmp
mv -f fonts.alias.tmp fonts.alias
for FAMILY in kai lishu sung
do
  (for WEIGHT in medium bold
   do
     (for SLANT in r i
      do
        (while [ ${SIZE} -le 128 ]
         do
           echo -moe-${FAMILY}-${WEIGHT}-${SLANT}-normal--${SIZE}-`expr ${SIZE} \* 10`-0-0-c-`expr ${SIZE} \* 10`-big5-0 -twmoe-${FAMILY}-${WEIGHT}-${SLANT}-normal--${SIZE}-`expr ${SIZE} \* 10`-0-0-c-`expr ${SIZE} \* 10`-big5-0 >> fonts.alias;
           SIZE=`expr ${SIZE} + 1`;
         done)   # SIZE
      done)   # SLANT
   done)   # WEIGHT
done   # FAMILY