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

import [mix slY] from "@iosevka/util"

glyph-module

glyph-block LetterLike-Fraktur-Lower-Z : begin
	glyph-block-import Common-Derivatives
	glyph-block-import CommonShapes
	glyph-block-import LetterLike-Fraktur-Common : LowerDf S F T fraktur-stroke change-pen
	glyph-block-import LetterLike-Fraktur-Common : DecoSizeX DecoSizeY SlopeA SlopeB PHexTop

	create-glyph "frak/z" 0x1D537 : glyph-proc
		local df : include : LowerDf 1
		include : df.markSet.e

		local box : S.box XH Descender df.leftSB df.rightSB

		local upperLoop : include : lift-@ : fraktur-stroke S
			corner                (@xL = box.left)          (@yL + DecoSizeY)
			corner                (@xL2 = @xL + DecoSizeX)  (@yL = [slY @xT @yT @xL2 SlopeA])
			[cg2.sr SlopeB].start (@xT = [box.xp PHexTop])  (@yT = box.top)
			g2.down.mid           (@xR = box.right)         [mix @yT @yC 0.45]
			[g2c.sl SlopeA].end   [box.xp 0.375]            (@yC = [box.yp 0.55])

		local lowerLoop : include : lift-@ : fraktur-stroke S
			[cg2.sr SlopeA].start [upperLoop.last].x (@yC = [upperLoop.last].y)
			g2.down.mid           (box.right - OX)   [mix @yC @yB 0.5]
			hookend (sw -- S.thick)                  (@yB = box.bottom)
			g2                     box.left          (@yB + SHook)
