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

import [mix linreg clamp fallback] from "@iosevka/util"
import [DesignParameters] from "../../meta/aesthetics.mjs"
import [MathSansSerif] from "@iosevka/glyph/relation"

glyph-module

glyph-block Letter-Greek-Lower-Upsilon : begin
	glyph-block-import CommonShapes
	glyph-block-import Common-Derivatives

	alias 'grek/upsilon.straightSerifless' null 'u.toothlessRoundedSerifless'
	alias 'grek/upsilon.straightSerifed'   null 'u.toothlessRoundedMotionSerifed'

	define [LowerUpsilonCasualShape] : with-params [k top ada adb [sw Stroke]] : glyph-proc
		define xArcRight : RightSB - OX
		define yArcRight : [mix 0 top 0.6] - sw * (0.2 + TanSlope)
		define xArcEnd : [mix SB RightSB 0.82] + sw * 0.375
		define yArcEnd : top - O + Stroke * (0.1 - TanSlope)
		include : dispiro
			widths.lhs sw
			flat SB top [heading Downward]
			curl SB adb
			arch.lhs 0 (p -- k) (sw -- sw)
			g4 xArcRight yArcRight
			g4 xArcEnd yArcEnd

	create-glyph 'grek/upsilon.casualSerifless' : glyph-proc
		include : MarkSet.e
		include : LowerUpsilonCasualShape 0.5 XH SmallArchDepthA SmallArchDepthB

	derive-composites 'grek/upsilon.casualSerifed' null 'grek/upsilon.casualSerifless' : HSerif.lt SB XH SideJut

	select-variant 'grek/upsilon' 0x3C5
	link-reduced-variant 'grek/upsilon/sansSerif' 'grek/upsilon' MathSansSerif
