Skip to content

Commit

Permalink
Add dollar/cent with slanted stroke. (#2408) (#2474)
Browse files Browse the repository at this point in the history
* Use variants-buildup mechanism for dollar and cent variants

* Add Dollar/cent with slanted stroke (#2408)
  • Loading branch information
be5invis authored Aug 19, 2024
1 parent 304183d commit 67f7a43
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 131 deletions.
94 changes: 52 additions & 42 deletions packages/font-glyphs/src/letter/latin/c.ptl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$$include '../../meta/macros.ptl'

import [mix linreg clamp fallback] from "@iosevka/util"
import [mix linreg clamp fallback SuffixCfg] from "@iosevka/util"
import [DependentSelector MathSansSerif] from "@iosevka/glyph/relation"

glyph-module
Expand Down Expand Up @@ -371,51 +371,61 @@ glyph-block Letter-Latin-C : begin
CShapeT spiro-outline 0.1 [DivFrame 1] SLAB-NONE SLAB-NONE XH 0 SmallArchDepthA SmallArchDepthB Hook BBS
VBar.l (SB + BBD + OX) 0 CAP BBS

define CentBarConfig : object
open { (Descender / 2) (XH - Descender / 2) 0 "std" }
through { (Descender / 2) (XH - Descender / 2) 1 "std" }
interrupted { (Descender / 2) (XH - Descender / 2) 2 "std" }
openCap { 0 CAP 0 "cap" }
throughCap { 0 CAP 1 "cap" }
interruptedCap { 0 CAP 2 "cap" }
define CentConfig : SuffixCfg.weave
object # slope
"" 0
"slanted" 0.08
object # body
open 0
through 1
interrupted 2
object # height
"" { 0 XH (Descender / 2) (XH - Descender / 2) "std" }
"cap" { (CAP / 2 - XH / 2) (CAP / 2 + XH / 2) 0 CAP "cap" }

foreach { suffix { sl fillType { bMask tMask bot top selector }}} [pairs-of CentConfig] : do
define [xBot df] : mix df.leftSB df.rightSB (0.5 - sl)
define [xTop df] : mix df.leftSB df.rightSB (0.5 + sl)

define swBarThick : AdviceStroke 3
define swBarFine : AdviceStroke [StrokeWidthBlend 3 5.5]

define [FullBar df sw] : dispiro
flat [xBot df] bot [widths.center.heading sw Downward]
curl [xTop df] top [widths.center.heading sw Downward]

define [InterruptBar df] : begin
local cofine : AdviceStroke 4
return : union
dispiro
flat [xTop df] top [widths.center.heading cofine Downward]
curl df.middle [mix top bot 0.5] [widths.center.heading swBarFine Downward]
dispiro
flat [xBot df] bot [widths.center.heading cofine Upward]
curl df.middle [mix bot top 0.5] [widths.center.heading swBarFine Upward]

define [OutlineMask df] : spiro-outline
curl (df.leftSB + 0.5 * Stroke) (post@ <-> SmallArchDepthA)
arch.rhs (sw -- Stroke) (tMask - 0.5 * Stroke)
flat (df.rightSB - 0.5 * Stroke) (pre@ <-> SmallArchDepthB)
curl pre@ (post@ <+> SmallArchDepthA)
arch.rhs (sw -- Stroke) (bMask + 0.5 * Stroke)
flat post@ (pre@ <+> SmallArchDepthB)

define [InterruptMask df] : begin
define gap : Math.max (XH / 8) [AdviceStroke2 6 6 XH]
return : HBar.m 0 df.width [mix bot top 0.5] gap

foreach { suffix { bot top fillType selector } } [Object.entries CentBarConfig] : do
create-glyph "cent/bar.\(suffix)" : glyph-proc
define w : AdviceStroke 3
define fine : AdviceStroke [StrokeWidthBlend 3 5.5]

local yMid : mix bot top 0.5
local fillBottom : yMid - XH / 2 + HalfStroke
local fillTop : yMid + XH / 2 - HalfStroke

set-base-anchor 'cvDecompose' Middle yMid

# Draw the outside subbars
include : dispiro
flat Middle fillTop [widths.center w]
curl Middle top [heading Upward]
include : dispiro
flat Middle fillBottom [widths.center w]
curl Middle bot [heading Downward]

include : match fillType
[Just 1] : VBar.m Middle fillBottom fillTop fine
[Just 2] : begin
define cofine : AdviceStroke 4
define gap : Math.max (XH / 8) [AdviceStroke2 6 6 XH]

union
dispiro
flat Middle fillTop [widths.center.heading cofine Downward]
curl Middle (yMid + gap / 2) [widths.center.heading fine Downward]
dispiro
flat Middle fillBottom [widths.center.heading cofine Upward]
curl Middle (yMid - gap / 2) [widths.center.heading fine Upward]

__ : no-shape

local df : include : DivFrame 1
set-base-anchor 'cvDecompose' df.middle [mix bot top 0.5]
DependentSelector.set currentGlyph selector

include : difference [FullBar df swBarThick] [OutlineMask df]
if (fillType === 1) : include : intersection [FullBar df swBarFine] [OutlineMask df]
if (fillType === 2) : include : intersection [InterruptBar df]
difference [OutlineMask df] [InterruptMask df]

select-variant 'cent/bar' (follow -- 'cent')

CreateDependentComposite 'cent/centSign' 0xA2 "cent/bar" : object
Expand Down
105 changes: 62 additions & 43 deletions packages/font-glyphs/src/letter/latin/s.ptl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$$include '../../meta/macros.ptl'

import [mix linreg clamp fallback] from "@iosevka/util"
import [mix linreg clamp fallback SuffixCfg] from "@iosevka/util"
import [DependentSelector MathSansSerif] from "@iosevka/glyph/relation"

glyph-module
Expand Down Expand Up @@ -461,52 +461,71 @@ glyph-block Letter-Latin-S : begin
.y ([if (sign < 0) 0.25 0.375] * sign * BBD * [Math.cos theta])
}

define DollarConfig : SuffixCfg.weave
object # slope
"" 0
"slanted" 0.08
object # body
open 0
through 1
interrupted 2
object # height
"" { 0.05 0.95 (Descender / 2) "std" }
"cap" { 0.12 0.88 0 "cap" }

foreach { suffix { sl fillType { kBot kTop overflow selector } } } [pairs-of DollarConfig] : do
define [xBot df] : mix df.leftSB df.rightSB (0.5 - sl)
define [xTop df] : mix df.leftSB df.rightSB (0.5 + sl)
define bot : CAP * kBot
define top : CAP * kTop

define swBarThick : AdviceStroke 3
define swBarFine : AdviceStroke [StrokeWidthBlend 3 5.5]

define [FullBar df sw] : dispiro
flat [xBot df] (0 + overflow) [widths.center.heading sw Downward]
curl [xTop df] (CAP - overflow) [widths.center.heading sw Downward]

define [InterruptBar df] : begin
local cofine : AdviceStroke 4
return : union
dispiro
flat [xTop df] (CAP - overflow) [widths.center.heading cofine Downward]
curl df.middle [mix top bot 0.5] [widths.center.heading swBarFine Downward]
dispiro
flat [xBot df] (0 + overflow) [widths.center.heading cofine Upward]
curl df.middle [mix bot top 0.5] [widths.center.heading swBarFine Upward]

define [DollarMask df stroke] : begin
define archDepthA : AdviceSArchDepth (top - bot) (-1) stroke
define archDepthB : AdviceSArchDepth (top - bot) (+1) stroke
return : spiro-outline
curl (df.leftSB + 0.5 * stroke) (post@ <-> archDepthA)
arch.rhs (sw -- stroke) (top - 0.5 * stroke)
flat (df.rightSB - 0.5 * stroke) (pre@ <-> archDepthB)
curl pre@ (post@ <+> archDepthA)
arch.rhs (sw -- stroke) (bot + 0.5 * stroke)
flat post@ (pre@ <+> archDepthB)

define [InterruptMask df] : begin
local gap : (swBarThick / Stroke * EssUpper) + [Math.max ((top - bot) / 6) [AdviceStroke2 3 3 (top - bot)]]
local yMid : mix bot top 0.5
local yTermLeft : mix yMid (top - [AdviceSArchDepth (top - bot) (-1) swBarThick]) 0.5
local yTermRight : mix yMid (bot + [AdviceSArchDepth (top - bot) (-1) swBarThick]) 0.5

return : dispiro [corner 0 yTermLeft : widths.center gap] [corner Width yTermRight]


define DollarConfig : object
open { 0.95 0.05 (Descender / 2) 0 "std" }
through { 0.95 0.05 (Descender / 2) 1 "std" }
interrupted { 0.95 0.05 (Descender / 2) 2 "std" }
openCap { 0.88 0.12 0 0 "cap" }
throughCap { 0.88 0.12 0 1 "cap" }
interruptedCap { 0.88 0.12 0 2 "cap" }

foreach { suffix { kTop kBot overflow fillType selector } } [Object.entries DollarConfig] : do
create-glyph "dollar/bar.\(suffix)" : glyph-proc
define top : CAP * kTop
define bot : CAP * kBot
define w : AdviceStroke 3
define fine : AdviceStroke [StrokeWidthBlend 3 5.5]
local df : include : DivFrame 1
set-base-anchor 'cvDecompose' df.middle (CAP / 2)
DependentSelector.set currentGlyph selector

set-base-anchor 'cvDecompose' Middle (CAP / 2)
local [outlineMask] : DollarMask df [AdviceStroke2 2 3 CAP]

include : dispiro
widths.center w
flat Middle (top - HalfStroke)
curl Middle (CAP - overflow) [heading Upward]
include : dispiro
widths.center w
flat Middle overflow [heading Upward]
curl Middle (bot + HalfStroke)
if (fillType === 1) : include : VBar.m Middle (bot + HalfStroke) (top - HalfStroke) fine
if (fillType === 2) : begin
local cofine : AdviceStroke 4
local gap : (w / Stroke * EssUpper) + [Math.max ((top - bot) / 6) [AdviceStroke2 3 3 (top - bot)]]
local yMid : mix bot top 0.5
local yTermLeft : mix yMid (top - [AdviceSArchDepth (top - bot) (-1) w]) 0.5
local yTermRight : mix yMid (bot + [AdviceSArchDepth (top - bot) (-1) w]) 0.5
include : difference
union
dispiro
flat Middle (top - HalfStroke) [widths.center.heading cofine Downward]
curl Middle [mix bot top 0.5] [widths.center.heading fine Downward]
dispiro
flat Middle (bot + HalfStroke) [widths.center.heading cofine Upward]
curl Middle [mix bot top 0.5] [widths.center.heading fine Upward]

dispiro [corner 0 yTermLeft : widths.center gap] [corner Width yTermRight]

DependentSelector.set currentGlyph selector
include : difference [FullBar df swBarThick] [outlineMask]
if (fillType === 1) : include : intersection [FullBar df swBarFine] [outlineMask]
if (fillType === 2) : include : intersection [InterruptBar df]
difference [outlineMask] [InterruptMask df]

select-variant 'dollar/bar' (follow -- 'dollar')

Expand Down
Loading

0 comments on commit 67f7a43

Please sign in to comment.