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

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

glyph-module

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

	# Common Params
	define barPos : XH / 2
	define highBarPos XH
	define jut Jut

	do "K'eh"
		create-glyph 'armn/Keh' 0x554 : glyph-proc
			local df : include : DivFrame 1
			include : df.markSet.capital
			local ostroke : OverlayStroke * (df.mvs / Stroke)
			local bot : CAP * HBarPos - df.mvs / 2
			include : OBarLeft.roundedTop
				top   -- CAP
				bot   -- bot
				left  -- df.leftSB
				right -- df.rightSB
				sw    -- df.mvs
				ada   -- ArchDepthA
				adb   -- ArchDepthB
				yTerminal -- 0
			include : HBar.m
				df.leftSB - jut + [HSwToV : 0.5 * df.mvs]
				df.rightSB + 0
				mix [if SLAB df.mvs 0] bot 0.5
				Math.min ostroke : 0.5 * (bot - [if SLAB df.mvs 0])
			if SLAB : begin
				local sf : SerifFrame.fromDf df CAP 0
				include sf.lb.full

		create-glyph 'armn/keh' 0x584 : glyph-proc
			local df : include : DivFrame 1
			include : df.markSet.p
			local ostroke : OverlayStroke * (df.mvs / Stroke)
			local bot : Math.max (0.1 * (XH - Descender)) (1.5 * ostroke)
			include : OBarLeft.shape
				top   -- XH
				bot   -- bot
				left  -- df.leftSB
				right -- df.rightSB
				sw    -- df.mvs
				ada   -- SmallArchDepthA
				adb   -- SmallArchDepthB
			include : VBar.l df.leftSB Descender XH df.mvs
			include : HBar.b
				df.leftSB - jut + [HSwToV : 0.5 * df.mvs]
				df.rightSB + 0
				XH - highBarPos
				1 * ostroke
			if SLAB : begin
				local sf : SerifFrame.fromDf df XH Descender
				include : composite-proc sf.lt.outer sf.lb.fullSide
