Make _scl argument for [UnicodeWeightGrade n _scl] default to 1.

This commit is contained in:
John McWilliams 2025-05-03 06:42:50 -04:00
parent 51c8e487fc
commit babb2c8ea4
2 changed files with 19 additions and 18 deletions

View file

@ -39,7 +39,7 @@ export : define [calculateMetrics para] : begin
# Transform constructors
define [Italify angle shift] : begin
local slope : Math.tan ([fallback angle para.slopeAngle] / 180 * Math.PI)
local slope : Math.tan : [fallback angle para.slopeAngle] / 180 * Math.PI
return : new Transform 1 slope 0 1 [fallback shift : (-slope) * SymbolMid] 0
define [Upright angle shift] [Italify angle shift :.inverse]
define [Scale sx sy] : new Transform sx 0 0 [fallback sy sx] 0 0
@ -49,16 +49,16 @@ export : define [calculateMetrics para] : begin
define GlobalTransform : Italify para.slopeAngle
define TanSlope GlobalTransform.xy
define SinSlope : Math.sin (para.slopeAngle / 180 * Math.PI)
define CosSlope : Math.cos (para.slopeAngle / 180 * Math.PI)
define SinSlope : Math.sin : para.slopeAngle / 180 * Math.PI
define CosSlope : Math.cos : para.slopeAngle / 180 * Math.PI
define HVContrast : Contrast * CosSlope + SinSlope * TanSlope
define [HSwToV sw] : sw * HVContrast
define [VSwToH sw] : sw / HVContrast
# Orient parameters
define Upward : new Point Point.Type.Corner (-HVContrast) 0
define Downward : new Point Point.Type.Corner HVContrast 0
define Rightward : new Point Point.Type.Corner 0 1
define Downward : new Point Point.Type.Corner (+HVContrast) 0
define Rightward : new Point Point.Type.Corner 0 (+1)
define Leftward : new Point Point.Type.Corner 0 (-1)
# Style parameters
@ -77,7 +77,7 @@ export : define [calculateMetrics para] : begin
define SmallArchDepth para.smallArchDepth
# Weight Control
define BaseFillRate : Math.min 0.95 : 2 * HVContrast * para.stroke / (Width - SB * 2)
define BaseFillRate : Math.min 0.95 : [HSwToV : 2 * para.stroke] / (Width - SB * 2)
define WeightControlFactor : [Math.atanh BaseFillRate] / BaseFillRate
define [StrokeWeightControlSigmoid x] : Math.tanh : WeightControlFactor * x
@ -112,22 +112,22 @@ export : define [calculateMetrics para] : begin
define AccentStackOffset para.accentStackOffset
define AccentWidth para.accentWidth
define AccentClearance para.accentClearance
define AccentHeight para.accentHeight
define AccentHeight para.accentHeight
define CThin : fallback para.cthin 0.75
define CThinB : fallback para.cthinb 0.5
define CThin : fallback para.cthin 0.75
define CThinB : fallback para.cthinb 0.50
define SLAB para.slab
define [IBalance df] : df.adws * df.adws * [fallback para.ibalance (LongJut * 0.04)] # Serifed
define [IBalance2 df] : df.adws * [fallback para.ibalance2 (LongJut * 0.14)] # Hooky, Tailed
define JBalance : fallback para.jbalance 0
define JBalance2 : fallback para.jbalance2 (QuarterStroke + LongJut * 0.04)
define TBalance : fallback para.tbalance JBalance
define JBalance : fallback para.jbalance 0
define JBalance2 : fallback para.jbalance2 (LongJut * 0.04 + QuarterStroke)
define TBalance : fallback para.tbalance JBalance
define TBalance2 : fallback para.tbalance2 TBalance
define RBalance : fallback para.rbalance (JBalance * 0.3)
define RBalance2 : fallback para.rbalance2 0
define FBalance : fallback para.fbalance 0
define FBalance : fallback para.fbalance 0
define OneBalance : fallback para.onebalance 0
# derived metrics
@ -190,10 +190,11 @@ export : define [calculateMetrics para] : begin
define GeometryStroke : AdviceStroke 4
define ShoulderFine : Math.min (Stroke * para.shoulderFineMin) : AdviceStroke 24
define [UnicodeWeightGrade n s] : begin
define kw : 10 - s - n / 200
define [mulPow ss] : (0.25 + ss / 8) * [StrokeWidthBlend 2 1]
define kMul : [Math.pow (n / 100) : mulPow s] / [Math.pow 4 : mulPow 2]
define [UnicodeWeightGrade n _scl] : begin
define scl : fallback _scl 1
define kw : 10 - scl - n / 200
define [mulPow s] : (0.25 + s / 8) * [StrokeWidthBlend 2 1]
define kMul : [Math.pow (n / 100) : mulPow scl] / [Math.pow 4 : mulPow 2]
define kAdj : GeometryStroke / [AdviceStroke 6]
return : kMul * kAdj * [AdviceStroke kw]

View file

@ -334,7 +334,7 @@ glyph-block Symbol-Letter : begin
create-glyph 'informationSource' 0x2139 : glyph-proc
include : MarkSet.b
local sw : UnicodeWeightGrade 900 1
local sw : UnicodeWeightGrade 900
include : VBar.m Middle 0 XH sw
include : HSerif.lt (Middle - [HSwToV : 0.5 * sw]) XH (LongJut / 2)
include : HSerif.lb (Middle - [HSwToV : 0.5 * sw]) 0 (LongJut / 2)