# Copyright 2026 Nadeŭka <me+oss@nadevko.cc>
# Distributed under the terms of the GNU General Public License v2
EAPI=8

inherit font

DESCRIPTION='Open-source GOST 2.304-81 compliant fonts family'
HOMEPAGE=https://codeberg.org/nadevko/opengostfonts
SRC_URI="https://codeberg.org/nadevko/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
S="${WORKDIR}"/${PN}
FONT_S="${S}"/dist
LICENSE=OFL-1.1

SLOT=0
KEYWORDS=amd64
IUSE='+type-a +type-b +ttf otf +plain ostroke'
REQUIRED_USE='
	|| ( type-a type-b )
	|| ( ttf otf )
	|| ( plain ostroke )
'

BDEPEND=media-gfx/fontforge

src_compile() {
	local type ext targets=()

	for type in $(usev type-a A) $(usev type-b B); do
		for ext in $(usev ttf) $(usev otf); do
			use plain &&
				targets+=( dist/OpenGostType${type}-Regular.${ext} )
			use ostroke &&
				targets+=( dist/OpenGostType${type}-Regular-ostroke.${ext} )
		done
	done

	emake "${targets[@]}"
}

src_install() {
	local FONT_SUFFIX="$(usev ttf) $(usev otf)"
	font_src_install
}