Iosevka/font-src/glyphs/marks/overlay.ptl
2023-07-03 13:59:12 -07:00

359 lines
13 KiB
Text

$$include '../../meta/macros.ptl'
import [Arcs Quadify ShapeConv] from "typo-geom"
import [mix linreg clamp fallback] from"../../support/utils.mjs"
import [DesignParameters] from"../../meta/aesthetics.mjs"
import [TieMark TieGlyph] from"../../support/gr.mjs"
import [Box] from"../../support/geometry/box.mjs"
glyph-module
glyph-block Mark-Overlay : begin
glyph-block-import CommonShapes
glyph-block-import Common-Derivatives
glyph-block-import Mark-Shared-Metrics : markExtend MarkStroke markStress markFine
glyph-block-import Mark-Shared-Metrics : asciiMarkZoomX asciiMarkZoomY
glyph-block-import Mark-Shared-Metrics : markMiddle markDotsRadius
glyph-block-import Mark-Above : aboveMarkTop aboveMarkBot aboveMarkMid TildeShape RingShape
glyph-block-import Mark-Below : belowMarkBot belowMarkTop belowMarkMid
local tildeHeight : 0.75 * (aboveMarkTop - aboveMarkBot)
local tildeHalfWidth : markExtend + 0.4 * Stroke * HVContrast
# Overlay on stems
create-glyph 'tildeOver' 0x334 : glyph-proc
set-width 0
set-mark-anchor 'overlay' markMiddle (XH / 2) markMiddle (XH / 2)
include : TildeShape
ttop -- XH / 2 + tildeHeight / 2
tbot -- XH / 2 - tildeHeight / 2
leftEnd -- markMiddle - tildeHalfWidth
rightEnd -- markMiddle + tildeHalfWidth
hs -- [AdviceStroke 4] / 2
create-glyph 'dblTildeOver' : glyph-proc
set-width 0
set-mark-anchor 'overlay' markMiddle (XH / 2) markMiddle (XH / 2)
local ttop : XH / 2 + tildeHeight / 2
local tbot : XH / 2 - tildeHeight / 2
define [addTilde] : TildeShape
ttop -- ttop
tbot -- tbot
leftEnd -- markMiddle - tildeHalfWidth
rightEnd -- markMiddle + tildeHalfWidth
hs -- [AdviceStroke 4.5] / 2
local shift : (ttop - tbot) * 1.2
include : addTilde
include : ApparentTranslate 0 shift
include : addTilde
include : ApparentTranslate 0 (-0.5 * shift)
create-glyph 'asciiTilde.symbolMid' : glyph-proc
include : TildeShape
ttop -- SymbolMid + tildeHeight * 0.5 * asciiMarkZoomY
tbot -- SymbolMid - tildeHeight * 0.5 * asciiMarkZoomY
leftEnd -- SB
rightEnd -- RightSB
hs -- OperatorStroke / 2
create-glyph 'tildeOverOnExension' : glyph-proc
set-width 0
set-mark-anchor 'overlayOnExtension' markMiddle (XH / 2) markMiddle (XH / 2)
include : TildeShape
ttop -- XH / 2 + tildeHeight / 3
tbot -- XH / 2 - tildeHeight / 3
leftEnd -- markMiddle - tildeHalfWidth
rightEnd -- markMiddle + tildeHalfWidth
hs -- [AdviceStroke 4] / 2
create-glyph 'barOver' 0x335 : glyph-proc
set-width 0
set-mark-anchor 'overlay' markMiddle (XH / 2) markMiddle (XH / 2)
include : HOverlayBar (markMiddle - LongJut * 0.75) (markMiddle + LongJut * 0.75) (XH / 2)
create-glyph 'dblBarOver' : glyph-proc
set-width 0
set-mark-anchor 'overlay' markMiddle (XH / 2) markMiddle (XH / 2)
local gap : 0.2 * CAP
include : HOverlayBar (markMiddle - LongJut * 0.75) (markMiddle + LongJut * 0.75) (XH / 2 + 0.5 * gap)
include : HOverlayBar (markMiddle - LongJut * 0.75) (markMiddle + LongJut * 0.75) (XH / 2 - 0.5 * gap)
create-glyph 'shortSlashOver' 0xE000 : glyph-proc
set-width 0
set-mark-anchor 'overlay' markMiddle (XH / 2) markMiddle (XH / 2)
include : FlatSlashShape markMiddle (XH / 2) (0.5 * OverlayStroke)
create-glyph 'antiSlashOver' : glyph-proc
set-width 0
set-mark-anchor 'overlay' markMiddle (XH / 2) markMiddle (XH / 2)
include : FlatSlashShape markMiddle (XH / 2) (0.5 * OverlayStroke) (0.75) (-0.3)
create-glyph 'ringOver' : glyph-proc
set-width 0
set-mark-anchor 'overlay' 0 0 0 0
include : RingShape 0 0 tildeHalfWidth
# Slash on entire letter on blank (bowl)
create-glyph 'hStrike' : glyph-proc
set-width 0
set-mark-anchor 'strike' markMiddle (XH / 2) markMiddle (XH / 2)
include : HOverlayBar ([mix 0 SB 0.5] - Width) ([mix Width RightSB 0.5] - Width) (XH / 2)
create-glyph 'strikeThrough' 0x0336 : glyph-proc
set-width 0
set-mark-anchor 'slash' markMiddle (XH / 2) markMiddle (XH / 2)
include : HOverlayBar (0 - Width) (0) (XH / 2)
create-glyph 'oblStrike' : glyph-proc
set-width 0
set-mark-anchor 'strike' markMiddle (XH / 2) markMiddle (XH / 2)
include : dispiro
widths.center OverlayStroke
flat ([mix 0 SB 0.5] - Width) (0.4 * XH)
curl ([mix Width RightSB 0.5] - Width) (0.6 * XH)
create-glyph 'tildeStrike' : glyph-proc
set-width 0
set-mark-anchor 'strike' markMiddle (XH / 2) markMiddle (XH / 2)
include : TildeShape
ttop -- XH / 2 + tildeHeight / 2
tbot -- XH / 2 - tildeHeight / 2
leftEnd -- markMiddle - Width / 2
rightEnd -- markMiddle + Width / 2
hs -- OverlayStroke / 2
create-glyph 'tildeStrike2' : glyph-proc
set-width 0
set-mark-anchor 'strike' markMiddle (XH / 2) markMiddle (XH / 2)
include : TildeShape
ttop -- XH / 2 + tildeHeight / 2
tbot -- XH / 2 - tildeHeight / 2
leftEnd -- markMiddle - Width / 2 + SB
rightEnd -- markMiddle + Width / 2 - SB
hs -- OverlayStroke / 2
create-glyph 'tildeStrikeDivM' : glyph-proc
set-width 0
set-mark-anchor 'strike' markMiddle (XH / 2) markMiddle (XH / 2)
include : TildeShape
ttop -- XH / 2 + tildeHeight / 2
tbot -- XH / 2 - tildeHeight / 2
leftEnd -- markMiddle - Width / 2 * para.diversityM
rightEnd -- markMiddle + Width / 2 * para.diversityM
hs -- OverlayStroke / 2
# Slashes
create-glyph 'shortSlash' 0x337 : glyph-proc
set-width 0
local fine : 0.375 * OverlayStroke
set-mark-anchor 'slash' markMiddle (XH / 2) markMiddle (XH / 2)
include : dispiro
flat (SB - O * 3 + fine - Width) (XH * (-0.1)) [widths fine fine]
curl (RightSB + O * 3 - fine - Width) (XH * 1.1)
create-glyph 'longSlash' 0x338 : glyph-proc
set-width 0
local fine : 0.375 * OverlayStroke
set-mark-anchor 'slash' markMiddle (XH / 2) markMiddle (XH / 2)
include : dispiro
flat (SB - O * 3 + fine - Width) (XH * 0.5 - CAP * 0.6) [widths fine fine]
curl (RightSB + O * 3 - fine - Width) (XH * 0.5 + CAP * 0.6)
create-glyph 'wideSlash' : glyph-proc
set-width 0
local fine : 0.375 * OverlayStroke
set-mark-anchor 'slash' markMiddle (XH / 2) markMiddle (XH / 2)
include : dispiro
flat (SB + O * 3 + fine - Width) (XH * (-0.1)) [widths fine fine]
curl (RightSB - O * 3 - fine - Width) (XH * 1.1)
# Arrow overlays
create-glyph 'arrSlashOver' : glyph-proc
set-width 0
local fine : 0.375 * OverlayStroke
local dx : Width * 0.1
local dy : Width * 0.4
set-mark-anchor 'slash' markMiddle (XH / 2) markMiddle (XH / 2)
include : dispiro
flat (Middle - dx - Width) (XH / 2 - dy) [widths fine fine]
curl (Middle + dx - Width) (XH / 2 + dy)
create-glyph 'arrVStrokeOver' : glyph-proc
set-width 0
local fine : 0.375 * OverlayStroke
local dx : Width * 0
local dy : Width * 0.3
set-mark-anchor 'slash' markMiddle (XH / 2) markMiddle (XH / 2)
include : dispiro
flat (Middle - dx - Width) (XH / 2 - dy) [widths fine fine]
curl (Middle + dx - Width) (XH / 2 + dy)
create-glyph 'arrDblVStrokeOver' : glyph-proc
set-width 0
local fine : 0.3 * OverlayStroke
local dx : Width * 0
local dy : Width * 0.3
local gap : Math.max (fine * 2) (Width / 10)
set-mark-anchor 'slash' markMiddle (XH / 2) markMiddle (XH / 2)
include : dispiro
flat (Middle - dx - Width - gap) (XH / 2 - dy) [widths fine fine]
curl (Middle + dx - Width - gap) (XH / 2 + dy)
include : dispiro
flat (Middle - dx - Width + gap) (XH / 2 - dy) [widths fine fine]
curl (Middle + dx - Width + gap) (XH / 2 + dy)
create-glyph 'arrHStrokeOver' : glyph-proc
set-width 0
local fine : 0.375 * OverlayStroke
local dx : Width * 0.3
set-mark-anchor 'slash' markMiddle (XH / 2) markMiddle (XH / 2)
include : dispiro
flat (Middle - Width - dx) (XH / 2) [widths fine fine]
curl (Middle - Width + dx) (XH / 2)
create-glyph 'arrDblHStrokeOver' : glyph-proc
set-width 0
local fine : 0.3 * OverlayStroke
local dx : Width * 0.3
local gap : Math.max (fine * 2) (Width / 10)
set-mark-anchor 'slash' markMiddle (XH / 2) markMiddle (XH / 2)
include : dispiro
flat (Middle - Width - dx) (XH / 2 - gap) [widths fine fine]
curl (Middle - Width + dx) (XH / 2 - gap)
include : dispiro
flat (Middle - Width - dx) (XH / 2 + gap) [widths fine fine]
curl (Middle - Width + dx) (XH / 2 + gap)
# Half-XH marks for spacing modifiers
create-glyph 'leftTackOver' : glyph-proc
set-width 0
set-mark-anchor 'overlay' 0 0 0 0
include : VBar.m (markExtend) (-XH / 4) (XH / 4) MarkStroke
include : HBar.m (-markExtend) (markExtend) 0 MarkStroke
create-glyph 'rightTackOver' : glyph-proc
set-width 0
set-mark-anchor 'overlay' 0 0 0 0
include : VBar.m (-markExtend) (-XH / 4) (XH / 4) MarkStroke
include : HBar.m (-markExtend) (markExtend) 0 MarkStroke
create-glyph 'upTackOver' : glyph-proc
set-width 0
set-mark-anchor 'overlay' 0 0 0 0
local ext : Math.min markExtend (belowMarkTop - belowMarkBot)
include : VBar.m 0 (-ext) (+ext) (markFine * 2)
include : HBar.b (-markExtend) (+markExtend) (-ext) (markFine * 2)
create-glyph 'downTackOver' : glyph-proc
set-width 0
set-mark-anchor 'overlay' 0 0 0 0
local ext : Math.min markExtend (belowMarkTop - belowMarkBot)
include : VBar.m 0 (-ext) (+ext) (markFine * 2)
include : HBar.t (-markExtend) (+markExtend) (+ext) (markFine * 2)
create-glyph 'plusOver' : glyph-proc
set-width 0
set-mark-anchor 'overlay' 0 0 0 0
local ext : Math.min markExtend (belowMarkTop - belowMarkBot)
include : VBar.m 0 (-ext) (+ext) (markFine * 2)
include : HBar.m (-markExtend) (+markExtend) 0 (markFine * 2)
create-glyph 'minusOver' : glyph-proc
set-width 0
set-mark-anchor 'overlay' 0 0 0 0
local ext : 0.5 * [Math.min markExtend (belowMarkTop - belowMarkBot)]
include : VBar.m (-markExtend) (-ext) (+ext) (markFine * 2)
include : VBar.m (+markExtend) (-ext) (+ext) (markFine * 2)
include : HBar.m (-markExtend) (+markExtend) 0 (markFine * 2)
create-glyph 'equalOver' : glyph-proc
set-width 0
set-mark-anchor 'overlay' 0 0 0 0
local ext : Math.min markExtend (belowMarkTop - belowMarkBot)
local sw : Math.min (2 * markFine) ((2 / 3) * ext)
include : HBar.t (-markExtend) (+markExtend) (+ext) sw
include : HBar.b (-markExtend) (+markExtend) (-ext) sw
create-glyph 'rightHalfCircleOver' : glyph-proc
set-width 0
set-mark-anchor 'overlay' 0 0 0 0
include : WithTransform [ApparentTranslate (-markMiddle) (-aboveMarkMid)]
refer-glyph 'rightHalfCircleAbove'
create-glyph 'leftHalfCircleOver' : glyph-proc
set-width 0
set-mark-anchor 'overlay' 0 0 0 0
include : WithTransform [ApparentTranslate (-markMiddle) (-aboveMarkMid)]
refer-glyph 'leftHalfCircleAbove'
# Inner dots
glyph-block-export InnerDot
define [InnerDot x y kHeight fRound kdr _space _div] : begin
local space : fallback _space : InnerDot.spaceOfDf [DivFrame 1]
local div : fallback _div 4
local halfDotWidth : kdr * [Math.min DotRadius (space / div)]
local halfDotHeight : kdr * [Math.min DotRadius (halfDotWidth * kHeight)]
if fRound
: then : return : OShapeOutline.NoOvershoot
y + halfDotHeight
y - halfDotHeight
x + halfDotWidth
x - halfDotWidth
Stroke * halfDotWidth * 2 / Width
ArchDepthAOf halfDotWidth (halfDotWidth * 2)
ArchDepthBOf halfDotWidth (halfDotWidth * 2)
: else : return : Rect
y + halfDotHeight
y - halfDotHeight
x + halfDotWidth
x - halfDotWidth
set [InnerDot.spaceOfDf df] : df.rightSB - df.leftSB - 2 * OX - 2 * HVContrast * df.mvs
define [InnerDot2 kHeight fRound kdr] : glyph-proc
local space : InnerDot.spaceOfDf [DivFrame 1]
local div : StrokeWidthBlend 7 5
local halfDotWidth : kdr * [Math.min DotRadius (space / div)]
local kHeight2 : div / 4 * kHeight
local offset : (0.5 * space - 2 * halfDotWidth) / 3 + halfDotWidth
include : InnerDot (-offset) 0 kHeight2 fRound kdr space div
include : InnerDot offset 0 kHeight2 fRound kdr space div
foreach { suffix { DrawAt kdr } } [Object.entries DotVariants] : do
create-glyph "innerDot.\(suffix)" : glyph-proc
set-width 0
set-mark-anchor 'slash' 0 0 0 0
include : InnerDot 0 0 2 (DrawAt === DotAt) kdr
create-glyph "innerDotSmall.\(suffix)" : glyph-proc
set-width 0
set-mark-anchor 'slash' 0 0 0 0
include : InnerDot 0 0 1.5 (DrawAt === DotAt) kdr
create-glyph "innerDoubleDot.\(suffix)" : glyph-proc
set-width 0
set-mark-anchor 'slash' 0 0 0 0
include : InnerDot2 2 (DrawAt === DotAt) kdr
create-glyph "innerDoubleDotSmall.\(suffix)" : glyph-proc
set-width 0
set-mark-anchor 'slash' 0 0 0 0
include : InnerDot2 1.5 (DrawAt === DotAt) kdr
select-variant "innerDot" (follow -- 'diacriticDot')
select-variant "innerDotSmall" (follow -- 'diacriticDot')
select-variant "innerDoubleDot" (follow -- 'diacriticDot')
select-variant "innerDoubleDotSmall" (follow -- 'diacriticDot')