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

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


glyph-module

glyph-block Letter-Latin-Lower-DB-QP : begin
	glyph-block-import CommonShapes
	glyph-block-import Common-Derivatives
	glyph-block-import Letter-Shared-Shapes : OBarLeft OBarRight

	define [DbCenterShape df] : glyph-proc
		local subDf : df.slice 3 2 OX
		include : OBarRight.rounded
			left      -- df.leftSB
			right     -- (df.middle + [HSwToV : 0.5 * df.mvs])
			yTerminal -- XH
			sw        -- df.mvs
			ada       -- subDf.smallArchDepthA
			adb       -- subDf.smallArchDepthB
		include : OBarLeft.rounded
			left      -- (df.middle - [HSwToV : 0.5 * df.mvs])
			right     -- df.rightSB
			yTerminal -- (XH / 2)
			sw        -- df.mvs
			ada       -- subDf.smallArchDepthA
			adb       -- subDf.smallArchDepthB

	create-glyph 'db' 0x238 : glyph-proc
		local df : include : DivFrame para.advanceScaleMM 3
		include : df.markSet.b
		include : DbCenterShape df
		include : VBar.m df.middle XH Ascender df.mvs
		if SLAB : begin
			include : HSerif.lt (df.middle - [HSwToV : 0.5 * df.mvs]) Ascender SideJut

	create-glyph 'qp' 0x239 : glyph-proc
		local df : include : DivFrame para.advanceScaleMM 3
		include : df.markSet.p
		include : DbCenterShape df
		include : FlipAround df.middle (XH / 2)
		include : VBar.m df.middle Descender 0 df.mvs
		if SLAB : begin
			include : HSerif.mb df.middle Descender Jut
