Files
Iosevka/glyphs/numbers.ptl
T

380 lines
11 KiB
Plaintext

$$include '../meta/macros.ptl'
import '../support/transform' as : Transform && [object [transformPoint tp] [untransform utp] inverse]
import [mix linreg clamp fallback] from '../support/utils'
import [designParameters] from '../meta/aesthetics'
###### NUMBERS
export : define [apply] : begin
glyph-module-entry commonShapes letterExt
define [ShiftDown] : glyph-construction
include : Upright
include : Translate 0 DESCENDER
include : Italify
define [ZeroSlashShape top] : begin
local fine : 0.5 * OVERLAYSTROKE
return : intersection
OShapeOutline top 0 SB RIGHTSB
dispiro
flat (SB + STROKE / 2) (top * (1 - 0.77)) [widths fine fine]
curl (RIGHTSB - STROKE / 2) (top * 0.77)
define [ZeroDotShape top] : begin
local radius : Math.min DOTRADIUS ((RIGHTSB - SB - STROKE * 2) / 4)
return : Ring (top / 2 + radius) (top / 2 - radius) (MIDDLE + radius) (MIDDLE - radius)
sketch # zero.lnum.unslashed
include MarkSet.capital
include : OShape CAP 0 SB RIGHTSB
save 'zero.lnum.unslashed'
sketch # zero.lnum.slashed
include MarkSet.capital
include glyphs.'zero.lnum.unslashed'
include : ZeroSlashShape CAP
save 'zero.lnum.slashed'
sketch # zero.lnum.dotted
include MarkSet.capital
include glyphs.'zero.lnum.unslashed'
include : ZeroDotShape CAP
save 'zero.lnum.dotted'
sketch # zero.onum.unslashed
include MarkSet.e
include : OShape XH 0 SB RIGHTSB
save 'zero.onum.unslashed'
sketch # zero.onum.slashed
include MarkSet.e
include glyphs.'zero.onum.unslashed'
include : ZeroSlashShape XH
save 'zero.onum.slashed'
sketch # zero.onum.dotted
include MarkSet.e
include glyphs.'zero.onum.unslashed'
include : ZeroDotShape XH
save 'zero.onum.dotted'
select-variant 'zero.lnum' '0' (follow -- 'zero')
select-variant 'zero.onum' (follow -- 'zero')
alias 'zero' nothing 'zero.lnum'
define [OneShape top] : glyph-construction
include : VBar (MIDDLE + ONEBALANCE) 0 top
include : dispiro
flat (MIDDLE - HALFSTROKE * HVCONTRAST + ONEBALANCE) top [widths STROKE 0]
curl (MIDDLE - HOOKX * 1.25 + ONEBALANCE) (top - HOOK * 0.75 * (top / CAP))
sketch # one.lnum.nobase
include MarkSet.capital
include : OneShape CAP
save 'one.lnum.nobase'
sketch # one.lnum.base
include glyphs.'one.lnum.nobase' AS_BASE
include : CenterBottomSerif (MIDDLE + ONEBALANCE) 0 LONGJUT
save 'one.lnum.base'
sketch # one.onum.nobase
include MarkSet.e
include : OneShape XH
save 'one.onum.nobase'
sketch # one.onum.base
include glyphs.'one.onum.nobase' AS_BASE
include : CenterBottomSerif (MIDDLE + ONEBALANCE) 0 LONGJUT
save 'one.onum.base'
select-variant 'one.lnum' '1' (follow -- 'one')
select-variant 'one.onum' (follow -- 'one')
alias 'one' nothing 'one.lnum'
define [TwoShape top] : glyph-construction
define smooth : [adviceGlottalStopSmooth top 1] * 0.95
include : dispiro
widths.rhs
g4 SB (top - HOOK)
hookstart (top - O)
g4.down.mid (RIGHTSB - OX / 2) (top - smooth)
alsothru 0.5 ([linreg 18 0.425 120 0.4 STROKE] * [linreg 500 1 700 0.95 WIDTH]) [widths.center]
flat SB 1 [widths.heading STROKE 0 DOWNWARD]
curl SB 0 [heading DOWNWARD]
include : HBarBottom (SB + HALFSTROKE) RIGHTSB 0
if SLAB : begin
include : UpwardRightSerif RIGHTSB 0 VJUT
sketch # two.lnum
include MarkSet.capital
include : TwoShape CAP
save 'two.lnum' '2'
sketch # two.onum
include MarkSet.e
include : TwoShape XH
save 'two.onum'
alias 'two' nothing 'two.lnum'
define [ThreeShape top] : glyph-construction
local barcenter : top * BARPOS
local threeRadius : ((top / 2) + HALFSTROKE - SMOOTH) * 1.25
local fine : STROKE * CTHIN
include : dispiro
widths.rhs
g4 (SB - O) (top - HOOK)
hookstart (top - O)
g4 (RIGHTSB) (top - (SMOOTHB * (top - barcenter) / (top / 2)))
flat (RIGHTSB - threeRadius + 0.01) (barcenter - (fine - HALFSTROKE)) [widths.heading 0 fine LEFTWARD]
curl (RIGHTSB - threeRadius) (barcenter - (fine - HALFSTROKE)) [heading LEFTWARD]
include : dispiro
widths.lhs
g4 (SB + O) HOOK
hookstart O
g4 (RIGHTSB - O * 2) (SMOOTHA * barcenter / (top / 2))
flat (RIGHTSB - threeRadius + 0.01) (barcenter + (fine - HALFSTROKE)) [widths.heading fine 0 LEFTWARD]
curl (RIGHTSB - threeRadius) (barcenter + (fine - HALFSTROKE)) [heading LEFTWARD]
sketch # three.lnum
include MarkSet.capital
include : ThreeShape CAP
save 'three.lnum.twoarcs'
sketch
include MarkSet.capital
include : EzhShape CAP 0 0.25 0.975
save 'three.lnum.flattop'
sketch # three.lnum
include MarkSet.p
include : ThreeShape (XH - DESCENDER)
include : ShiftDown
save 'three.onum.twoarcs'
sketch
include MarkSet.p
include : EzhShape (XH - DESCENDER) 0 0.25 0.975
include : ShiftDown
save 'three.onum.flattop'
select-variant 'three.lnum' '3' (follow -- 'three')
select-variant 'three.onum' (follow -- 'three')
alias 'three' nothing 'three.lnum'
define [FourShape top] : glyph-construction
local bar (top * 0.4)
local vert : [mix SB RIGHTSB 0.825] - HVCONTRAST * STROKE
local p 0.25
local fine (STROKE * 0.9)
include : HBarTop (SB + OX) RIGHTSB bar
include : VBarLeft vert 0 top
local slope : (top - bar) / (vert - fine * p * HVCONTRAST - (SB + OX))
include : dispiro
g4 (SB + OX) bar [widths 0 fine]
g4 (vert - fine * p * HVCONTRAST) top [widths.heading 0 [Math.hypot fine (fine / slope)] UPWARD]
if SLAB : begin
include : CenterBottomSerif (vert + HALFSTROKE * HVCONTRAST) 0 JUT
sketch # four.lnum
include MarkSet.capital
include : FourShape CAP
save 'four.lnum' '4'
save 'four'
sketch # four.onum
include MarkSet.p
include : FourShape (XH - DESCENDER)
include : ShiftDown
save 'four.onum'
define [FiveShape top bp] : glyph-construction
local t1 : top * bp * 0.8
local t2 : top * bp
local ycurly : mix 0 t2 (SMOOTHA / (SMOOTHA + SMOOTHB))
local xleft : mix SB RIGHTSB 0.025
local xright : [mix RIGHTSB SB 0.05] - OXE
local FiveStroke : dispiro
widths.rhs
g4 xleft (t2 - AHOOK * top / CAP)
hookstart (t2 - O)
g4 (RIGHTSB - OX) ycurly
hookend O
g4 SB (HOOK * top / CAP)
local fiveStroke : FiveStroke.call currentGlyph
local firstKnot : utp currentGlyph.gizmo fiveStroke.rhsKnots.(fiveStroke.rhsKnots.length - 1)
include : VBarRight firstKnot.x firstKnot.y top
include : HBarTop xleft xright top
if SLAB : begin
include : DownwardRightSerif xright top VJUT
sketch # five.lnum
include MarkSet.capital
include : FiveShape CAP FIVEBARPOS
save 'five.lnum' '5'
save 'five'
sketch # five.onum
include MarkSet.p
include : FiveShape (XH - DESCENDER) FIVEBARPOS
include : ShiftDown
save 'five.onum'
sketch # zhuangToneFive
include MarkSet.capital
include : FiveShape CAP FIVEBARPOS
save 'zhuangToneFive' 0x1BC
sketch # zhuangtonefive
include MarkSet.e
include : FiveShape XH FIVEBARPOS
save 'zhuangtonefive' 0x1BD
sketch # six
include MarkSet.capital
local top (CAP * 0.6)
local ymiddlea : (top - SMALLSMOOTHA + SMALLSMOOTHB) / 2
local ymiddleb : (top - SMALLSMOOTHB + SMALLSMOOTHA) / 2
include : dispiro
widths.rhs
g4.up.start (SB + OX + STROKE * 0.5 * HVCONTRAST) ymiddlea [widths.heading 0 (STROKE * 0.5) UPWARD]
arcvh
g4 (MIDDLE - CORRECTION_OMIDS) (top - O) [widths.rhs]
archv
g4.down.mid (RIGHTSB - OX) ymiddleb
arcvh
g4 (MIDDLE + CORRECTION_OMIDS) (O)
archv
g4.up.mid (SB + OX) ymiddlea
quadcontrols 0 0.8
g4 ([mix SB RIGHTSB 0.85] - HALFSTROKE * HVCONTRAST) CAP
save 'six.lnum' '6'
save 'six.onum'
save 'six'
define [SevenShape top] : glyph-construction
include : HBarTop (SB + OXE) RIGHTSB top
local x : mix SB RIGHTSB 0.28
local cor : [Math.hypot 1 ((RIGHTSB - x - HALFSTROKE) / (top - STROKE))] * HVCONTRAST
start-from (x - STROKE * cor / 2) 0
line-to (x + STROKE * cor / 2) 0
line-to RIGHTSB (top - STROKE)
line-to (RIGHTSB - STROKE * cor) (top - STROKE)
reverse-last
sketch # seven.lnum
include MarkSet.capital
include : SevenShape CAP
branch
save 'seven.lnum.noserif'
branch
include : DownwardLeftSerif (SB + OXE) CAP VJUT
save 'seven.lnum.serifed'
sketch # seven.onum
include MarkSet.p
include : SevenShape (XH - DESCENDER)
include : ShiftDown
branch
save 'seven.onum.noserif'
branch
include : DownwardLeftSerif (SB + OXE) XH VJUT
save 'seven.onum.serifed'
select-variant 'seven.lnum' '7' (follow -- 'seven')
select-variant 'seven.onum' (follow -- 'seven')
alias 'seven' nothing 'seven.lnum'
local EightPr : linreg 18 0.85 120 0.975 STROKE
define [EightShape top] : begin
local p 0.96
local l (SB + OX)
local r (RIGHTSB - OX)
return : dispiro
widths.rhs
g4.right.mid (MIDDLE - CORRECTION_OMIDS) (top - O)
archv
g4 [mix l r p] (top - SMOOTHB * EightPr * p)
alsothru 0.5 0.5 [widths.center]
g4 (l) (SMOOTHB * EightPr) [widths.lhs]
arcvh
g4.right.mid (MIDDLE + CORRECTION_OMIDS) (O)
archv
g4 (r) (SMOOTHA * EightPr) [widths.lhs]
alsothru 0.5 0.5 [widths.center]
g4 [mix r l p] (top - SMOOTHA * EightPr * p) [widths.rhs]
arcvh
close
sketch # eight
include MarkSet.capital
include : EightShape CAP
save 'eight.lnum' '8'
save 'eight.onum'
save 'eight'
# There is an "eight without lower contour" shape used for /propto
sketch # rotetedpropto
local p 0.96
local py 0.4
local l (SB + OX)
local r (RIGHTSB - OX)
include : dispiro
widths.lhs
straight.up.start r 0 [heading UPWARD]
alsothru 0.5 (1 - py) [widths (STROKE * py) (STROKE * (1 - py))]
g4 [mix r l p] (CAP - SMOOTHA * p * EightPr) [widths.rhs]
arcvh
g4 (MIDDLE - CORRECTION_OMIDS) (CAP - O)
archv
g4 [mix l r p] (CAP - SMOOTHB * p * EightPr)
alsothru 0.5 py [widths (STROKE * py) (STROKE * (1 - py))]
straight.down.end l 0 [widths.heading STROKE 0 DOWNWARD]
save 'rotetedpropto'
define [NineShape top] : begin
local u top
local d : Math.min (u - SMALLSMOOTHA - SMALLSMOOTHB - 0.1) (top * 0.425 - HALFSTROKE)
local l (SB + OX)
local r (RIGHTSB - OX)
local ymiddlea : mix u d 0.5
return : dispiro
widths.rhs (STROKE * CTHINB)
flat (r - STROKE * (1 - CTHINB) * HVCONTRAST) ymiddlea
curl (r - STROKE * (1 - CTHINB) * HVCONTRAST) (d + SMALLSMOOTHA)
arcvh
g4 ([mix l r 0.5] + CORRECTION_OMIDS) (d + O) [widths 0 STROKE]
archv
flat l (d + SMALLSMOOTHB)
curl l (u - SMALLSMOOTHA)
arcvh
g4 ([mix l r 0.5] - CORRECTION_OMIDS) (u - O)
archv
flat r ymiddlea
curl r SMALLSMOOTHA
hookend O
g4 SB HOOK
sketch # nine
include MarkSet.capital
include : NineShape CAP
save 'nine.lnum' '9'
save 'nine'
sketch
include MarkSet.p
include : NineShape (XH - DESCENDER)
include : ShiftDown
save 'nine.onum'
sketch # ten
include MarkSet.capital
set-width : WIDTH * 2
include glyphs.one
apply-transform : Translate (-WIDTH) 0
include glyphs.zero
apply-transform : Translate WIDTH 0
save 'ten'