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

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

glyph-module

glyph-block LetterLike-Fraktur-S : begin
	glyph-block-import Common-Derivatives
	glyph-block-import CommonShapes
	glyph-block-import LetterLike-Fraktur-Common : UpperDf S M 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

	create-glyph "frak/S" 0x1D516 : glyph-proc
		local df : include : UpperDf 1
		include : df.markSet.capital

		local box : S.box CAP 0 df.leftSB df.rightSB

		include : lift-@ : fraktur-stroke S
			g2.ld.start (@xR = box.right)        (@yT = box.top)
			~~~ [g2.left.mid [mix @xR @xT : 1/3] (@yT - 0.75 * Wave.DepthY - O)]
			g2.left.mid (@xT = [box.xp 0.375])   (@yT - O)
			~~~ [archv]
			flat        (@xL = box.left)         (@yT - SmallArchDepthA * (CAP / XH))
			curl         @xL                     (@yB + SmallArchDepthB * (CAP / XH))
			arch.lhs (sw -- S.thick)             (@yB = box.bottom)
			g2.up.mid   (@xR - OX)               [mix @yB @yMT 0.5]
			~~~ [arcvh]
			g2.left.mid [box.xp 0.625]           (@yMT = box.yMid + 0.25 * Wave.DepthY - O)
			~~~ [g2.left.mid [box.xp 0.3]        (box.yMid - 0.25 * Wave.DepthY + O) [change-pen T]]
			g2          [box.xp 0.125]            @yMT
