From ba6e5c5b5861a273d607e5ad44fb87b98fe77fac Mon Sep 17 00:00:00 2001 From: be5invis Date: Mon, 22 Feb 2021 23:31:01 -0800 Subject: [PATCH] Add ligation for chained hyphens and tildes (#893). --- changes/5.0.4.md | 1 + font-src/glyphs/symbol/ligation.ptl | 29 ++++-- font-src/otl/gsub-ligation.ptl | 134 +++++++++++++++++++--------- params/ligation-set.toml | 14 ++- 4 files changed, 126 insertions(+), 52 deletions(-) create mode 100644 changes/5.0.4.md diff --git a/changes/5.0.4.md b/changes/5.0.4.md new file mode 100644 index 000000000..3bcad136c --- /dev/null +++ b/changes/5.0.4.md @@ -0,0 +1 @@ + * Add ligation for chained hyphens and tildes (#893). \ No newline at end of file diff --git a/font-src/glyphs/symbol/ligation.ptl b/font-src/glyphs/symbol/ligation.ptl index 345f7b408..ff1c80831 100644 --- a/font-src/glyphs/symbol/ligation.ptl +++ b/font-src/glyphs/symbol/ligation.ptl @@ -53,9 +53,20 @@ glyph-block Symbol-Ligation : begin local arrowExtend [clamp 0 Width (RightSB - OperatorStroke / 2 * arrowheadSlope)] local arrowJ : clamp 0 Width (SB + OperatorStroke / 2 * arrowheadSlope) - foreach [{subclass left right} : items-of [ArrowBarConfig arrowExtend arrowheadsKern arrowJ false]] : create-glyph ('hyphen.lig.' + subclass) : glyph-proc - include : HBar left right SymbolMid OperatorStroke - set currentGlyph.autoRefPriority (-3) + + define [HyphenNotch x] : union + VBar x (SymbolMid + OperatorStroke / 3) (SymbolMid + OperatorStroke) OperatorStroke + VBar x (SymbolMid - OperatorStroke / 3) (SymbolMid - OperatorStroke) OperatorStroke + foreach [{subclass left right} : items-of [ArrowBarConfig arrowExtend arrowheadsKern arrowJ false]] : begin + + create-glyph "hyphen.lig.\(subclass)" : glyph-proc + include : HBar left right SymbolMid OperatorStroke + set currentGlyph.autoRefPriority (-3) + create-glyph "hyphen.lig.\(subclass).notched" : glyph-proc + include : difference + HBar left right SymbolMid OperatorStroke + if (left < SB) [HyphenNotch 0] [glyph-proc] + if (right > RightSB) [HyphenNotch Width] [glyph-proc] # => local dblArrowD : (ParenTop - ParenBot) * DesignParameters.equal_wideness + OperatorStroke * 0.75 @@ -96,7 +107,7 @@ glyph-block Symbol-Ligation : begin j { J (Width + arrowJ) true } j1 { J (Width + arrowJ + arrowheadsKern) true } - foreach [lS : items-of : Object.keys lk] : foreach [rS : items-of : Object.keys rk] : create-glyph"wave.\(lS)\(rS)" : glyph-proc + foreach [lS : items-of : Object.keys lk] : foreach [rS : items-of : Object.keys rk] : create-glyph"wave.lig.\(lS)\(rS)" : glyph-proc local {tL jL djL} lk.(lS) local {tR jR djR} rk.(rS) include : WaveShape @@ -322,12 +333,12 @@ glyph-block Symbol-Ligation : begin do "Chaining Plus" glyph-block-import Symbol-Math-Arith : PlusShape - create-glyph 'plus.lig.lc' : PlusShape SB (Width - O) - create-glyph 'plus.lig.lc.s' : PlusShape SB (Width - O) SB + create-glyph 'plus.lig.fc' : PlusShape SB (Width - O) + create-glyph 'plus.lig.fc.s' : PlusShape SB (Width - O) SB create-glyph 'plus.lig.cc' : PlusShape O (Width - O) - create-glyph 'plus.lig.cr' : PlusShape O RightSB - create-glyph 'plus.lig.cr.s' : PlusShape O RightSB (-SB) - create-glyph 'plus.lig.jr' : PlusShape (-SB + O) RightSB + create-glyph 'plus.lig.cf' : PlusShape O RightSB + create-glyph 'plus.lig.cf.s' : PlusShape O RightSB (-SB) + create-glyph 'plus.lig.zf' : PlusShape (-SB + O) RightSB do 'Less / Greater as arrow' create-glyph 'greaterArrow' : composite-proc diff --git a/font-src/otl/gsub-ligation.ptl b/font-src/otl/gsub-ligation.ptl index 45fd6bc3b..3f5c92b62 100644 --- a/font-src/otl/gsub-ligation.ptl +++ b/font-src/otl/gsub-ligation.ptl @@ -25,7 +25,7 @@ define [buildLigationsImpl sink para featureName mappedFeature rankedLookups] : define [stickClass style] : [lsx style] {'hyphen' 'equal'} define [stickTf style] : {'hyphen' 'equal'} ~> [lsx style] define anyWave {'asciiTilde' 'asciiTilde.low' 'asciiTilde.high'} - define [waveClass cl] : [just ('wave.' + cl)] anyWave + define [waveClass cl] : [just ('wave.lig.' + cl)] anyWave define [waveTf cl] : anyWave ~> [waveClass cl] define less {'less'} @@ -240,45 +240,6 @@ define [buildLigationsImpl sink para featureName mappedFeature rankedLookups] : dRight ~> dRightHalf dLeft ~> dLeftHalf - do "Plus chains" : if [hasLG 'plusplus'] : begin - CreateLigationLookup : list - # +++++++++ - chain-rule - {'plus.lig.cr' 'plus.lig.jr'} ~> look-around - {'plus'} ~> [lsx 'jr'] - chain-rule - {'plus'} ~> [lsx 'lc'] - {'plus'} ~> [lsx 'cc'] - {'plus'} ~> [lsx 'cc'] - {'plus'} ~> [lsx 'cr'] - chain-rule - {'plus'} ~> [lsx 'lc'] - {'plus'} ~> [lsx 'cc'] - {'plus'} ~> [lsx 'cr'] - chain-rule - {'plus'} ~> [lsx 'lc'] - {'plus'} ~> [lsx 'cr'] - CreateLigationLookup : list - chain-rule # +++ - {'plus.lig.lc'} ~> {'plus.lig.lc.s'} - {'plus.lig.cc'} ~> look-around - {'plus.lig.cr'} ~> {'plus.lig.cr.s'} - chain-rule # ++ - {'plus.lig.lc'} ~> {'plus.lig.lc.s'} - {'plus.lig.cr'} ~> {'plus.lig.cr.s'} - - do "Underscore chains" : if [hasLG 'connected-underscore'] : begin - CreateLigationLookup : list - chain-rule - {'underscore' 'underscore.jr'} ~> look-around - {'underscore'} ~> {'underscore.jr'} - - do "Number sign chains" : if [hasLG 'connected-number-sign'] : begin - CreateLigationLookup : list - chain-rule - {'numberSign' 'numberSign.jr'} ~> look-around - {'numberSign'} ~> {'numberSign.jr'} - do "triangles" : if [hasLG 'trig'] : begin CreateLigationLookup : list chain-rule # <| @@ -387,7 +348,7 @@ define [buildLigationsImpl sink para featureName mappedFeature rankedLookups] : define [CBarSingular k] : begin local hyphenSet : new Set hyphen local fHyphen : lsx k - local fWave : just "wave.\(k)" + local fWave : just "wave.lig.\(k)" return : lambda [t] : begin local hyphenResults : fHyphen t local waveResults : fWave t @@ -403,7 +364,7 @@ define [buildLigationsImpl sink para featureName mappedFeature rankedLookups] : # rod FBarCls list equal lsx list hyphen lsx - list anyWave [lambda [k] [just "wave.\(k)"]] + list anyWave [lambda [k] [just "wave.lig.\(k)"]] foreach [{barCls dbl ltgt CBar} : items-of ArrowFormationConfig] : do define heads {} @@ -918,3 +879,92 @@ define [buildLigationsImpl sink para featureName mappedFeature rankedLookups] : chain-rule {'bar'} ~> {'ligBarInsideBracketRight'} {'braceRight'} ~> {'ligExtBraceRight'} + + + do "Plus chains" : if [hasLG 'plusplus'] : begin + CreateLigationLookup : list + # +++++++++ + chain-rule + {'plus.lig.cf' 'plus.lig.zf'} ~> look-around + {'plus'} ~> [lsx 'zf'] + chain-rule + {'plus'} ~> [lsx 'fc'] + {'plus'} ~> [lsx 'cc'] + {'plus'} ~> [lsx 'cc'] + {'plus'} ~> [lsx 'cf'] + chain-rule + {'plus'} ~> [lsx 'fc'] + {'plus'} ~> [lsx 'cc'] + {'plus'} ~> [lsx 'cf'] + chain-rule + {'plus'} ~> [lsx 'fc'] + {'plus'} ~> [lsx 'cf'] + CreateLigationLookup : list + chain-rule # +++ + {'plus.lig.fc'} ~> {'plus.lig.fc.s'} + {'plus.lig.cc'} ~> look-around + {'plus.lig.cf'} ~> {'plus.lig.cf.s'} + chain-rule # ++ + {'plus.lig.fc'} ~> {'plus.lig.fc.s'} + {'plus.lig.cf'} ~> {'plus.lig.cf.s'} + + do "Underscore chains" : if [hasLG 'connected-underscore'] : begin + CreateLigationLookup : list + chain-rule + {'underscore' 'underscore.jr'} ~> look-around + {'underscore'} ~> {'underscore.jr'} + + do "Tilde chains" : if [hasLG 'connected-tilde-as-wave'] : begin + CreateLigationLookup : list + chain-rule + {'wave.lig.cf' 'wave.lig.zf'} ~> look-around + {'asciiTilde'} ~> {'wave.lig.zf'} + chain-rule + {'asciiTilde'} ~> {"wave.lig.fc"} + {'asciiTilde'} ~> {"wave.lig.cf"} + + do "Hyphen chains" : if [hasLG 'connected-hyphen-as-solid-line'] : begin + CreateLigationLookup : list + chain-rule + {'hyphen.lig.zf'} ~> look-around + {'hyphen'} ~> {'hyphen.lig.zf'} + chain-rule + {'hyphen'} ~> {"hyphen.lig.fc"} + {'hyphen'} ~> {"hyphen.lig.zf"} + CreateLigationLookup : list + chain-rule + {'hyphen.lig.jf'} ~> {'hyphen.lig.jc'} + {'hyphen'} ~> {'hyphen.lig.cc'} + {'hyphen.lig.fj'} ~> {'hyphen.lig.cj'} + chain-rule + {'hyphen.lig.jf'} ~> {'hyphen.lig.jc'} + {'hyphen.lig.fc'} ~> {'hyphen.lig.cc'} + chain-rule + {'hyphen.lig.zf'} ~> {'hyphen.lig.zc'} + {'hyphen.lig.fj'} ~> {'hyphen.lig.cj'} + + do "Hyphen chains" : if [hasLG 'connected-hyphen-as-semi-dashed-line'] : begin + CreateLigationLookup : list + chain-rule + {'hyphen.lig.zf.notched'} ~> look-around + {'hyphen'} ~> {'hyphen.lig.zf.notched'} + chain-rule + {'hyphen'} ~> {"hyphen.lig.fc.notched"} + {'hyphen'} ~> {"hyphen.lig.zf.notched"} + CreateLigationLookup : list + chain-rule + {'hyphen.lig.jf'} ~> {'hyphen.lig.jc.notched'} + {'hyphen'} ~> {'hyphen.lig.cc.notched'} + {'hyphen.lig.fj'} ~> {'hyphen.lig.cj.notched'} + chain-rule + {'hyphen.lig.jf'} ~> {'hyphen.lig.jc.notched'} + {'hyphen.lig.fc.notched'} ~> {'hyphen.lig.cc.notched'} + chain-rule + {'hyphen.lig.zf.notched'} ~> {'hyphen.lig.zc.notched'} + {'hyphen.lig.fj'} ~> {'hyphen.lig.cj.notched'} + + do "Number sign chains" : if [hasLG 'connected-number-sign'] : begin + CreateLigationLookup : list + chain-rule + {'numberSign' 'numberSign.jr'} ~> look-around + {'numberSign'} ~> {'numberSign.jr'} diff --git a/params/ligation-set.toml b/params/ligation-set.toml index bd51b7b66..7feaeb80b 100644 --- a/params/ligation-set.toml +++ b/params/ligation-set.toml @@ -138,6 +138,18 @@ desc = 'Make contiguous underscores (like `__`) connected' ligGroup = 'connected-number-sign' desc = 'Make contiguous number signs (like `##`) connected' +[simple.connected-tilde-as-wave] +ligGroup = 'connected-tilde-as-wave' +desc = 'Make contiguous ASCII tildes (like `~~`) connected as a wave line' + +[simple.connected-hyphen-as-solid-line] +ligGroup = 'connected-hyphen-as-solid-line' +desc = 'Make contiguous hyphen-minuses (like `--`) connected as a straight solid line' + +[simple.connected-hyphen-as-semi-dashed-line] +ligGroup = 'connected-hyphen-as-semi-dashed-line' +desc = 'Make contiguous hyphen-minuses (like `--`) connected as a straight semi-dashed line, identifying each hyphen component' + ################################################################################################### # This feature is on by default by many software @@ -150,7 +162,7 @@ readmeDesc = 'Inherit default ligation set' [composite.dlig] tag = 'dlig' -buildup = ['center-ops', 'arrow', 'html-comment', 'trig', 'arrow2', 'llgg', 'eqeq', 'exeq', 'ineq', 'ltgt-diamond', 'plusplus', 'kern-dotty', 'dot-as-operator', 'logic', 'brst', 'brace-bar', 'brack-bar', 'connected-underscore', 'connected-number-sign'] +buildup = ['center-ops', 'arrow', 'html-comment', 'trig', 'arrow2', 'llgg', 'eqeq', 'exeq', 'ineq', 'ltgt-diamond', 'plusplus', 'kern-dotty', 'dot-as-operator', 'logic', 'brst', 'brace-bar', 'brack-bar', 'connected-underscore', 'connected-number-sign', 'connected-tilde-as-wave', 'connected-hyphen-as-semi-dashed-line'] brief = 'Discretionary' desc = 'Discretionary ligatures'