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

import [mix linreg clamp fallback] from "@iosevka/util"
import [Transform] from "@iosevka/geometry/transform"

glyph-module

glyph-block Symbol-Pictograph-OCR : begin
	glyph-block-import CommonShapes
	glyph-block-import Common-Derivatives

	create-glyph 'ockHook' 0x2440 : glyph-proc
		local df : include : DivFrame 1
		local sw : df.adviceStroke 3

		include : VBar.l df.leftSB OperBot SymbolMid sw
		include : VBar.m df.middle OperBot OperTop sw
		include : VBar.r df.rightSB SymbolMid OperTop sw
		include : HBar.b df.leftSB df.middle OperBot sw
		include : HBar.t df.middle df.rightSB OperTop sw

	create-glyph 'ocrChair' 0x2441 : glyph-proc
		local df : include : DivFrame 1
		local sw : df.adviceStroke 3

		include : VBar.l df.leftSB OperBot SymbolMid sw
		include : VBar.r df.rightSB OperBot OperTop sw
		include : HBar.m df.leftSB df.rightSB SymbolMid sw

	create-glyph 'ocrFork' 0x2442 : glyph-proc
		local df : include : DivFrame 1
		local sw : df.adviceStroke 3

		include : VBar.l df.leftSB SymbolMid OperTop sw
		include : VBar.r df.rightSB SymbolMid OperTop sw
		include : VBar.m df.middle OperBot SymbolMid sw
		include : HBar.m df.leftSB df.rightSB SymbolMid sw

	turned 'ocrInvertedFork' 0x2443 'ocrFork' [DivFrame 1].middle SymbolMid

	create-glyph 'ocrBeltBuckle' 0x2444 : glyph-proc
		local df : include : DivFrame 1
		local sw : df.adviceStroke 3
		local gap : Math.max (XH / 4) [df.adviceStroke2 6 6 XH]

		include : HBar.t df.leftSB df.rightSB OperTop sw
		include : HBar.b df.leftSB df.rightSB OperBot sw
		include : VBar.m df.middle OperBot OperTop sw
		include : with-knockout [HBar.m OperBot df.width SymbolMid gap]
			VBar.l df.leftSB OperBot OperTop sw
			VBar.r df.rightSB OperBot OperTop sw

	create-glyph 'ocrBowTie' 0x2445 : glyph-proc
		local df : include : DivFrame 1
		local sw : df.adviceStroke2 4 6 (OperTop - OperBot)

		local y0 : mix OperBot OperTop 0.35
		local y1 : mix OperBot OperTop 0.65

		include : VBar.l df.leftSB y0 y1 sw
		include : VBar.r df.rightSB y0 y1 sw
		include : dispiro
			flat df.leftSB  y0 [widths.rhs sw]
			curl df.rightSB y1 [widths.lhs sw]
		include : dispiro
			flat df.leftSB  y1 [widths.lhs sw]
			curl df.rightSB y0 [widths.rhs sw]
