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

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

glyph-module

glyph-block Letter-Armenian-Eh-Liun-Hiun : begin
	glyph-block-import CommonShapes
	glyph-block-import Common-Derivatives
	glyph-block-import Letter-Shared-Shapes : SerifFrame
	glyph-block-import Letter-Armenian-Shared-Shapes : ArmHBar

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

	do "Eh"
		create-glyph 'armn/Eh' 0x537 : glyph-proc
			local df : include : DivFrame 1
			include : df.markSet.capital
			include : VBar.l df.leftSB 0 CAP df.mvs
			include : [ArmHBar.normal : DivFrame (5 / 6)].base
			include : [ArmHBar.normal df].high
			if SLAB : begin
				local sf : SerifFrame.fromDf df CAP 0
				include : composite-proc sf.lt.full sf.lb.outer

		create-glyph 'armn/eh' 0x567 : glyph-proc
			local df : include : DivFrame 1
			include : df.markSet.b
			include : VBar.l df.leftSB 0 Ascender df.mvs
			include : [ArmHBar.normal : DivFrame (5 / 6)].base
			include : [ArmHBar.normal df].high
			if SLAB : begin
				local sf : SerifFrame.fromDf df CAP 0
				include sf.lt.outer
				if [not para.isItalic] : include sf.lb.outer

	do "Liun"
		create-glyph 'armn/Liun' 0x53C : glyph-proc
			local df : include : DivFrame para.advanceScaleF
			include : df.markSet.capital
			include : VBar.l df.leftSB 0 CAP df.mvs
			include : [ArmHBar.normal df].base
			if SLAB : begin
				local sf : SerifFrame.fromDf df CAP 0
				include : composite-proc sf.lt.full sf.lb.outer

		create-glyph 'armn/liun' 0x56C : glyph-proc
			local df : include : DivFrame para.advanceScaleII
			include : df.markSet.p
			local xMiddle : df.middle - [IBalance2 df]
			local longJut : if (df.adws < 1) (jut * [if SLAB 1.5 1]) LongJut
			include : VBar.m xMiddle Descender XH df.mvs
			include : HBar.b xMiddle (xMiddle + longJut) Descender df.mvs
			if SLAB : include : HSerif.lt xMiddle XH Jut df.mvs

	do "Hiun"
		create-glyph 'armn/Hiun' 0x552 : glyph-proc
			local df : include : DivFrame 1
			include : df.markSet.capital
			include : VBar.l df.leftSB 0 CAP df.mvs
			include : [ArmHBar.normal df].high
			if SLAB : begin
				local sf : SerifFrame.fromDf df CAP 0
				include : composite-proc sf.lt.full sf.lb.full

		create-glyph 'armn/hiun' 0x582 : glyph-proc
			local df : include : DivFrame para.advanceScaleF
			include : VBar.l df.leftSB 0 XH df.mvs
			include : [ArmHBar.normal df].base
			if SLAB : begin
				local sf : SerifFrame.fromDf df XH 0
				include sf.lt.outer
				if [not para.isItalic] : begin
					include sf.lb.full
