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

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

glyph-module

glyph-block Letter-Cyrillic-Abkhasian-Ha : begin
	glyph-block-import CommonShapes
	glyph-block-import Common-Derivatives

	define [CyrlAbkHaShape df top sm] : begin
		local ada : ArchDepthAOf sm df.width
		local adb : ArchDepthBOf sm df.width
		local ada2 : ArchDepthAOf (0.625 * sm) df.width
		local adb2 : ArchDepthBOf (0.625 * sm) df.width
		local xm : df.middle - [HSwToV : 0.5 * df.mvs]
		local y2 : top * 0.75
		return : dispiro
			arch.lhs.centerAt.rtl.t df.middle top (sw -- df.mvs) (knot-ty -- g4.left.start)
			archv
			flat (df.leftSB + OX) (top - ada)
			curl (df.leftSB + OX) adb
			arch.lhs 0 (sw -- df.mvs)
			straight.up.mid (df.rightSB - OX) [YSmoothMidR (y2 + df.mvs / 2) 0 ada2 adb2]
			arch.lhs y2 (sw -- df.mvs)
			straight.down.mid xm [YSmoothMidL (y2 + df.mvs / 2) 0 ada2 adb2]
			arcvh
			g4 (df.rightSB - O) O


	create-glyph 'cyrl/abk/Ha' 0x4A8 : glyph-proc
		define df : include : DivFrame para.advanceScaleM 3
		include : df.markSet.capital
		include : CyrlAbkHaShape df CAP ArchDepth

	create-glyph 'cyrl/abk/ha' 0x4A9 : glyph-proc
		define df : include : DivFrame para.advanceScaleM 3
		include : df.markSet.e
		include : CyrlAbkHaShape df XH SmallArchDepth
