From e38fff51a3424204de2586e00c40d813392c3d5a Mon Sep 17 00:00:00 2001 From: Belleve Date: Fri, 28 Jun 2024 00:59:47 -1000 Subject: [PATCH] Adjust balancing of r with corner hooks (#2394) (#2398) --- changes/30.3.1.md | 1 + .../font-glyphs/src/letter/latin/lower-r.ptl | 51 +++++++++---------- packages/font-otl/src/index.ptl | 7 +-- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/changes/30.3.1.md b/changes/30.3.1.md index d89b08c3e..86a0a1e3e 100644 --- a/changes/30.3.1.md +++ b/changes/30.3.1.md @@ -4,3 +4,4 @@ * Optimize glyph shape for `U+01A6`. * Make Aile and Etoile use {`six`|`nine`}.`closed-contour` by default. * Make `ss20` use `seven`.`curly-serifless` by default. +* Adjust balancing of r with corner hooks (#2394). diff --git a/packages/font-glyphs/src/letter/latin/lower-r.ptl b/packages/font-glyphs/src/letter/latin/lower-r.ptl index 79ab29123..fc48b76af 100644 --- a/packages/font-glyphs/src/letter/latin/lower-r.ptl +++ b/packages/font-glyphs/src/letter/latin/lower-r.ptl @@ -15,6 +15,8 @@ glyph-block Letter-Latin-Lower-R : begin local dfN : DivFrame 1 local dfR : DivFrame para.diversityF + + # Modes local rStraight 0 local rSerifed 1 local rNarrow 2 @@ -28,17 +30,15 @@ glyph-block Letter-Latin-Lower-R : begin local stroke : fallback _stroke Stroke local strokeA : mix strokeBar stroke 0.5 local { rBalanceMultiplier rHookMultiplier rHookSwMultiplier rSerifLeftExtender hookSuperness } : match mode - [Just rStraight] { 1 1 0 0 2.35 } - [Just rSerifed] { (4 / 3) (2 / 3) (1 / 4) (1 / 3) 2.35 } - [Just rNarrow] { (2 * (df.div - 0.5)) 1 0 0 2.35 } - [Just rNarrowSerifed] { (5 / 8 * df.div) (3 / 4) 0 (1 / 2 * [Math.max 0 : mix 1 df.div 4]) 2.35 } - [Just rCornerHooked] { (2 * (df.div - 0.5)) 1 0 0 2.35 } - [Just rCornerHookedSerifed] { (4 / 3) (2 / 3) (1 / 4) (1 / 3) 2.35 } - [Just rEarless] { 1 1 0 0 2.35 } + [Just rStraight] { 1 1 0 0 2.35 } + [Just rSerifed] { (4 / 3) (2 / 3) (1 / 4) (1 / 3) 2.35 } + [Just rNarrow] { (2 * (df.div - 0.5)) 1 0 0 2.35 } + [Just rNarrowSerifed] { (2 * (df.div - 0.5)) 1 0 0 2.35 } + [Just rCornerHooked] { (5 / 8) 1 0 0 2.35 } + [Just rCornerHookedSerifed] { (4 / 3) (2 / 3) (1 / 4) (1 / 3) 2.35 } + [Just rEarless] { 1 1 0 0 2.35 } - export : local xBar : match mode - [Just rNarrowSerifed] : df.middle + [HSwToV : 0.5 * strokeBar] - RBalance * rBalanceMultiplier - __ : df.leftSB + RBalance * rBalanceMultiplier + [HSwToV strokeBar] + export : local xBar : df.leftSB + RBalance * rBalanceMultiplier + [HSwToV strokeBar] local rSerifX : xBar - [HSwToV : 0.5 * strokeBar] local rSerifLeftJut : SideJut + RBalance * (0.3 + rSerifLeftExtender) local rSerifRightJut : rSerifLeftJut * 1.20 @@ -55,13 +55,11 @@ glyph-block Letter-Latin-Lower-R : begin export : local fine ShoulderFine export : local rHookX : df.rightSB + RBalance2 * rBalanceMultiplier - (OX - O) export : local xArchMiddle : match mode - [Just rStraight] : mix (xBar - fine) rHookX (0.54 + 2 * TanSlope * strokeBar / Width) - [Just rSerifed] : mix (xBar - fine) rHookX (0.59 + 2 * TanSlope * strokeBar / Width) - [Just rNarrow] : mix df.width rHookX : Math.max 1.01 (5 / 4 * [mix 1 dfR.div 2]) - [Just rNarrowSerifed] : Math.min ([mix df.width rHookX df.div] - TINY) : xBar + RHook * 1.25 * df.div - [Just rCornerHooked] : rHookX - [HSwToV : 0.5 * strokeBar] - [Just rCornerHookedSerifed] : rHookX - [HSwToV : 0.5 * strokeBar] - [Just rEarless] : mix (xBar - [HSwToV strokeBar]) rHookX 0.5 + [Just rStraight] : mix (xBar - fine) rHookX (0.54 + 2 * TanSlope * strokeBar / Width) + [Just rSerifed] : mix (xBar - fine) rHookX (0.59 + 2 * TanSlope * strokeBar / Width) + ([Just rNarrow] || [Just rNarrowSerifed]) : mix df.width rHookX : Math.max 1.01 (5 / 4 * [mix 1 dfR.div 2]) + ([Just rCornerHooked] || [Just rCornerHookedSerifed]) : rHookX - [HSwToV : 0.5 * strokeBar] + [Just rEarless] : mix (xBar - [HSwToV strokeBar]) rHookX 0.5 local mixpin : match mode ([Just rSerifed] || [Just rCornerHooked] || [Just rCornerHookedSerifed]) : begin 0.65 + 0.25 * strokeA / Width + 4 * TanSlope * strokeA / Width @@ -175,14 +173,14 @@ glyph-block Letter-Latin-Lower-R : begin define SmallRConfig : SuffixCfg.weave # Body object - '' { StandardShape dfN rStraight } - earlessCorner { EarlessCornerShape dfN rEarless } - earlessRounded { EarlessRoundedShape dfN rEarless } - hookless { CompactShape dfN rNarrow } - cornerHooked { CornerHookShape dfN rCornerHooked } - compact { CompactShape dfR rNarrow } - hooklessFlap { FlapHooklessShape dfN rNarrow } - compactFlap { FlapHooklessShape dfR rNarrow } + '' { StandardShape dfN rStraight rSerifed } + earlessCorner { EarlessCornerShape dfN rEarless rEarless } + earlessRounded { EarlessRoundedShape dfN rEarless rEarless } + hookless { CompactShape dfN rNarrow rNarrowSerifed } + cornerHooked { CornerHookShape dfN rCornerHooked rCornerHookedSerifed } + compact { CompactShape dfR rNarrow rNarrowSerifed } + hooklessFlap { FlapHooklessShape dfN rNarrow rNarrowSerifed } + compactFlap { FlapHooklessShape dfR rNarrow rNarrowSerifed } # Serifs object @@ -191,7 +189,8 @@ glyph-block Letter-Latin-Lower-R : begin baseSerifed { 0 1 } serifed { 1 1 } - foreach { suffix { {F df mode} {doTS doBS} } } [pairs-of SmallRConfig] : do + foreach { suffix { {F df modeSans modeSerifed} {doTS doBS} } } [pairs-of SmallRConfig] : do + local mode : if (doTS || doBS) modeSerifed modeSans create-glyph "r.\(suffix)" : glyph-proc set-width df.width include : df.markSet.e diff --git a/packages/font-otl/src/index.ptl b/packages/font-otl/src/index.ptl index bb5e89048..161a5508f 100644 --- a/packages/font-otl/src/index.ptl +++ b/packages/font-otl/src/index.ptl @@ -25,8 +25,9 @@ define [buildGSUB para glyphStore markGlyphs] : begin # NWID / WWID if para.enableNwidWwid : begin - buildGrFeature gsub glyphStore Gr.Nwid [if para.isQuasiProportional Gr.IsCompositeOrLigature null] - buildGrFeature gsub glyphStore Gr.Wwid [if para.isQuasiProportional Gr.IsCompositeOrLigature null] + local grIgnore : if para.isQuasiProportional Gr.IsCompositeOrLigature null + buildGrFeature gsub glyphStore Gr.Nwid grIgnore + buildGrFeature gsub glyphStore Gr.Wwid grIgnore # lnum / onum buildGrFeature gsub glyphStore Gr.Lnum @@ -74,7 +75,7 @@ define [buildGSUB para glyphStore markGlyphs] : begin # TXTR, "texture" feature if (para.buildTextureFeature && !para.isQuasiProportional) : begin - buildGsubTexture gsub glyphStore markGlyphs cvs + buildGsubTexture gsub glyphStore markGlyphs cvs gsub.finalize return gsub