]> git.wh0rd.org - fontconfig.git/blob - debian/fontconfig.postinst
file fc-match.sgml was initially added on branch fc-2_4_branch.
[fontconfig.git] / debian / fontconfig.postinst
1 #!/bin/sh
2
3 set -e
4
5 . /usr/share/debconf/confmodule
6
7 LOCALCONF=/var/lib/fontconfig/local.conf
8 rm -f $LOCALCONF
9
10 CONFDIR=/etc/fonts/conf.d
11
12 db_get fontconfig/hinting_type
13 hinting_type="$RET"
14
15 hint_prio="10-debconf-"
16 unhinted="unhinted.conf"
17 autohint="autohint.conf"
18
19 if [ -h $CONFDIR/$hint_prio$unhinted ]; then
20 rm $CONFDIR/$hint_prio$unhinted
21 fi
22 if [ -h $CONFDIR/$hint_prio$autohint ]; then
23 rm $CONFDIR/$hint_prio$autohint
24 fi
25
26 case "$hinting_type" in
27 "Native")
28 ;;
29 "Autohinter")
30 ln -s $CONFDIR/$autohint $CONFDIR/$hint_prio$autohint
31 ;;
32 "None")
33 ln -s $CONFDIR/$unhinted $CONFDIR/$hint_prio$unhinted
34 ;;
35 esac
36
37 db_get fontconfig/subpixel_rendering
38 subpixel_rendering="$RET"
39
40 subpixel_prio="20-debconf-"
41 subpixel="sub-pixel.conf"
42 no_subpixel="no-sub-pixel.conf"
43
44 if [ -h $CONFDIR/$subpixel_prio$subpixel ]; then
45 rm $CONFDIR/$subpixel_prio$subpixel
46 fi
47
48 if [ -h $CONFDIR/$subpixel_prio$no_subpixel ]; then
49 rm $CONFDIR/$subpixel_prio$no_subpixel
50 fi
51
52 case "$subpixel_rendering" in
53 "Automatic")
54 ;;
55 "Always")
56 ln -s $CONFDIR/$subpixel $CONFDIR/$subpixel_prio$subpixel
57 ;;
58 "Never")
59 ln -s $CONFDIR/$no_subpixel $CONFDIR/$subpixel_prio$no_subpixel
60 ;;
61 esac
62
63 db_get fontconfig/enable_bitmaps
64 enable_bitmaps="$RET"
65
66 bitmaps_prio="30-debconf-"
67 yes_bitmaps="yes-bitmaps.conf"
68 no_bitmaps="no-bitmaps.conf"
69
70 if [ -h $CONFDIR/$bitmaps_prio$yes_bitmaps ]; then
71 rm $CONFDIR/$bitmaps_prio$yes_bitmaps
72 fi
73
74 if [ -h $CONFDIR/$bitmaps_prio$no_bitmaps ]; then
75 rm $CONFDIR/$bitmaps_prio$no_bitmaps
76 fi
77
78 case "$enable_bitmaps" in
79 "true")
80 #
81 # Bitmap fonts will be enabled by default, so there's no need
82 # to use this configuration file. However, the file remains useful if
83 # you want to force bitmaps to be considered even when some application
84 # disables them.
85 #
86 # ln -s $CONFDIR/$yes_bitmaps $CONFDIR/$bitmaps_prio$yes_bitmaps
87 ;;
88 *)
89 ln -s $CONFDIR/$no_bitmaps $CONFDIR/$bitmaps_prio$no_bitmaps
90 ;;
91 esac
92
93 cp /dev/null $LOCALCONF
94 rm -f $LOCALCONF.md5sum
95 ln -sf /usr/share/fontconfig/local.conf.md5sum $LOCALCONF.md5sum
96 ucf --debconf-ok $LOCALCONF /etc/fonts/local.conf
97 rm -f $LOCALCONF.md5sum
98
99 # if the local.conf file is now empty, remove it
100
101 if [ -s /etc/fonts/local.conf ]; then
102 :
103 else
104 if [ -f /etc/fonts/local.conf ]; then
105 rm /etc/fonts/local.conf
106 fi
107 fi
108
109 # Create /usr/local/share/fonts
110 LOCALDIR=/usr/local/share/fonts
111 if [ ! -d $LOCALDIR ]; then
112 if mkdir $LOCALDIR 2>/dev/null ; then
113 chmod 2775 $LOCALDIR
114 chown root:staff $LOCALDIR
115 fi
116 fi
117
118 if [ "$1" = configure ]; then
119 # Ensure Defoma subst file exists, with some default substitutions
120 if ! defoma-subst check-rule fontconfig; then
121 defoma-subst new-rule fontconfig \
122 'serif --GeneralFamily,* Roman --Shape Serif Upright --Weight Medium' \
123 'sans-serif --GeneralFamily,* SansSerif --Shape NoSerif Upright --Weight Medium' \
124 'monospace --Width,* Fixed --GeneralFamily,2 Typewriter --Shape Upright --Weight Medium'
125 fi
126 fi
127
128 if [ -d /var/lib/defoma/x-ttcidfont-conf.d ]; then
129 # Remove old fonts.cache-1 files
130 find /var/lib/defoma/x-ttcidfont-conf.d -name fonts.cache-1 | xargs rm -f
131 fi
132
133 #DEBHELPER#
134
135 if [ "$1" = configure ]; then
136 # (Hacked up from Red Hat 8 fontconfig RPM)
137 # Force regeneration of all fontconfig cache files.
138 # The redirect is because fc-cache is giving warnings about ~/fc.cache
139 # the HOME setting is to avoid problems if HOME hasn't been reset
140 printf "Regenerating fonts cache... "
141 HOME=/root fc-cache -f -v 1>/var/log/fontconfig.log 2>&1 || (printf "failed.\nSee /var/log/fontconfig.log for more information.\n"; exit 1)
142 printf "done.\n"
143 fi
144
145 exit 0