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

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

glyph-module

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

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

	do "C'o"
		create-glyph 'armn/Co' 0x551 : glyph-proc
			local df : include : DivFrame 1
			include : df.markSet.capital

			local xStart : Math.min df.leftSB : Math.max
				[mix df.leftSB df.rightSB 0.4] - [HSwToV : 1.5 * df.mvs] - jut
				df.leftSB - jut + [HSwToV : 0.5 * df.mvs]

			local midy : CAP * HBarPos
			local midyTop : midy + 0.5 * df.mvs
			local midyBot : midy - 0.5 * df.mvs

			include : dispiro
				widths.lhs df.mvs
				flat xStart midyBot
				curl df.middle midyBot
				archv
				g4 df.rightSB [mix midyBot CAP (ArchDepthA / (ArchDepthA + ArchDepthB))]
				arch.lhs CAP (sw -- df.mvs)
				g4 df.leftSB [mix CAP midyBot (ArchDepthA / (ArchDepthA + ArchDepthB))]
				arcvh
				straight.right.end df.middle midyBot [heading Rightward]
			include : dispiro
				widths.rhs df.mvs
				straight.right.start df.middle midyTop [heading Rightward]
				archv
				g4 (df.rightSB - OX) [mix midyTop 0 (ArchDepthB / (ArchDepthA + ArchDepthB))]
				hookend 0 (sw -- df.mvs)
				g4 (df.leftSB + OX) Hook
