$$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-Gim-Group : 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 "Gim"
		create-glyph 'armn/Gim' 0x533 : glyph-proc
			local df : include : DivFrame 1
			include : df.markSet.capital
			local barPosB : barPos - df.mvs / 2
			include : dispiro
				widths.lhs df.mvs
				flat df.rightSB 0 [heading Upward]
				curl df.rightSB (CAP - ArchDepthB)
				arch.lhs CAP (sw -- df.mvs)
				flatside.ld df.leftSB barPosB CAP ArchDepthA ArchDepthB
				arcvh
				flat df.middle barPosB
				curl (df.rightSB + jut * [if SLAB 1.5 1] - [HSwToV : 0.5 * df.mvs]) barPosB [heading Rightward]
			if SLAB : begin
				local sf : SerifFrame.fromDf df CAP 0
				include sf.rb.full

	do "Zhe"
		create-glyph 'armn/Zhe' 0x53A : glyph-proc
			local df : include : DivFrame 1
			include : dispiro
				widths.rhs df.mvs
				flat df.rightSB CAP [heading Downward]
				curl df.rightSB (0 + ArchDepthA)
				arch.rhs 0 (sw -- df.mvs)
				flatside.lu df.leftSB 0 highBarPos ArchDepthA ArchDepthB
				arcvh
				flat df.middle highBarPos
				curl (df.rightSB + jut * [if SLAB 1.5 1] - [HSwToV : 0.5 * df.mvs]) highBarPos [heading Rightward]
			if SLAB : begin
				local sf : SerifFrame.fromDf df CAP 0
				include sf.rt.full

		create-glyph 'armn/zhe' 0x56A : glyph-proc
			local df : include : DivFrame 1
			include : df.markSet.b
			include : dispiro
				widths.rhs df.mvs
				flat df.rightSB Ascender [heading Downward]
				curl df.rightSB (0 + SmallArchDepthA)
				arch.rhs 0 (sw -- df.mvs)
				flatside.lu df.leftSB 0 highBarPos SmallArchDepthA SmallArchDepthB
				arcvh
				flat df.middle highBarPos
				curl (df.rightSB + jut * [if SLAB 1.5 1] - [HSwToV : 0.5 * df.mvs]) highBarPos [heading Rightward]
			if SLAB : begin
				local sf : SerifFrame.fromDf df Ascender 0
				include sf.rt.inner
