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

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

glyph-module

glyph-block NotGlyphFn : begin
	glyph-block-import CommonShapes
	glyph-block-import Common-Derivatives
	glyph-block-export NotGlyphSw notGlyph

	define NotGlyphSw : AdviceStroke 4.5

	define [notGlyphGeneric newid unicode oldid top bot prop shift F] : begin
		local component : F
			fallback top BgOpTop
			fallback bot BgOpBot
			mix SB RightSB [fallback prop 0.25]
			mix RightSB SB [fallback prop 0.25]
			begin NotGlyphSw
			fallback shift 0
		create-glyph (newid || 'not' + oldid) unicode : glyph-proc
			include : refer-glyph oldid
			include component

	define [notGlyph] : with-params [newid unicode oldid top bot prop shift] : begin
		notGlyphGeneric newid unicode oldid top bot prop shift
			lambda [t b l r sw sh] : begin
				local slashBarName ".NotGlyphSlash{\(l)}{\(r)}{\(t)}{\(b)}{\(sw)}"
				if [not : query-glyph slashBarName] : begin
					create-glyph slashBarName : dispiro
						widths.center sw
						flat l b
						curl r t
				return : glyph-proc
					include : with-transform [Translate sh 0] [refer-glyph slashBarName]

	define [notGlyph.right] : with-params [newid unicode oldid top bot prop shift] : begin
		notGlyph newid unicode oldid top bot prop (-NotGlyphSw * 0.5)
	define [notGlyph.left] : with-params [newid unicode oldid top bot prop shift] : begin
		notGlyph newid unicode oldid top bot prop (NotGlyphSw * 0.5)
	define [notGlyph.generic] : with-params [newid unicode oldid top bot prop shift F] : begin
		notGlyphGeneric newid unicode oldid top bot prop shift F
