$$include '../../meta/macros.ptl'

import [mix linreg clamp fallback] from "@iosevka/util"

glyph-module

glyph-block Letter-Latin-Sakha-Yat : begin
	glyph-block-import CommonShapes
	glyph-block-import Common-Derivatives
	glyph-block-import Letter-Cyrillic-Yeri : YeriConfig
	glyph-block-import Letter-Cyrillic-Iotified-A : Iotified

	define [SakhaYatShape Yeri df top] : glyph-proc
		include : Yeri top
			left   -- (df.middle - [HSwToV : 0.5 * df.mvs])
			right  -- df.rightSB
			stroke -- df.mvs
			jut    -- [Math.min Jut : Jut * 0.75 * df.adws]

		local fEnoughSpaceForFullSerifs : df.width > 7 * para.refJut
		if [not fEnoughSpaceForFullSerifs] : eject-contour 'serifYeriLB'
		include : Iotified.[if fEnoughSpaceForFullSerifs 'full' 'outer'] df top (df.middle + [HSwToV : 0.5 * df.mvs]) (top - df.mvs * 0.5)

	foreach { suffix { Uc Lc } } [Object.entries YeriConfig] : do
		create-glyph "latn/yatSakha.upright.\(suffix)" : glyph-proc
			local df : include : DivFrame para.advanceScaleMM 3
			include : df.markSet.e
			include : SakhaYatShape Lc df XH

	select-variant 'latn/yatSakha.upright' (follow -- 'cyrl/yeri')
