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

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

glyph-module

glyph-block Letter-Armenian-Feh : begin
	glyph-block-import CommonShapes
	glyph-block-import Common-Derivatives
	glyph-block-import Letter-Shared-Shapes : SerifFrame

	define [FehBody df top bot sw hook ada adb] : glyph-proc
		local midy : mix bot top HBarPos
		local midyTop : midy + 0.5 * sw
		local midyBot : midy - 0.5 * sw
		include : dispiro
			widths.lhs sw
			straight.left.start df.middle top
			archv
			g4 df.leftSB [mix top midyBot (ada / (ada + adb))]
			arcvh
			straight.right.end df.middle midyBot [heading Rightward]
		include : dispiro
			widths.rhs sw
			straight.right.start df.middle midyTop [heading Rightward]
			archv
			g4 (df.rightSB - OX) [mix midyTop 0 (adb / (ada + adb))]
			hookend 0 (sw -- sw)
			g4 (df.leftSB + OX) (0 + hook)

	create-glyph 'armn/Feh' 0x556 : glyph-proc
		local df : include : DivFrame para.advanceScaleM 3
		include : df.markSet.capital
		local sw : Math.min df.mvs : AdviceStroke2 3 3 CAP df.adws
		local ada : df.archDepthAOf ArchDepth sw
		local adb : df.archDepthBOf ArchDepth sw
		include : FehBody df CAP 0 sw Hook ada adb
		include : VBar.m df.middle 0 CAP sw
		if SLAB : begin
			local sf : SerifFrame.fromDf df CAP 0 (swSerif -- sw)
			include sf.mt.right

	create-glyph 'armn/feh' 0x586 : glyph-proc
		local df : include : DivFrame para.advanceScaleM 3
		include : df.markSet.bp
		local sw : Math.min df.mvs : AdviceStroke2 3 3 Ascender df.adws
		local ada : df.archDepthAOf SmallArchDepth sw
		local adb : df.archDepthBOf SmallArchDepth sw
		include : FehBody df Ascender 0 sw Hook ada adb
		include : VBar.m df.middle Descender Ascender sw
		if SLAB : begin
			local sf : SerifFrame.fromDf df Ascender Descender (swSerif -- sw)
			include sf.mb.full
