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

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

glyph-module

glyph-block Symbol-Math-Logicals : begin
	glyph-block-import CommonShapes
	glyph-block-import Common-Derivatives
	glyph-block-import Symbol-Math-Relation-Common : IdentHalfSpace
	glyph-block-import Mark-Shared-Metrics : markStroke
	glyph-block-import Symbol-Punctuation-Bar : BarShape DoubleBarShape TripleBarShape

	create-glyph 'negate' 0xAC : glyph-proc
		include : refer-glyph "minus"
		include : VBar.r RightSB (SymbolMid - (RightSB - SB) * 0.55) SymbolMid OperatorStroke

	create-glyph 'revNegate' 0x2310 : glyph-proc
		include : refer-glyph "minus"
		include : VBar.l SB (SymbolMid - (RightSB - SB) * 0.55) SymbolMid OperatorStroke

	turned 'turnedNegate' 0x2319 'negate' Middle SymbolMid
	turned 'invNegate'   null 'revNegate' Middle SymbolMid

	local top TackTop
	local bot TackBot

	create-glyph 'endOfProof' 0x220E : glyph-proc
		include : Rect top bot SB RightSB

	create-glyph 'stile' 0x2223 : BarShape Middle top bot OperatorStroke

	create-glyph 'parallel' 0x2225 : DoubleBarShape Middle top bot OperatorStroke

	create-glyph 'vdash' 0x22A2 : glyph-proc
		include : HBar.m SB RightSB SymbolMid OperatorStroke
		include : VBar.l SB top bot OperatorStroke

	turned 'dashv' 0x22A3 'vdash' Middle SymbolMid

	create-glyph 'top' 0x22A4 : glyph-proc
		include : HBar.t SB RightSB top OperatorStroke
		include : VBar.m Middle top bot OperatorStroke

	turned 'bot' 0x22A5 'top' Middle SymbolMid

	create-glyph 'assert' 0x22A6 : glyph-proc
		local l : mix Middle SB DesignParameters.logic_narrow_shrink
		local r : mix Middle RightSB DesignParameters.logic_narrow_shrink
		include : HBar.m l r SymbolMid OperatorStroke
		include : VBar.l l top bot OperatorStroke

	create-glyph 'models' 0x22A7 : glyph-proc
		local l : mix Middle SB DesignParameters.logic_narrow_shrink
		local r : mix Middle RightSB DesignParameters.logic_narrow_shrink
		include : HBar.m l r [mix SymbolMid top (1 / 3)] OperatorStroke
		include : HBar.m l r [mix SymbolMid bot (1 / 3)] OperatorStroke
		include : VBar.l l top bot OperatorStroke

	create-glyph 'tautology' 0x22A8 : glyph-proc
		local l : mix Middle SB 1
		local r : mix Middle RightSB 1
		include : HBar.m l r [mix SymbolMid top (1 / 3)] OperatorStroke
		include : HBar.m l r [mix SymbolMid bot (1 / 3)] OperatorStroke
		include : VBar.l l top bot OperatorStroke

	create-glyph 'forces' 0x22A9 : glyph-proc
		local l : mix Middle SB 1
		local r : mix Middle RightSB 1
		local vs : AdviceStroke 4
		local m : mix l (r - vs) (3 / 5)
		include : HBar.m m r SymbolMid OperatorStroke
		include : VBar.l l top bot vs
		include : VBar.m m top bot vs

	create-glyph 'tripleBarForces' 0x22AA : glyph-proc
		local l : mix Middle SB 1
		local r : mix Middle RightSB 1
		local vs : AdviceStroke 5
		local m : mix l (r - vs) (3 / 4)
		include : HBar.m m r SymbolMid OperatorStroke
		include : VBar.l l top bot vs
		include : VBar.m     m top bot vs
		include : VBar.m     ([mix l m (1/2)] + [HSwToV : 0.25 * vs]) top bot vs

	create-glyph 'doubleForces' 0x22AB : glyph-proc
		local l : mix Middle SB 1
		local r : mix Middle RightSB 1
		local vs : AdviceStroke 4
		local m : mix l (r - vs) (3 / 5)
		include : HBar.m m r [mix SymbolMid top (1 / 3)] OperatorStroke
		include : HBar.m m r [mix SymbolMid bot (1 / 3)] OperatorStroke
		include : VBar.l l top bot vs
		include : VBar.m m top bot vs

	create-glyph 'intercalate' 0x22BA : glyph-proc
		local l : mix Middle SB DesignParameters.logic_narrow_shrink
		local r : mix Middle RightSB DesignParameters.logic_narrow_shrink
		include : HBar.t l r top OperatorStroke
		include : VBar.m Middle top bot OperatorStroke

	create-glyph 'topring' 0x2355 : glyph-proc
		define mid : mix bot (top - OperatorStroke / 2) 0.5
		define w : (RightSB - SB) * 0.4
		define fine : Math.min (w / 2.5) : AdviceStroke 5
		include : HBar.t SB RightSB top OperatorStroke
		include : VBar.m Middle top (mid + w) OperatorStroke
		include : VBar.m Middle (mid - w) bot OperatorStroke
		include : VBar.m Middle (mid + w) (mid - w) fine
		include : OShape (mid + w) (mid - w) (Middle - w) (Middle + w) fine

	turned 'botring' 0x234E 'topring' Middle SymbolMid

	create-glyph 'perpendicular' 0x27C2 : glyph-proc
		include : HBar.b SB RightSB 0 OperatorStroke
		include : VBar.m Middle (SymbolMid * 2) 0 OperatorStroke

	create-glyph 'turnedTautologyTautology' 0x27DA : glyph-proc
		local df : include : DivFrame para.advanceScaleMM 4
		local vs : df.mvs * OperatorStroke / Stroke
		local innerSB : Math.min (SB * [Math.min 1 : df.adws / 1.5]) df.leftSB
		local l : Math.max (df.middle - innerSB - vs / 2) : mix df.middle df.leftSB  (1 / 3)
		local r : Math.min (df.middle + innerSB + vs / 2) : mix df.middle df.rightSB (1 / 3)
		local t : mix SymbolMid top (1 / 3)
		local b : mix SymbolMid bot (1 / 3)
		include : VBar.m l top bot vs
		include : VBar.m r top bot vs
		include : HBar.m df.leftSB  l t OperatorStroke
		include : HBar.m df.leftSB  l b OperatorStroke
		include : HBar.m r df.rightSB t OperatorStroke
		include : HBar.m r df.rightSB b OperatorStroke

	create-glyph 'dashvvdash' 0x27DB : glyph-proc
		local df : include : DivFrame para.advanceScaleMM 4
		local vs : df.mvs * OperatorStroke / Stroke
		local innerSB : Math.min (SB * [Math.min 1 : df.adws / 1.5]) df.leftSB
		local l : Math.max (df.middle - innerSB - vs / 2) : mix df.middle df.leftSB  (1 / 3)
		local r : Math.min (df.middle + innerSB + vs / 2) : mix df.middle df.rightSB (1 / 3)
		include : VBar.m l top bot vs
		include : VBar.m r top bot vs
		include : HBar.m df.leftSB  l SymbolMid OperatorStroke
		include : HBar.m r df.rightSB SymbolMid OperatorStroke

	create-glyph 'gleichStark' 0x29E6 : glyph-proc
		local l : mix Middle SB 1
		local r : mix Middle RightSB 1
		include : HBar.m l r [mix SymbolMid top (1 / 3)] OperatorStroke
		include : HBar.m l r [mix SymbolMid bot (1 / 3)] OperatorStroke
		include : VBar.l l top bot OperatorStroke
		include : VBar.r r top bot OperatorStroke

	turned 'turnedAssert' 0x2ADE 'assert' Middle SymbolMid

	create-glyph 'shortTop' 0x2ADF : glyph-proc
		local t : mix SymbolMid top (5 / 12)
		local b : mix SymbolMid bot (5 / 12)
		include : HBar.t SB RightSB t   OperatorStroke
		include : VBar.m Middle     t b OperatorStroke

	turned 'shortBot' 0x2AE0 'shortTop' Middle SymbolMid

	create-glyph 'ordinarilySatisfies' 0x2AE2 : glyph-proc
		local l : mix Middle SB 1
		local r : mix Middle RightSB 1
		include : HBar.m l r [mix SymbolMid top (1 / 2)] OperatorStroke
		include : HBar.m l r      SymbolMid              OperatorStroke
		include : HBar.m l r [mix SymbolMid bot (1 / 2)] OperatorStroke
		include : VBar.l l top bot OperatorStroke

	turned 'turnedForces' 0x2AE3 'forces' Middle SymbolMid
	turned 'turnedTautology' 0x2AE4 'tautology' Middle SymbolMid
	turned 'turnedDoubleForces' 0x2AE5 'doubleForces' Middle SymbolMid

	create-glyph 0x2AE6 : glyph-proc
		local l : mix Middle SB 1
		local r : mix Middle RightSB 1
		local vs : AdviceStroke 4
		local m : mix l (r - vs) (3 / 5)
		include : HBar.m l r SymbolMid OperatorStroke
		include : VBar.l l top bot vs
		include : VBar.m m top bot vs

	create-glyph 'shortTopOverbar' 0x2AE7 : glyph-proc
		local t : mix SymbolMid top (1 / 4)
		local b : mix SymbolMid bot (7 / 12)
		local markb : mix SymbolMid top (7 / 12)
		include : HBar.t SB RightSB t   OperatorStroke
		include : VBar.m Middle     t b OperatorStroke
		include : HBar.b SB RightSB markb markStroke

	turned 'shortBotUnderbar' 0x2AE8 'shortTopOverbar' Middle SymbolMid

	create-glyph 'shortBotOverShortTop' 0x2AE9 : glyph-proc
		# local t1 top
		local b1 : mix SymbolMid top (1 / 6)
		local t2 : mix SymbolMid bot (1 / 6)
		# local b2 bot
		include : VBar.m Middle     b1 top OperatorStroke
		include : HBar.b SB RightSB b1     OperatorStroke
		include : HBar.t SB RightSB t2     OperatorStroke
		include : VBar.m Middle     t2 bot OperatorStroke

	create-glyph 'doubleTop' 0x2AEA : glyph-proc
		local vs : AdviceStroke 4
		include : VBar.m [mix Middle SB      (2 / 5)] top bot vs
		include : VBar.m [mix Middle RightSB (2 / 5)] top bot vs
		include : HBar.t SB RightSB top OperatorStroke

	turned 'doubleBot' 0x2AEB 'doubleTop' Middle SymbolMid

	create-glyph 'doubleNegate' 0x2AEC : glyph-proc
		include : HBar.m SB RightSB (SymbolMid + IdentHalfSpace * 0.5) OperatorStroke
		include : HBar.m SB RightSB (SymbolMid - IdentHalfSpace * 0.5) OperatorStroke
		include : VBar.r RightSB (SymbolMid + IdentHalfSpace * 0.5) (SymbolMid - (RightSB - SB) * 0.55) OperatorStroke

	create-glyph 'revDoubleNegate' 0x2AED : glyph-proc
		include : HBar.m SB RightSB (SymbolMid + IdentHalfSpace * 0.5) OperatorStroke
		include : HBar.m SB RightSB (SymbolMid - IdentHalfSpace * 0.5) OperatorStroke
		include : VBar.l SB (SymbolMid + IdentHalfSpace * 0.5) (SymbolMid - (RightSB - SB) * 0.55) OperatorStroke

	create-glyph 'barRingAbove' 0x2AEF : glyph-proc
		local sw : AdviceStroke 4
		local radius : (RightSB - SB) / 6
		include : VBar.m Middle (top - radius - sw / 2) bot OperatorStroke
		include : difference
			DotAt Middle top (radius + sw)
			DotAt Middle top radius

	create-glyph 'botRingAbove' 0x27DF : glyph-proc
		include : refer-glyph "barRingAbove"
		include : HBar.b SB RightSB bot OperatorStroke

	turned 'barRingBelow' 0x2AF0 'barRingAbove' Middle SymbolMid
	turned 'topRingBelow' 0x2AF1 'botRingAbove' Middle SymbolMid

	create-glyph 'interleave' 0x2AF4 : TripleBarShape Middle top bot OperatorStroke

	create-glyph 'bigInterleave' 0x2AFC : TripleBarShape Middle BgTkTop BgTkBot OperatorStroke
