aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/extras/fontconfig/debian/fontconfig.postinst
blob: 7030cdbd274496cdaf8a63d8e398a5a20e7c9d47 (plain)
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
#!/bin/sh

set -e

. /usr/share/debconf/confmodule

LOCALCONF=/var/lib/fontconfig/local.conf
rm -f $LOCALCONF

CONFDIR=/etc/fonts/conf.d

db_get fontconfig/hinting_type
hinting_type="$RET"

hint_prio="10-debconf-"
unhinted="unhinted.conf"
autohint="autohint.conf"

if [ -h $CONFDIR/$hint_prio$unhinted ]; then
	rm $CONFDIR/$hint_prio$unhinted
fi
if [ -h $CONFDIR/$hint_prio$autohint ]; then
	rm $CONFDIR/$hint_prio$autohint
fi
	
case "$hinting_type" in
"Native")
	;;
"Autohinter")
	ln -s $CONFDIR/$autohint $CONFDIR/$hint_prio$autohint
	;;
"None")
	ln -s $CONFDIR/$unhinted $CONFDIR/$hint_prio$unhinted
	;;
esac

db_get fontconfig/subpixel_rendering
subpixel_rendering="$RET"

subpixel_prio="20-debconf-"
subpixel="sub-pixel.conf"
no_subpixel="no-sub-pixel.conf"

if [ -h $CONFDIR/$subpixel_prio$subpixel ]; then
	rm $CONFDIR/$subpixel_prio$subpixel
fi

if [ -h $CONFDIR/$subpixel_prio$no_subpixel ]; then
	rm $CONFDIR/$subpixel_prio$no_subpixel
fi

case "$subpixel_rendering" in
"Automatic")
	;;
"Always")
	ln -s $CONFDIR/$subpixel $CONFDIR/$subpixel_prio$subpixel
	;;
"Never")
	ln -s $CONFDIR/$no_subpixel $CONFDIR/$subpixel_prio$no_subpixel
	;;
esac

db_get fontconfig/enable_bitmaps
enable_bitmaps="$RET"

bitmaps_prio="30-debconf-"
yes_bitmaps="yes-bitmaps.conf"
no_bitmaps="no-bitmaps.conf"

if [ -h $CONFDIR/$bitmaps_prio$yes_bitmaps ]; then
	rm $CONFDIR/$bitmaps_prio$yes_bitmaps
fi

if [ -h $CONFDIR/$bitmaps_prio$no_bitmaps ]; then
	rm $CONFDIR/$bitmaps_prio$no_bitmaps
fi

case "$enable_bitmaps" in
"true")
#
# Bitmap fonts will be enabled by default, so there's no need
# to use this configuration file.  However, the file remains useful if
# you want to force bitmaps to be considered even when some application
# disables them.
#
#	ln -s $CONFDIR/$yes_bitmaps $CONFDIR/$bitmaps_prio$yes_bitmaps
	;;
*)
	ln -s $CONFDIR/$no_bitmaps $CONFDIR/$bitmaps_prio$no_bitmaps
	;;
esac

cp /dev/null $LOCALCONF
rm -f $LOCALCONF.md5sum
ln -sf /usr/share/fontconfig/local.conf.md5sum $LOCALCONF.md5sum
ucf --debconf-ok $LOCALCONF /etc/fonts/local.conf
rm -f $LOCALCONF.md5sum

# if the local.conf file is now empty, remove it

if [ -s /etc/fonts/local.conf ]; then
	:
else
	if [ -f /etc/fonts/local.conf ]; then
		rm /etc/fonts/local.conf
	fi
fi

# Create /usr/local/share/fonts
LOCALDIR=/usr/local/share/fonts
if [ ! -d $LOCALDIR ]; then
  if mkdir $LOCALDIR 2>/dev/null ; then
    chmod 2775 $LOCALDIR
    chown root:staff $LOCALDIR
  fi
fi

if [ "$1" = configure ]; then
  # Ensure Defoma subst file exists, with some default substitutions
  if ! defoma-subst check-rule fontconfig; then
    defoma-subst new-rule fontconfig \
      'serif --GeneralFamily,* Roman --Shape Serif Upright --Weight Medium' \
      'sans-serif --GeneralFamily,* SansSerif --Shape NoSerif Upright --Weight Medium' \
      'monospace --Width,* Fixed --GeneralFamily,2 Typewriter --Shape Upright --Weight Medium'
  fi
fi

if [ -d /var/lib/defoma/x-ttcidfont-conf.d ]; then
  # Remove old fonts.cache-1 files
  find /var/lib/defoma/x-ttcidfont-conf.d -name fonts.cache-1 | xargs rm -f
fi

#DEBHELPER#  

if [ "$1" = configure ]; then
  # (Hacked up from Red Hat 8 fontconfig RPM)
  # Force regeneration of all fontconfig cache files.
  # The redirect is because fc-cache is giving warnings about ~/fc.cache
  # the HOME setting is to avoid problems if HOME hasn't been reset
  printf "Regenerating fonts cache... " 
  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)
  printf "done.\n"
fi

exit 0