summaryrefslogtreecommitdiff
blob: dca1e3b3ba1f313404fd33c864e486ba3afa91b6 (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
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=5

inherit readme.gentoo versionator

MY_PV=$(replace_version_separator 3 "-")
DESCRIPTION="A set of rendering and font replacement rules for fontconfig-infinality"
HOMEPAGE="http://bohoomil.com/"
SRC_URI="https://github.com/bohoomil/fontconfig-ultimate/archive/v${MY_PV}.tar.gz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
IUSE="+fonts-ms +fonts-free fonts-extra fonts-non-latin"

RDEPEND="app-eselect/eselect-infinality
	app-eselect/eselect-lcdfilter
	media-libs/fontconfig-infinality
	media-libs/freetype:2[infinality]
	fonts-ms? (
		media-fonts/corefonts
		media-fonts/dejavu
		media-fonts/droid
		media-fonts/notofonts
		fonts-extra? (
			media-fonts/cantarell
			media-fonts/croscorefonts
			media-fonts/droid
			media-fonts/font-bh-75dpi
			media-fonts/paratype
			media-fonts/urw-fonts
		)
	)
	fonts-free? (
		media-fonts/dejavu
		media-fonts/notofonts
		media-fonts/liberation-fonts
		media-fonts/heuristica
		media-fonts/symbola
		fonts-extra? (
			media-fonts/cantarell
			media-fonts/croscorefonts
			media-fonts/droid
			media-fonts/font-bh-ttf
			media-fonts/libertine-ttf
			media-fonts/paratype
			media-fonts/source-pro
			media-fonts/ubuntu-font-family
			media-fonts/urw-fonts
		)
	)
	fonts-non-latin? (
		media-fonts/font-misc-meltho
		media-fonts/ja-ipafonts
		media-fonts/lklug
		media-fonts/lohit-fonts
		media-fonts/nanumfont
		media-fonts/wqy-microhei
	)"

S=${WORKDIR}/${PN}-${MY_PV}

DISABLE_AUTOFORMATTING="1"
DOC_CONTENTS="1. Disable all rules but 52-infinality.conf using eselect fontconfig
2. Enable one of \"ultimate\" presets using eselect infinality
3. Select ultimate lcdfilter settings using eselect lcdfilter"

src_prepare() {
	# Generate lcdfilter config
	echo -e "################# FONTCONFIG ULTIMATE STYLE #################\n" \
	> "${T}"/ultimate || die

	local infinality_style
	infinality_style=$(sed --quiet \
		-e 's/^USE_STYLE="*\([1-9]\)"*/\1/p' \
		freetype/infinality-settings.sh) || die

	if ! [ -n "$infinality_style" ]; then
		ewarn "Missing USE_STYLE variable in package source."
		infinality_style=1
	fi

	sed --quiet \
		-e '/INFINALITY_FT_FILTER_PARAMS=/p' \
		freetype/infinality-settings.sh \
	| sed --quiet \
		-e "${infinality_style} s/[ \t]*export[ \t]*//p" \
	>> "${T}"/ultimate
	assert

	sed --quiet \
		-e '/INFINALITY_FT_FILTER_PARAMS/ d' \
		-e 's/^[ \t]*export[ \t]*INFINALITY_FT/INFINALITY_FT/p' \
		freetype/infinality-settings.sh \
	>> "${T}"/ultimate || die
}

src_install() {
	insinto /etc/fonts/infinality/conf.src.ultimate
	doins conf.d.infinality/*.conf
	doins fontconfig_patches/{ms,free,combi}/*.conf

	# Cut a list of default .conf files out of Makefile.am
	local default_configs config
	default_configs=$(sed --quiet \
		-e ':again' \
		-e '/\\$/ N' \
		-e 's/\\\n/ /' \
		-e 't again' \
		-e 's/^CONF_LINKS =//p' \
		conf.d.infinality/Makefile.am) || die

	cd fontconfig_patches/ms || die
	for config in ${default_configs} *.conf; do
		dosym ../../conf.src.ultimate/"${config}" \
			/etc/fonts/infinality/styles.conf.avail/ultimate-ms/"${config}"
	done
	cd ../../fontconfig_patches/free || die
	for config in ${default_configs} *.conf; do
		dosym ../../conf.src.ultimate/"${config}" \
			/etc/fonts/infinality/styles.conf.avail/ultimate-free/"${config}"
	done
	cd ../../fontconfig_patches/combi || die
	for config in ${default_configs} *.conf; do
		dosym ../../conf.src.ultimate/"${config}" \
			/etc/fonts/infinality/styles.conf.avail/ultimate-combi/"${config}"
	done
	cd "${S}"

	insinto /etc/fonts/conf.avail
	doins fontconfig_patches/ftypes/*.conf

	insinto /usr/share/eselect-lcdfilter/env.d
	doins "${T}"/ultimate

	readme.gentoo_create_doc
}