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

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

glyph-module

glyph-block LetterLike-Fraktur-Lower-HY : 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
	glyph-block-import LetterLike-Fraktur-Common : Wave FHook PHexTop PHexBot LTDecoration

	define [LeftHalfShape mode box] : lift-@ : fraktur-stroke S
		LTDecoration box.left box.top
		corner (@xL = box.left)        [slY @xB @yB @xL SlopeB]
		corner (@xB = @xM - DecoSizeX) (@yB = box.bottom)
		corner (@xM = box.xMid)        (@yB + DecoSizeY)

	define [RightHalfShape mode box] : lift-@ : fraktur-stroke S
		corner                (@xL = box.left)         [slY @xT @yT @xL SlopeA]
		[cg2.sr SlopeB].start (@xT = [box.xp PHexTop]) (@yT = box.top)
		straight.down.mid     (@xR = box.right)         box.yMid
		corner                [box.xp PHexTop]          box.bottom

	create-glyph "frak/h" 0x1D525 : glyph-proc
		local df : include : LowerDf 1
		include : df.markSet.bp

		local leftBox : S.box Ascender 0 df.leftSB df.rightSB
		local rightBox : S.box XH Descender df.leftSB df.rightSB

		local leftStroke : include : LeftHalfShape 'h' leftBox
		local rightStroke : include : RightHalfShape 'h' rightBox

	create-glyph "frak/y" 0x1D536 : glyph-proc
		local df : include : LowerDf 1
		include : df.markSet.p

		local leftBox : S.box XH 0 df.leftSB df.rightSB
		local rightBox : S.box XH Descender df.leftSB df.rightSB

		local leftStroke : include : LeftHalfShape 'y' leftBox
		local rightStroke : include : RightHalfShape 'y' rightBox
