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

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

glyph-module

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

	define [HalfS box] : lift-@ : fraktur-stroke S
		corner      (@xR = box.right)                (@yT = box.top)
		g2          [mix @xR @xT 0.5]                (@yT - 0.5 * FHook)
		corner      (@xT = [box.xp : 0.5 * PHexTop])  @yT
		g2.down.mid  box.left                        [mix @yT @yA 0.5]
		corner       @xT                             (@yA = [slY @xM @yM @xT SlopeA])
		corner      (@xM = box.xMid)                 (@yM = box.yMid)

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

		local box : S.box XH 0 df.leftSB df.rightSB
		local lowerHalf : include : HalfS box
		include : FlipAround box.xMid box.yMid
		local upperHalf : include : HalfS box
