Refactor out cursives to a separate file (#2437)
This commit is contained in:
parent
1146e47850
commit
61ad3c365c
7 changed files with 118 additions and 97 deletions
|
@ -434,7 +434,7 @@ glyph-block CommonShapes : begin
|
||||||
local mixRatio : determineMixR w v u sw doSwash
|
local mixRatio : determineMixR w v u sw doSwash
|
||||||
local mx : [mix toStraight.x toFinish.x mixRatio] + [if atBottom 1 (-1)] * 0.75 * CorrectionOMidX * sw
|
local mx : [mix toStraight.x toFinish.x mixRatio] + [if atBottom 1 (-1)] * 0.75 * CorrectionOMidX * sw
|
||||||
local keyKnotDirection : if ltr Rightward Leftward
|
local keyKnotDirection : if ltr Rightward Leftward
|
||||||
local extraSlope : [if ltr 1 (-1)] * 0.25 * (sw - swTerminal) / sw
|
local extraSlope : [if ltr 1 (-1)] * 0.5 * (sw - swTerminal) / sw
|
||||||
local finalTurnSlope : keyKnotDirection.x + extraSlope - [if ltr 1 (-1)] * 0.5 * TanSlope
|
local finalTurnSlope : keyKnotDirection.x + extraSlope - [if ltr 1 (-1)] * 0.5 * TanSlope
|
||||||
local keyKnot : g4.[if ltr "right" "left"].mid
|
local keyKnot : g4.[if ltr "right" "left"].mid
|
||||||
begin mx
|
begin mx
|
||||||
|
|
|
@ -118,6 +118,9 @@ export : define [buildGlyphs para recursive] : begin
|
||||||
# Numbers
|
# Numbers
|
||||||
run-glyph-module "./number/index.mjs"
|
run-glyph-module "./number/index.mjs"
|
||||||
|
|
||||||
|
# Letter-likes
|
||||||
|
run-glyph-module "./letter-like/cursive.mjs"
|
||||||
|
|
||||||
# Symbols
|
# Symbols
|
||||||
run-glyph-module "./symbol/shared.mjs"
|
run-glyph-module "./symbol/shared.mjs"
|
||||||
run-glyph-module "./symbol/punctuation.mjs"
|
run-glyph-module "./symbol/punctuation.mjs"
|
||||||
|
|
93
packages/font-glyphs/src/letter-like/cursive.ptl
Normal file
93
packages/font-glyphs/src/letter-like/cursive.ptl
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
###### Cursive letter-like symbols
|
||||||
|
|
||||||
|
$$include '../meta/macros.ptl'
|
||||||
|
|
||||||
|
import [Box] from "@iosevka/geometry/box"
|
||||||
|
import [mix fallback] from "@iosevka/util"
|
||||||
|
|
||||||
|
glyph-module
|
||||||
|
|
||||||
|
glyph-block LetterLike-Cursive-Shared : begin
|
||||||
|
glyph-block-import CommonShapes
|
||||||
|
|
||||||
|
glyph-block-export DrCursive
|
||||||
|
class DrCursive
|
||||||
|
public [new box sw] : begin
|
||||||
|
this.box = box
|
||||||
|
this.sw = sw
|
||||||
|
|
||||||
|
public [withSw sw] : new DrCursive this.box sw
|
||||||
|
public [withXMix pL pR] : new DrCursive [this.box.withXMix pL pR] this.sw
|
||||||
|
public [withYMix pB pT] : new DrCursive [this.box.withYMix pB pT] this.sw
|
||||||
|
|
||||||
|
public [x pX _pSX _deltaX] : begin
|
||||||
|
local pSX : fallback _pSX 0
|
||||||
|
local deltaX : fallback _deltaX 0
|
||||||
|
return : [mix this.box.left this.box.right pX] + pSX * HVContrast * this.sw + deltaX
|
||||||
|
|
||||||
|
public [y pY _pSY _deltaY] : begin
|
||||||
|
local pSY : fallback _pSY 0
|
||||||
|
local deltaY : fallback _deltaY 0
|
||||||
|
return : [mix this.box.bottom this.box.top pY] + pSY * this.sw + deltaY
|
||||||
|
|
||||||
|
public [s pS d] : if d
|
||||||
|
then : return : widths.heading ((1 - pS) * this.sw) (pS * this.sw) d
|
||||||
|
else : return : widths ((1 - pS) * this.sw) (pS * this.sw)
|
||||||
|
|
||||||
|
public [lhs d] : this.s 0 d
|
||||||
|
public [cen d] : this.s 0.5 d
|
||||||
|
public [rhs d] : this.s 1 d
|
||||||
|
|
||||||
|
glyph-block LetterLike-Cursive : begin
|
||||||
|
glyph-block-import CommonShapes
|
||||||
|
glyph-block-import LetterLike-Cursive-Shared : DrCursive
|
||||||
|
|
||||||
|
create-glyph 'ell' 0x2113 : glyph-proc
|
||||||
|
include : MarkSet.b
|
||||||
|
|
||||||
|
local loopSize : Width * 0.25 + HalfStroke * HVContrast
|
||||||
|
local l : Middle - loopSize
|
||||||
|
local r : Middle + loopSize
|
||||||
|
|
||||||
|
local dr : new DrCursive [new Box Ascender 0 l r] Stroke
|
||||||
|
local loop : dr.withXMix 0 0.9 :.withSw [AdviceStroke 5.5]
|
||||||
|
local tip : dr.withSw [AdviceStroke 6.5]
|
||||||
|
|
||||||
|
local ada : 0.8 * SmallArchDepthA + 0.25 * dr.sw
|
||||||
|
local adb : 0.8 * SmallArchDepthB + 0.25 * dr.sw
|
||||||
|
|
||||||
|
include : dispiro
|
||||||
|
g2 [loop.x 0] [loop.y 0.33] [loop.cen]
|
||||||
|
g2.up.mid [loop.x 1 0 (-O)] [loop.y 0.8] [loop.lhs]
|
||||||
|
~~~ [arch.lhs [loop.y 1 0 O] (sw -- loop.sw) (swAfter -- dr.sw)]
|
||||||
|
flat [dr.x 0.5 (-0.75)] [dr.y 1 0 (-ada)] [dr.lhs]
|
||||||
|
curl [dr.x 0.5 (-0.75)] [dr.y 0 0 (+adb)] [dr.lhs]
|
||||||
|
~~~ [hookend O (sw -- dr.sw) (swTerminal -- tip.sw) (isTail -- true)]
|
||||||
|
g2 [tip.x 1] (SHook + dr.sw * 0.5) [tip.lhs]
|
||||||
|
|
||||||
|
create-glyph 'weierstrassP' 0x2118 : glyph-proc
|
||||||
|
include : MarkSet.p
|
||||||
|
|
||||||
|
local thick : AdviceStroke 2.5
|
||||||
|
local extSw : AdviceStroke 3.5
|
||||||
|
local fine : AdviceStroke 5.5
|
||||||
|
local tip : AdviceStroke 6.5
|
||||||
|
|
||||||
|
local bowl : new DrCursive [new Box XH 0 SB RightSB] thick
|
||||||
|
local extn : new DrCursive [new Box XH Descender SB [mix SB RightSB 0.3]] extSw
|
||||||
|
local bowT : bowl.withSw tip
|
||||||
|
local extF : extn.withSw fine
|
||||||
|
local extT : extn.withSw tip
|
||||||
|
|
||||||
|
include : dispiro
|
||||||
|
g2 [extT.x 0.25 0.5] [extT.y 1] [extT.cen]
|
||||||
|
g2.down.mid [extF.x 0 0 O] [extF.y 0.8] [extF.lhs]
|
||||||
|
~~~ [alsoThru.g2 0.5 0.5 [extn.cen]]
|
||||||
|
g2.down.mid [extF.x 1 0.4 (-O)] [extn.y 0.2 (-TanSlope)] [extn.s (fine / extSw)]
|
||||||
|
~~~ [arch.rhs [extF.y 0 0 0] (sw -- extF.sw)]
|
||||||
|
g2.up.mid [extF.x 0 0 O] [extF.y 0.2] [extF.rhs]
|
||||||
|
~~~ [arch.rhs [bowl.y 1 0 (-O)] 0.625 (sw -- bowl.sw) (swBefore -- extF.sw)
|
||||||
|
(blendPre -- [bezControls 0 0.5 0.4 1 16])]
|
||||||
|
straight.down.mid [bowl.x 1 0 (-O)] [bowl.y 0.5]
|
||||||
|
~~~ [arch.rhs [bowl.y 0 0 O] (sw -- bowl.sw) (swAfter -- bowT.sw)]
|
||||||
|
g2 [bowT.x 0.4] [bowT.y 0.3] [bowT.rhs Upward]
|
|
@ -7,6 +7,10 @@ define-operator "--" 890 'right' : syntax-rules
|
||||||
define-operator "~>" 880 'right' : syntax-rules
|
define-operator "~>" 880 'right' : syntax-rules
|
||||||
`(@l ~> @r) `{.left @l .right @r}
|
`(@l ~> @r) `{.left @l .right @r}
|
||||||
|
|
||||||
|
### The operator indicating a "mix"
|
||||||
|
define-operator prefix "~~~" : syntax-rules
|
||||||
|
`(~~~ @x) : dirty [formOf x]
|
||||||
|
|
||||||
### Macro for identity match
|
### Macro for identity match
|
||||||
define-macro Just : begin
|
define-macro Just : begin
|
||||||
local m : syntax-rules
|
local m : syntax-rules
|
||||||
|
@ -277,7 +281,7 @@ define-macro glyph-block : syntax-rules
|
||||||
NarrowUnicodeT WideUnicodeT VERY-FAR TINY]
|
NarrowUnicodeT WideUnicodeT VERY-FAR TINY]
|
||||||
define spiroFnImports `[g4 g2 corner flat curl close end straight widths
|
define spiroFnImports `[g4 g2 corner flat curl close end straight widths
|
||||||
disable-contrast heading unimportant important alsoThru alsoThruThem bezControls
|
disable-contrast heading unimportant important alsoThru alsoThruThem bezControls
|
||||||
quadControls archv arcvh dispiro spiro-outline CursiveBuilder]
|
quadControls archv arcvh dispiro spiro-outline]
|
||||||
define booleFnImports `[union intersection difference]
|
define booleFnImports `[union intersection difference]
|
||||||
|
|
||||||
dirty `[$GlyphBlocks$.push : lambda [$Capture_Ext$] : begin \\
|
dirty `[$GlyphBlocks$.push : lambda [$Capture_Ext$] : begin \\
|
||||||
|
|
|
@ -112,59 +112,6 @@ glyph-block Symbol-Letter : begin
|
||||||
alias 'eulerConst' 0x2107 'latn/Epsilon'
|
alias 'eulerConst' 0x2107 'latn/Epsilon'
|
||||||
alias 'scruple' 0x2108 'cyrl/E'
|
alias 'scruple' 0x2108 'cyrl/E'
|
||||||
|
|
||||||
create-glyph 'ell' 0x2113 : glyph-proc
|
|
||||||
include : MarkSet.b
|
|
||||||
local fine : AdviceStroke 3.5
|
|
||||||
local radius : Math.max fine (Width * 0.15)
|
|
||||||
local middle : Middle - fine / 2
|
|
||||||
local left : middle - radius * 1.25
|
|
||||||
local right : middle + radius * 1.5
|
|
||||||
local ada : ArchDepthA * 0.6
|
|
||||||
local adb : ArchDepthB * 0.6
|
|
||||||
include : dispiro
|
|
||||||
widths.center fine
|
|
||||||
g2 left [mix 0 CAP 0.33]
|
|
||||||
quadControls 1 0.6
|
|
||||||
g2 right [mix 0 CAP 0.8]
|
|
||||||
arcvh
|
|
||||||
g2 [mix middle right 0.5] (CAP - O - fine / 2)
|
|
||||||
archv
|
|
||||||
flat middle (CAP - ada)
|
|
||||||
curl middle (ArchDepthB * 0.5 + fine / 2)
|
|
||||||
hookend (O + fine / 2) (sw -- fine)
|
|
||||||
g2 (middle + radius * 2) SHook
|
|
||||||
|
|
||||||
create-glyph 'weierstrassP' 0x2118 : glyph-proc
|
|
||||||
include : MarkSet.p
|
|
||||||
|
|
||||||
local thick : AdviceStroke 2.75
|
|
||||||
local extSw : AdviceStroke 4
|
|
||||||
local fine : AdviceStroke 5.5
|
|
||||||
local tip : AdviceStroke 6.5
|
|
||||||
|
|
||||||
local bowl : CursiveBuilder [new Box XH 0 SB RightSB] thick
|
|
||||||
local extn : CursiveBuilder [new Box XH Descender SB [mix SB RightSB 0.3]] extSw
|
|
||||||
local bowT : bowl.withSw tip
|
|
||||||
local extF : extn.withSw fine
|
|
||||||
local extT : extn.withSw tip
|
|
||||||
|
|
||||||
include : dispiro
|
|
||||||
g2 [extT.x 0.25 0.5 0 ] [extT.y 1 0 0 ] [extT.s 0.5]
|
|
||||||
g2.down.mid [extF.x 0 0 O ] [extF.y 0.8 0 0 ] [extF.s 0]
|
|
||||||
alsoThru.g2 0.5 0.5 [extn.s 0.5]
|
|
||||||
g2.down.mid [extF.x 1 0.4 (-O) ] [extn.y 0.2 (-TanSlope) 0] [extn.s (fine / extSw)]
|
|
||||||
arcvh
|
|
||||||
g2 [extF.xAB 0.5 0.2 0 ] [extF.y 0 0 O ] [extF.s 1]
|
|
||||||
archv
|
|
||||||
g2.up.mid [extF.x 0 0 O ] [extF.y 0.2 0 0 ] [extF.s 1]
|
|
||||||
bezControls 0 0.5 0.4 1 16
|
|
||||||
g2 [bowl.xAT 0.7 (-0.3) 0 ] [bowl.y 1 0 (-O) ] [bowl.s 1]
|
|
||||||
archv
|
|
||||||
straight.down.mid [bowl.x 1 0 (-O) ] [bowl.y 0.5 0 0 ]
|
|
||||||
arcvh
|
|
||||||
g2 [bowl.xAB 0.7 (-0.2) 0 ] [bowl.y 0 0 O ]
|
|
||||||
archv
|
|
||||||
g2 [bowT.x 0.4 0 0 ] [bowT.y 0.3 0 0 ] [bowT.s 1 Upward]
|
|
||||||
|
|
||||||
alias 'Ohm' 0x2126 'grek/Omega'
|
alias 'Ohm' 0x2126 'grek/Omega'
|
||||||
turned 'Mho' 0x2127 'Ohm' Middle (CAP / 2)
|
turned 'Mho' 0x2127 'Ohm' Middle (CAP / 2)
|
||||||
|
|
|
@ -369,47 +369,6 @@ export function SetupBuilders(bindings) {
|
||||||
return new SpiroOutlineImpl(bindings, args);
|
return new SpiroOutlineImpl(bindings, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
class CCursiveBuilder {
|
|
||||||
constructor(box, sw) {
|
|
||||||
this.box = box;
|
|
||||||
this.sw = sw;
|
|
||||||
}
|
|
||||||
|
|
||||||
withSw(sw) {
|
|
||||||
return new CCursiveBuilder(this.box, sw);
|
|
||||||
}
|
|
||||||
|
|
||||||
x(pX, _pSX, _deltaX) {
|
|
||||||
const pSX = fallback(_pSX, 0);
|
|
||||||
const deltaX = fallback(_deltaX, 0);
|
|
||||||
const sw = this.sw;
|
|
||||||
return mix(this.box.left, this.box.right, pX) + pSX * Contrast * sw + deltaX;
|
|
||||||
}
|
|
||||||
xAT(px, _pSX, _deltaX) {
|
|
||||||
return this.x(px, _pSX, _deltaX) - this.sw * CorrectionOMidX;
|
|
||||||
}
|
|
||||||
xAB(px, _pSX, _deltaX) {
|
|
||||||
return this.x(px, _pSX, _deltaX) + this.sw * CorrectionOMidX;
|
|
||||||
}
|
|
||||||
y(pY, _pSY, _deltaY) {
|
|
||||||
const pSY = fallback(_pSY, 0);
|
|
||||||
const deltaY = fallback(_deltaY, 0);
|
|
||||||
const sw = this.sw;
|
|
||||||
return mix(this.box.bottom, this.box.top, pY) + pSY * sw + deltaY;
|
|
||||||
}
|
|
||||||
s(pS, d) {
|
|
||||||
const sw = fallback(this.sw);
|
|
||||||
if (d) {
|
|
||||||
return widths.heading((1 - pS) * sw, pS * sw, d);
|
|
||||||
} else {
|
|
||||||
return widths((1 - pS) * sw, pS * sw);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function CursiveBuilder(box, sw) {
|
|
||||||
return new CCursiveBuilder(box, sw);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
g4,
|
g4,
|
||||||
g2,
|
g2,
|
||||||
|
@ -432,6 +391,5 @@ export function SetupBuilders(bindings) {
|
||||||
arcvh,
|
arcvh,
|
||||||
dispiro,
|
dispiro,
|
||||||
"spiro-outline": spiroOutline,
|
"spiro-outline": spiroOutline,
|
||||||
CursiveBuilder,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,22 @@ export class Box {
|
||||||
withYPadding(d) {
|
withYPadding(d) {
|
||||||
return new Box(this.top - d, this.bottom + d, this.left, this.right);
|
return new Box(this.top - d, this.bottom + d, this.left, this.right);
|
||||||
}
|
}
|
||||||
|
withXMix(pL, pR) {
|
||||||
|
return new Box(
|
||||||
|
this.top,
|
||||||
|
this.bottom,
|
||||||
|
mix(this.left, this.right, pL),
|
||||||
|
mix(this.left, this.right, pR),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
withYMix(pT, pB) {
|
||||||
|
return new Box(
|
||||||
|
mix(this.bottom, this.top, pT),
|
||||||
|
mix(this.bottom, this.top, pB),
|
||||||
|
this.left,
|
||||||
|
this.right,
|
||||||
|
);
|
||||||
|
}
|
||||||
mixX(t) {
|
mixX(t) {
|
||||||
return mix(this.left, this.right, t);
|
return mix(this.left, this.right, t);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue