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

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


glyph-module

glyph-block Letter-Latin-Flattened-Open-A : begin
	glyph-block-import CommonShapes
	glyph-block-import Common-Derivatives

	create-glyph 'flattenedOpena' : glyph-proc
		local df : include : DivFrame para.advanceScaleMM 3
		include : df.markSet.e

		local top : 0.5 * XH

		local subDf : df.slice 3 2 OX
		local ada : Math.min subDf.smallArchDepthA : top - TINY
		local adb : Math.min subDf.smallArchDepthB : top - TINY

		include : dispiro
			widths.lhs df.mvs
			flat (df.leftSB + OX) top [heading Downward]
			curl (df.leftSB + OX) adb [heading Downward]
			arcvh
			g4   [mix (df.leftSB + OX) (df.middle + [HSwToV : 0.5 * df.mvs]) 0.5] O [heading Rightward]
			archv
			flat (df.middle + [HSwToV : 0.5 * df.mvs]) ada [heading Upward]
			curl (df.middle + [HSwToV : 0.5 * df.mvs]) top [heading Upward]
		include : dispiro
			widths.lhs df.mvs
			flat (df.middle - [HSwToV : 0.5 * df.mvs]) top [heading Downward]
			curl (df.middle - [HSwToV : 0.5 * df.mvs]) adb [heading Downward]
			arcvh
			g4   [mix (df.middle - [HSwToV : 0.5 * df.mvs]) (df.rightSB - OX) 0.5] O [heading Rightward]
			archv
			flat (df.rightSB - OX) ada [heading Upward]
			curl (df.rightSB - OX) top [heading Upward]
