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

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

glyph-module

glyph-block LetterLike-Fraktur-Lower-IJL : begin
	glyph-block-import Common-Derivatives
	glyph-block-import CommonShapes
	glyph-block-import Letter-Shared : CreateAccentedComposition
	glyph-block-import Mark-Shared-Metrics : markMiddle markDotsRadius
	glyph-block-import Mark-Above : StdAnchors aboveMarkTop aboveMarkBot aboveMarkMid aboveMarkStack
	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 PHexTop PHexBot LTDecoration RBDecoration

	create-glyph "frak/tittleAbove" : glyph-proc
		set-width 0
		include : StdAnchors.narrow
		local xC markMiddle
		local yC aboveMarkMid
		include : lift-@ : spiro-outline
			corner (@xB = xC + [mix (-DotRadius) (+DotRadius) PHexBot]) (@yB = yC - DotRadius)
			~~~ [curl (@xB + TINY) (@yB + SlopeA * TINY)]
			~~~ [flat (@xT + TINY) (@yT + SlopeB * TINY)]
			corner (@xT = xC + [mix (-DotRadius) (+DotRadius) PHexTop]) (@yT = yC + DotRadius)
			~~~ [curl (@xT - TINY) (@yT - SlopeA * TINY)]
			~~~ [flat (@xB - TINY) (@yB - SlopeB * TINY)]
			close

	create-glyph "frak/dotlessi" : glyph-proc
		local df : include : LowerDf para.advanceScaleI
		include : df.markSet.e

		local box : S.box XH 0 df.leftSB df.rightSB
		include : fraktur-stroke S
			LTDecoration box.xMid box.top
			RBDecoration box.xMid box.bot

	create-glyph "frak/dotlessj" : glyph-proc
		local df : include : LowerDf para.advanceScaleI
		include : df.markSet.p

		local box : S.box XH Descender df.leftSB df.rightSB
		include : lift-@ : fraktur-stroke S
			LTDecoration (@xM = box.xMid)  box.top
			corner        @xM             [slY @xB @yB @xM SlopeA]
			corner       (@xB = box.left) (@yB = box.bot)

	CreateAccentedComposition 'frak/i' 0x1D526 'frak/dotlessi' 'frak/tittleAbove'
	CreateAccentedComposition 'frak/j' 0x1D527 'frak/dotlessj' 'frak/tittleAbove'

	create-glyph "frak/l" 0x1D529 : glyph-proc
		local df : include : LowerDf para.advanceScaleI
		include : df.markSet.b

		local box : S.box Ascender 0 df.leftSB df.rightSB
		include : fraktur-stroke S
			LTDecoration box.xMid box.top
			RBDecoration box.xMid box.bot
