summaryrefslogtreecommitdiff
blob: 48ed068767ec6190406f88c3439f66f36e406887 (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
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit font

# [...document.querySelectorAll('[colspan="3"] > b')]
#     .map(x => "[\""
#          + (x = x.innerText.trim()).toLowerCase().replaceAll("\xa0", "-")
#          + "\"]=\""
#          + x
#          + "\"")
#     .join("\n\t")
declare -A MY_FONT_VARIANTS=(
	["iosevka"]="Iosevka"
	["iosevka-slab"]="Iosevka Slab"
	["iosevka-curly"]="Iosevka Curly"
	["iosevka-curly-slab"]="Iosevka Curly Slab"
	["iosevka-ss01"]="Iosevka SS01"
	["iosevka-ss02"]="Iosevka SS02"
	["iosevka-ss03"]="Iosevka SS03"
	["iosevka-ss04"]="Iosevka SS04"
	["iosevka-ss05"]="Iosevka SS05"
	["iosevka-ss06"]="Iosevka SS06"
	["iosevka-ss07"]="Iosevka SS07"
	["iosevka-ss08"]="Iosevka SS08"
	["iosevka-ss09"]="Iosevka SS09"
	["iosevka-ss10"]="Iosevka SS10"
	["iosevka-ss11"]="Iosevka SS11"
	["iosevka-ss12"]="Iosevka SS12"
	["iosevka-ss13"]="Iosevka SS13"
	["iosevka-ss14"]="Iosevka SS14"
	["iosevka-ss15"]="Iosevka SS15"
	["iosevka-ss16"]="Iosevka SS16"
	["iosevka-ss17"]="Iosevka SS17"
	["iosevka-ss18"]="Iosevka SS18"
	["iosevka-aile"]="Iosevka Aile"
	["iosevka-etoile"]="Iosevka Etoile"
)

DESCRIPTION="Slender typeface for code, from code"
HOMEPAGE="https://typeof.net/Iosevka/"

SRC_URI=''
REQUIRED_USE='|| ('
MY_BASE="https://github.com/be5invis/Iosevka/releases/download/v${PV}"
for variant in "${!MY_FONT_VARIANTS[@]}"; do
	my_filename="super-ttc-${variant}-${PV}.zip"

	[[ ${SRC_URI} ]] && SRC_URI+=' '
	SRC_URI+="${variant}? ( ${MY_BASE}/${my_filename} )"

	[[ ${IUSE} ]] && IUSE+=' '
	[[ ${variant} == iosevka ]] && IUSE+='+'
	IUSE+="${variant}"

	REQUIRED_USE+=" ${variant} "
done
REQUIRED_USE+=')'
unset MY_BASE my_filename variant

LICENSE="OFL-1.1"
SLOT="0"
KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc64 ~riscv ~x86"

BDEPEND="app-arch/unzip"

S="${WORKDIR}"
FONT_S="${S}"
FONT_SUFFIX="ttc"

src_prepare() {
	default

	FONT_CONF=()
	local vinternal
	for vinternal in "${!MY_FONT_VARIANTS[@]}"; do
		case "${vinternal}" in
			*-etoile|*-aile)
				continue
				;;
		esac
		local vname="${MY_FONT_VARIANTS[${vinternal}]}"
		use "${vinternal}" || continue
		cat >66-"${vinternal}".conf <<EOF
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- Enable this config to change your monospace font to ${vname} -->
<fontconfig>
	<alias>
		<family>monospace</family>
		<prefer>
			<family>${vname}</family>
		</prefer>
	</alias>
	<alias>
		<family>${vname}</family>
		<default>
			<family>monospace</family>
		</default>
	</alias>
</fontconfig>
EOF
		assert "Failed to generate ${vinternal}"
		FONT_CONF+=( 66-"${vinternal}".conf )
	done
}