# 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

if [[ $PV == 9999 ]]; then
	inherit git-r3
	EGIT_REPO_URI="$HOMEPAGE.git"
else
	SRC_URI="$HOMEPAGE/archive/v$PV.tar.gz -> $P.tar.gz"
	KEYWORDS='~*'
	S="$WORKDIR/$PN"
fi

LICENSE=OFL-1.1
SLOT=0

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

BDEPEND=media-gfx/fontforge

FONT_S="$S/dist"

src_compile() {
	local makeargs=()

	for font in a b; do
		use type-$font || continue

		for type in ttf otf; do
			use $type || continue
			use plain && makeargs+=( dist/OpenGostType${font^}-Regular.$type )
			use ostroke &&
				makeargs+=( dist/OpenGostType${font^}-Regular-ostroke.$type )
		done
	done

	einfo "Call make targets: ${makeargs[*]}"
	emake "${makeargs[@]}"
}

src_install() {
	einstalldocs

	local suffixes=()
	use ttf && suffixes+=( ttf )
	use otf && suffixes+=( otf )

	FONT_SUFFIX="${suffixes[*]}"

	font_src_install
}