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

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


glyph-module

glyph-block Letter-Latin-Glottal-Stop : begin
	glyph-block-import CommonShapes
	glyph-block-import Common-Derivatives
	glyph-block-import Letter-Shared : CreateTurnedLetter
	glyph-block-import Letter-Shared-Shapes : LetterBarOverlay CurlyTail

	create-glyph 'glottalStop' 0x294 : glyph-proc
		include : MarkSet.b
		include : dispiro
			widths.rhs
			g4 SB (Ascender - Hook)
			hookstart Ascender
			g4 RightSB (Ascender - [AdviceGlottalStopArchDepth Ascender 1])
			alsoThru.g2 0.5 0.5 important
			flat (Middle + [HSwToV HalfStroke]) (XH * 0.3)
			curl (Middle + [HSwToV HalfStroke]) 0 [heading Downward]
		if SLAB : begin
			include : HSerif.mb Middle 0 MidJutCenter

	create-glyph 'capGlottalStop' 0x241 : glyph-proc
		include : MarkSet.capital
		include : dispiro
			widths.rhs
			g4 SB (CAP - Hook)
			hookstart CAP
			g4 RightSB (CAP - [AdviceGlottalStopArchDepth CAP 1])
			alsoThru.g2 0.5 0.5 important
			flat (Middle + [HSwToV HalfStroke]) (XH * 0.3)
			curl (Middle + [HSwToV HalfStroke]) 0 [heading Downward]
		if SLAB : begin
			include : HSerif.mb Middle 0 MidJutCenter

	create-glyph 'revGlottalStop' 0x295 : glyph-proc
		include : MarkSet.b
		include : dispiro
			widths.lhs
			g4 RightSB (Ascender - Hook)
			hookstart Ascender
			g4 SB (Ascender - [AdviceGlottalStopArchDepth Ascender (-1)])
			alsoThru.g2 0.5 0.5 important
			flat (Middle - [HSwToV HalfStroke]) (XH * 0.3)
			curl (Middle - [HSwToV HalfStroke]) 0 [heading Downward]
		if SLAB : begin
			include : HSerif.mb Middle 0 MidJutCenter

	create-glyph 'smallGlottalStop' 0x242 : glyph-proc
		include : MarkSet.e
		include : dispiro
			widths.rhs
			g4 SB (XH - Hook)
			hookstart XH
			g4 RightSB (XH - [AdviceGlottalStopArchDepth XH 1])
			alsoThru.g2 0.5 0.5 important
			flat (Middle + [HSwToV HalfStroke]) (XH * 0.15)
			curl (Middle + [HSwToV HalfStroke]) 0 [heading Downward]
		if SLAB : begin
			include : HSerif.mb Middle 0 MidJutCenter

	create-glyph 'smallRevGlottalStop' : glyph-proc
		include : MarkSet.e
		include : dispiro
			widths.lhs
			g4 RightSB (XH - Hook)
			hookstart XH
			g4 SB (XH - [AdviceGlottalStopArchDepth XH (-1)])
			alsoThru.g2 0.5 0.5 important
			flat (Middle - [HSwToV HalfStroke]) (XH * 0.15)
			curl (Middle - [HSwToV HalfStroke]) 0 [heading Downward]
		if SLAB : begin
			include : HSerif.mb Middle 0 MidJutCenter

	CreateTurnedLetter 'invGlottalStop' 0x296 'revGlottalStop' HalfAdvance (Ascender / 2)

	create-glyph 'invGlottalStopCurlyTail' 0x1DF0E : glyph-proc
		include : MarkSet.b

		local yMid : AdviceGlottalStopArchDepth Ascender 1
		local fine : AdviceStroke 3.5

		include : dispiro
			widths.rhs
			flat (Middle + [HSwToV HalfStroke]) Ascender [heading Downward]
			curl (Middle + [HSwToV HalfStroke]) (Ascender - XH * 0.3)
			alsoThru.g2 0.5 0.5 important
			g4 RightSB yMid
			CurlyTail.n fine 0 SB RightSB 0 yMid

		if SLAB : begin
			include : HSerif.mt Middle Ascender MidJutCenter


	create-glyph 'glottalStopBar' 0x2A1 : glyph-proc
		include [refer-glyph 'glottalStop'] AS_BASE
		include : LetterBarOverlay.m.in Middle [if SLAB Stroke 0] (Ascender * 0.5) 0.5

	create-glyph 'revGlottalStopBar' 0x2A2 : glyph-proc
		include [refer-glyph 'revGlottalStop'] AS_BASE
		include : LetterBarOverlay.m.in Middle [if SLAB Stroke 0] (Ascender * 0.5) 0.5
