Tweak japanese/font-mplus-ipa version 1.0.20060520.p1_2
[dports.git] / japanese / font-mplus-ipa / files / pkg-install.in
1 #!/bin/sh
2 # $FreeBSD: japanese/font-mplus-ipa/files/pkg-install.in 340719 2014-01-22 15:52:06Z mat $
3
4 X_FONTSDIR=%%X_FONTSDIR%%/TTF
5
6 catfontsdir ()
7 {
8     while read _IN
9     do
10       case "${_IN}" in
11       *-ipa-M*|[0-9]*|"") ;;
12       *)       echo ${_IN} ;;
13       esac
14     done
15 }
16
17 ROMA=""
18 BOLD="ds=y"
19 ITAL="ai=0.15"
20 OBLI="ai=0.15"
21 RITA="ai=0.08"
22 ROBL="ai=0.08"
23
24 make_xlfd()
25 {
26         _enc=$1
27         _file=$2
28         _vendor=$3
29         _fname=$4
30         _poc=$5
31
32         case "${_poc}:${_enc}" in
33         p:jisx0201.1976-*)      PFIX="bw=0.5" ;;
34         c:jisx0201.1976-*)      PFIX="bw=0.5" ;;
35         p:*)                    PFIX="" ;;
36         c:*)                    PFIX="" ;;
37         esac
38
39         set --  "${ROMA}"       medium-r \
40                 ${BOLD}         bold-r \
41                 ${ITAL}         medium-i \
42                 ${ITAL}:${BOLD} bold-i \
43                 ${OBLI}         medium-o \
44                 ${OBLI}:${BOLD} bold-o \
45                 ${RITA}         medium-ri \
46                 ${RITA}:${BOLD} bold-ri \
47                 ${ROBL}         medium-ro \
48                 ${ROBL}:${BOLD} bold-ro
49         while [ $# != 0 ]; do
50                 _prefix="${PFIX}:$1"; shift
51                 _variant=$1; shift
52                 printf "%s:%s -%s-%s-%s-normal--0-0-0-0-%s-0-%s\n" \
53                         $_prefix $_file $_vendor $_fname $_variant $_poc $_enc
54         done | sed -e 's,::,:,g' -e 's,^:,,'
55 }
56
57 addentries ()
58 {
59         for ENC in iso8859-1 iso10646-1 jisx0201.1976-0 jisx0208.1983-0 jisx0208.1990-0
60         do
61                 make_xlfd $ENC M+2VM+IPAG-circle.ttf ipa M+2VM+IPAG_circle c
62                 make_xlfd $ENC M+1VM+IPAG-circle.ttf ipa M+1VM+IPAG_circle c
63                 make_xlfd $ENC M+1P+IPAG.ttf ipa M+1P+IPAG p
64                 make_xlfd $ENC M+1P+IPAG-circle.ttf ipa M+1P+IPAG_circle p
65                 make_xlfd $ENC M+2P+IPAG.ttf ipa M+2P+IPAG p
66                 make_xlfd $ENC M+2P+IPAG-circle.ttf ipa M+2P+IPAG_circle p
67         done
68 }
69
70 nfonts ()
71 {
72     _L=0; while read _IN; do _L=$((${_L}+1)); done; echo ${_L}
73 }
74
75 case "$2" in
76 POST-INSTALL)
77         cd ${X_FONTSDIR}
78         touch fonts.dir
79         (catfontsdir < fonts.dir; addentries) > fonts.dir.tmp
80         nfonts < fonts.dir.tmp > fonts.dir
81         cat fonts.dir.tmp >> fonts.dir
82         rm -f fonts.dir.tmp
83         ;;
84 POST-DEINSTALL)
85         cd ${X_FONTSDIR}
86         catfontsdir < fonts.dir > fonts.dir.tmp
87         nfonts < fonts.dir.tmp > fonts.dir
88         cat fonts.dir.tmp >> fonts.dir
89         rm -f fonts.dir.tmp
90         if [ -r fonts.dir -a `wc -l < fonts.dir` = 1 ]; then
91                 rm -f fonts.dir
92         fi
93         rmdir ${X_FONTSDIR} > /dev/null 2>&1 || true
94         ;;
95 esac