diff --git a/changes/16.2.0.md b/changes/16.2.0.md new file mode 100644 index 000000000..748c1c429 --- /dev/null +++ b/changes/16.2.0.md @@ -0,0 +1 @@ +* Add ligation set for HTML/XML/React tags (`<>`, `` and ``) (#1413). diff --git a/font-src/glyphs/symbol/ligation.ptl b/font-src/glyphs/symbol/ligation.ptl index cd60aa161..891dd04fb 100644 --- a/font-src/glyphs/symbol/ligation.ptl +++ b/font-src/glyphs/symbol/ligation.ptl @@ -188,35 +188,42 @@ glyph-block Symbol-Ligation : begin include : Translate (arrowheadsKern * k) 0 if (k > 0) : Joining.set currentGlyph Joining.Classes.Right if (k < 0) : Joining.set currentGlyph Joining.Classes.Left + create-glyph 'greater.lig.shift0' : glyph-proc include [refer-glyph 'greater'] AS_BASE ALSO_METRICS + create-aliased-glyph 'greater.lig.shift0.head' create-aliased-glyph 'greater.lig.shift0.mid' create-aliased-glyph 'greater.lig.shift0.anti' create-aliased-glyph 'greater.lig.shiftN0' create-aliased-glyph 'greater.lig.shiftN0.mid' - create-forked-glyph 'greater.lig.shift0h' : ArrowShiftTranslate 0.5 - create-forked-glyph 'greater.lig.shift1' : ArrowShiftTranslate 1.0 - create-forked-glyph 'greater.lig.shift1h' : ArrowShiftTranslate 1.5 - create-forked-glyph 'greater.lig.shift2' : ArrowShiftTranslate 2.0 - create-forked-glyph 'greater.lig.shiftN0h' : ArrowShiftTranslate (-0.5) - create-forked-glyph 'greater.lig.shiftN1' : ArrowShiftTranslate (-1.0) - create-forked-glyph 'greater.lig.shiftN1h' : ArrowShiftTranslate (-1.5) - create-forked-glyph 'greater.lig.shiftN2' : ArrowShiftTranslate (-2.0) + create-forked-glyph 'greater.lig.shift0h' : ArrowShiftTranslate 0.5 + create-forked-glyph 'greater.lig.shift1' : ArrowShiftTranslate 1.0 + create-forked-glyph 'greater.lig.shift1.head' : ArrowShiftTranslate 1.0 + create-forked-glyph 'greater.lig.shift1h' : ArrowShiftTranslate 1.5 + create-forked-glyph 'greater.lig.shift2' : ArrowShiftTranslate 2.0 + create-forked-glyph 'greater.lig.shiftN0h' : ArrowShiftTranslate (-0.5) + create-forked-glyph 'greater.lig.shiftN1' : ArrowShiftTranslate (-1.0) + create-forked-glyph 'greater.lig.shiftN1.anti' : ArrowShiftTranslate (-1.0) + create-forked-glyph 'greater.lig.shiftN1h' : ArrowShiftTranslate (-1.5) + create-forked-glyph 'greater.lig.shiftN2' : ArrowShiftTranslate (-2.0) create-glyph 'less.lig.shift0' : glyph-proc include [refer-glyph 'less'] AS_BASE ALSO_METRICS + create-aliased-glyph 'less.lig.shift0.head' create-aliased-glyph 'less.lig.shift0.mid' create-aliased-glyph 'less.lig.shift0.anti' create-aliased-glyph 'less.lig.shiftN0' create-aliased-glyph 'less.lig.shiftN0.mid' - create-forked-glyph 'less.lig.shift0h' : ArrowShiftTranslate (-0.5) - create-forked-glyph 'less.lig.shift1' : ArrowShiftTranslate (-1.0) - create-forked-glyph 'less.lig.shift1h' : ArrowShiftTranslate (-1.5) - create-forked-glyph 'less.lig.shift2' : ArrowShiftTranslate (-2.0) - create-forked-glyph 'less.lig.shiftN0h' : ArrowShiftTranslate 0.5 - create-forked-glyph 'less.lig.shiftN1' : ArrowShiftTranslate 1.0 - create-forked-glyph 'less.lig.shiftN1h' : ArrowShiftTranslate 1.5 - create-forked-glyph 'less.lig.shiftN2' : ArrowShiftTranslate 2.0 + create-forked-glyph 'less.lig.shift0h' : ArrowShiftTranslate (-0.5) + create-forked-glyph 'less.lig.shift1' : ArrowShiftTranslate (-1.0) + create-forked-glyph 'less.lig.shift1.head' : ArrowShiftTranslate (-1.0) + create-forked-glyph 'less.lig.shift1h' : ArrowShiftTranslate (-1.5) + create-forked-glyph 'less.lig.shift2' : ArrowShiftTranslate (-2.0) + create-forked-glyph 'less.lig.shiftN0h' : ArrowShiftTranslate 0.5 + create-forked-glyph 'less.lig.shiftN1' : ArrowShiftTranslate 1.0 + create-forked-glyph 'less.lig.shiftN1.anti' : ArrowShiftTranslate 1.0 + create-forked-glyph 'less.lig.shiftN1h' : ArrowShiftTranslate 1.5 + create-forked-glyph 'less.lig.shiftN2' : ArrowShiftTranslate 2.0 define [ArrowHeadHole] : Rect (SymbolMid + dblArrowD - dblArrowSw) (SymbolMid - dblArrowD + dblArrowSw) (-Width) (2 * Width) @@ -412,40 +419,84 @@ glyph-block Symbol-Ligation : begin do "<| , |> and <>" glyph-block-import Symbol-Math-Relation-Inequality : LessShape GreaterShape + glyph-block-import Symbol-Punctuation-Slashes-And-Number-Sign : slashDefautLeft slashDefaultRight - local trigLeft : mix SB RightSB (1/6) - local trigRight : Width * 1.5 - OperatorStroke * 1.5 * HVContrast - local dHTriangle : LessSlope * (trigRight - trigLeft) + define koTriangle : 1 / 6 + define koTag 0 - define [TrigLeftShape shift] : LessShape (SymbolMid + dHTriangle) (SymbolMid - dHTriangle) (trigLeft + shift) (trigRight + shift) - define [TrigRightShape shift] : GreaterShape (SymbolMid + dHTriangle) (SymbolMid - dHTriangle) (Width - trigRight + shift) (Width - trigLeft + shift) + define kiShrunk 0 + define kiExtend 1 + define kiExtend2 2 + + local [trigLeft k] : mix SB RightSB k + local [trigRight k] : mix RightSB (Width * 1.5 - OperatorStroke * 1.5 * HVContrast) k + local [dHTriangle kOut kIn] : LessSlope * ([trigRight kIn] - [trigLeft kOut]) + + define [TrigLeftShape kOut kIn shift] : LessShape (SymbolMid + [dHTriangle kOut kIn]) (SymbolMid - [dHTriangle kOut kIn]) ([trigLeft kOut] + shift) ([trigRight kIn] + shift) + define [TrigRightShape kOut kIn shift] : GreaterShape (SymbolMid + [dHTriangle kOut kIn]) (SymbolMid - [dHTriangle kOut kIn]) (Width - [trigRight kIn] + shift) (Width - [trigLeft kOut] + shift) create-glyph 'less.lig.trig' : glyph-proc Joining.set currentGlyph Joining.Classes.Right - include : TrigLeftShape 0 + include : TrigLeftShape koTriangle kiExtend 0 create-glyph 'bar.lig.trig' : glyph-proc - include : VBar Middle (SymbolMid + dHTriangle + OperatorStroke) (SymbolMid - dHTriangle - OperatorStroke) OperatorStroke + include : VBar Middle (SymbolMid + [dHTriangle koTriangle kiExtend] + OperatorStroke) (SymbolMid - [dHTriangle koTriangle kiExtend] - OperatorStroke) OperatorStroke create-glyph 'greater.lig.trig' : glyph-proc Joining.set currentGlyph Joining.Classes.Left - include : TrigRightShape 0 + include : TrigRightShape koTriangle kiExtend 0 create-glyph 'less.lig.diamond' : glyph-proc Joining.set currentGlyph Joining.Classes.Right include : intersection - TrigLeftShape 0 + TrigLeftShape koTriangle kiExtend2 0 union Rect ParenTop ParenBot 0 Width - TrigRightShape Width + TrigRightShape koTriangle kiExtend2 Width create-glyph 'greater.lig.diamond' : glyph-proc Joining.set currentGlyph Joining.Classes.Left include : intersection - TrigRightShape 0 + TrigRightShape koTriangle kiExtend2 0 union Rect ParenTop ParenBot 0 Width - TrigLeftShape (-Width) + TrigLeftShape koTriangle kiExtend2 (-Width) + + create-glyph 'less.lig.diamond.tag' : glyph-proc + Joining.set currentGlyph Joining.Classes.Right + include : intersection + TrigLeftShape koTag kiExtend2 0 + union + Rect ParenTop ParenBot 0 Width + TrigRightShape koTag kiExtend2 Width + + create-glyph 'greater.lig.diamond.tag' : glyph-proc + Joining.set currentGlyph Joining.Classes.Left + include : intersection + TrigRightShape koTag kiExtend2 0 + union + Rect ParenTop ParenBot 0 Width + TrigLeftShape koTag kiExtend2 (-Width) + + create-glyph 'less.lig.tag-slash' : glyph-proc + Joining.set currentGlyph Joining.Classes.Right + include : intersection + MaskAbove SymbolMid + TrigLeftShape koTag kiShrunk 0 + include : intersection + MaskBelow SymbolMid + TrigLeftShape koTag kiExtend2 0 + MaskLeftLine (slashDefautLeft + Width) ParenBot (slashDefaultRight + Width) ParenTop + + create-glyph 'greater.lig.tag-slash' : glyph-proc + Joining.set currentGlyph Joining.Classes.Right + include : intersection + MaskBelow SymbolMid + TrigRightShape koTag kiShrunk 0 + include : intersection + MaskAbove SymbolMid + TrigRightShape koTag kiExtend2 0 + MaskRightLine (slashDefautLeft - Width) ParenBot (slashDefaultRight - Width) ParenTop do "Chaining Plus" glyph-block-import Symbol-Math-Arith : PlusShape diff --git a/font-src/glyphs/symbol/punctuation/slashes-and-number-sign.ptl b/font-src/glyphs/symbol/punctuation/slashes-and-number-sign.ptl index 601f198c5..cffd7bbf3 100644 --- a/font-src/glyphs/symbol/punctuation/slashes-and-number-sign.ptl +++ b/font-src/glyphs/symbol/punctuation/slashes-and-number-sign.ptl @@ -10,8 +10,12 @@ glyph-block Symbol-Punctuation-Slashes-And-Number-Sign : begin glyph-block-import CommonShapes glyph-block-import Common-Derivatives + glyph-block-export slashDefautLeft + glyph-block-export slashDefaultRight + define slashDefautLeft : SB + HalfStroke define slashDefaultRight : RightSB - HalfStroke + define [SlashShape l r _t _b _w] : glyph-proc local w : fallback _w Stroke local t : fallback _t ParenTop diff --git a/font-src/otl/gsub-ligation.ptl b/font-src/otl/gsub-ligation.ptl index eb2b5a091..c597fed7f 100644 --- a/font-src/otl/gsub-ligation.ptl +++ b/font-src/otl/gsub-ligation.ptl @@ -36,6 +36,8 @@ define [buildLigationsImpl sink para featureName mappedFeature rankedLookups] : define exclam {'exclam'} define greater {'greater'} define greaterAndEquiv {'greater' 'greater.lig.shift0' 'greater.lig.shift0.anti'} + define lessOrGreater : {}.concat less greater + define lessOrGreaterAndEquiv : {}.concat lessAndEquiv greaterAndEquiv define anyBar {'bar' 'slash' 'backslash'} define slash {'slash'} define backslash {'backslash'} @@ -409,11 +411,11 @@ define [buildLigationsImpl sink para featureName mappedFeature rankedLookups] : regexLookAround ~> advance regexLookAround ~> advance - define [CJoinHeadForce] : if dbl [lsx 'dblhead'] [lsx 'shift0'] + define [CJoinHeadForce] : if dbl [lsx 'dblhead'] [lsx 'shift0.head'] define [CJoinHeadMid] : if dbl [lsx 'dblhead.mid'] [lsx 'shift0.mid'] - define [CJoinHeadForceShift1] : if dbl [lsx 'dblhead.shift1'] [lsx 'shift1'] + define [CJoinHeadForceShift1] : if dbl [lsx 'dblhead.shift1'] [lsx 'shift1.head'] define [CAntiHeadForce] : if dbl [lsx 'hole'] [lsx 'shift0.anti'] - define [CAntiHeadForceShiftN1] : if dbl [lsx 'hole.shiftN1'] [lsx 'shiftN1'] + define [CAntiHeadForceShiftN1] : if dbl [lsx 'hole.shiftN1'] [lsx 'shiftN1.anti'] define [TJoinHeadForce] : if [hasLG 'arrow'] [CJoinHeadForce] advance define [TJoinHeadAmbig] : if [not ltgt] [TJoinHeadForce] advance @@ -679,9 +681,9 @@ define [buildLigationsImpl sink para featureName mappedFeature rankedLookups] : # Cancel alternates of < and > shapes if there are more after them local lAll {"less" "less.lig.shift0h" "less.lig.shiftN0h"} - local lNeut {"less" "less" "less"} + local lNeut {"less" "less" "less"} local gAll {"greater" "greater.lig.shift0h" "greater.lig.shiftN0h"} - local gNeut {"greater" "greater" "greater"} + local gNeut {"greater" "greater" "greater"} local lgAll : lAll.concat gAll local lgNeut : lNeut.concat gNeut CreateLigationLookup : list @@ -807,13 +809,6 @@ define [buildLigationsImpl sink para featureName mappedFeature rankedLookups] : [hasLG 'exeq'] : chain-rule exclam ~> {'neq.allow-dot.2l'} equal ~> {'equal.fc+cf'} - piecewise - [hasLG 'ltgt-diamond'] : chain-rule - lessAndEquiv ~> [just 'less.lig.diamond'] - greaterAndEquiv ~> [just 'greater.lig.diamond'] - [hasLG 'ltgt-ne'] : chain-rule - lessAndEquiv ~> [just 'neq.bar-only.2l'] - greaterAndEquiv ~> [just 'equal.fc+cf'] piecewise [hasLG 'eqeq'] : chain-rule equal ~> {'equal.fc'} @@ -841,27 +836,51 @@ define [buildLigationsImpl sink para featureName mappedFeature rankedLookups] : {'question'} ~> look-around regexLookAround ~> advance regexLookAround ~> advance + + # <> + piecewise + [hasLG 'ltgt-diamond'] : chain-rule + lessAndEquiv ~> [just 'less.lig.diamond'] + greaterAndEquiv ~> [just 'greater.lig.diamond'] + [hasLG 'ltgt-diamond-tag'] : chain-rule + lessAndEquiv ~> [just 'less.lig.diamond.tag'] + greaterAndEquiv ~> [just 'greater.lig.diamond.tag'] + [hasLG 'ltgt-ne'] : chain-rule + lessAndEquiv ~> [just 'neq.bar-only.2l'] + greaterAndEquiv ~> [just 'equal.fc+cf'] + + # <=, >= chain-rule - [acops] ~> look-around - {'less' 'greater'} ~> advance - equal ~> advance + [acops] ~> look-around + lessOrGreaterAndEquiv ~> advance + equal ~> advance chain-rule - {'less' 'greater'} ~> advance - equal ~> advance - [acops] ~> look-around + lessOrGreaterAndEquiv ~> advance + equal ~> advance + [acops] ~> look-around chain-rule - {'less'} ~> {'less.lig2'} - equal ~> {'eq.at-lteq.lig2'} + lessAndEquiv ~> [just 'less.lig2'] + equal ~> {'eq.at-lteq.lig2'} chain-rule - {'greater'} ~> {'greater.lig2'} - equal ~> {'eq.at-gteq.lig2'} + greaterAndEquiv ~> [just 'greater.lig2'] + equal ~> {'eq.at-gteq.lig2'} + + # and + piecewise + [hasLG 'ltgt-slash-tag'] : chain-rule + lessAndEquiv ~> [just 'less.lig.tag-slash'] + slash ~> look-around + piecewise + [hasLG 'ltgt-slash-tag'] : chain-rule + slash ~> look-around + greaterAndEquiv ~> [just 'greater.lig.tag-slash'] # :> do "colon-less-greater" : if [hasLG 'colon-greater'] : begin CreateLigationLookup : list chain-rule - {'colon/mid'} ~> look-around - {'greater'} ~> {'greaterArrow'} + {'colon/mid'} ~> look-around + greaterAndEquiv ~> [just 'greaterArrow'] # [| |] {| |} do "brack-bar" : if [hasLG 'brack-bar'] : begin diff --git a/params/ligation-set.toml b/params/ligation-set.toml index 538181449..5ad691730 100644 --- a/params/ligation-set.toml +++ b/params/ligation-set.toml @@ -88,6 +88,18 @@ ligGroup = "ltgt-diamond" samples = ["<>"] desc = 'Enable ligation for `<>` as diamond' +[simple.ltgt-diamond-tag] +ligGroup = "ltgt-diamond-tag" +samples = ["<>"] +sampleRank = 3 +desc = 'Enable ligation for `<>` as diamond-shaped empty HTML/XML tag' + +[simple.ltgt-slash-tag] +ligGroup = "ltgt-slash-tag" +samples = ["", ""] +sampleRank = 2 +desc = 'Enable ligation for `` and ``' + [simple.brst] ligGroup = "brst" samples = ["(*", "*)", "(* comm *)"] @@ -198,30 +210,30 @@ desc = 'Make contiguous hyphen-minuses (like `--`) connected as a straight semi- # This feature is on by default by many software [composite.default-calt] tag = 'calt' -buildup = ['center-ops', 'arrow', 'html-comment', 'trig', 'llgg', 'llggeq', 'eqeq', 'exeq', 'ineq', 'plusplus', 'kern-dotty', 'kern-bars'] +buildup = ['center-ops', 'arrow', 'html-comment', 'ltgt-diamond-tag', 'ltgt-slash-tag', 'trig', 'llgg', 'llggeq', 'eqeq', 'exeq', 'ineq', 'plusplus', 'kern-dotty', 'kern-bars'] brief = 'Default' desc = 'Default setting in text editors' 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', 'kern-bars', 'dot-as-operator', 'logic', 'brst', 'brace-bar', 'brack-bar', 'connected-underscore', 'connected-number-sign', 'connected-tilde-as-wave', 'connected-hyphen-as-semi-dashed-line'] +buildup = ['center-ops', 'arrow', 'html-comment', 'ltgt-diamond-tag', 'ltgt-slash-tag', 'trig', 'arrow2', 'llgg', 'eqeq', 'exeq', 'ineq', 'plusplus', 'kern-dotty', 'kern-bars', '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' [composite.clike] tag = 'CLIK' -buildup = ['center-ops', 'arrow', 'html-comment', 'trig', 'llgg', 'llggeq', 'eqeqeq', 'eqeq', 'exeqeq', 'exeq', 'ineq', 'plusplus', 'kern-dotty', 'kern-bars'] +buildup = ['center-ops', 'arrow', 'html-comment', 'ltgt-diamond-tag', 'ltgt-slash-tag', 'trig', 'llgg', 'llggeq', 'eqeqeq', 'eqeq', 'exeqeq', 'exeq', 'ineq', 'plusplus', 'kern-dotty', 'kern-bars'] desc = 'C-Like' [composite.javascript] tag = 'JSPT' -buildup = ['center-ops', 'arrow', 'html-comment', 'trig', 'llgg', 'llggeq', 'eqeqeq', 'eqeq', 'exeqeq', 'exeq', 'ineq', 'plusplus', 'kern-dotty', 'kern-bars'] +buildup = ['center-ops', 'arrow', 'html-comment', 'ltgt-diamond-tag', 'ltgt-slash-tag', 'trig', 'llgg', 'llggeq', 'eqeqeq', 'eqeq', 'exeqeq', 'exeq', 'ineq', 'plusplus', 'kern-dotty', 'kern-bars'] desc = 'JavaScript' [composite.php] tag = 'PHPX' -buildup = ['center-ops', 'arrow', 'html-comment', 'trig', 'llgg', 'llggeq', 'eqeqeq', 'eqeq', 'exeqeq', 'exeq', 'ineq', 'plusplus', 'dot-as-operator', 'kern-dotty', 'kern-bars'] +buildup = ['center-ops', 'arrow', 'html-comment', 'ltgt-diamond-tag', 'ltgt-slash-tag', 'trig', 'llgg', 'llggeq', 'eqeqeq', 'eqeq', 'exeqeq', 'exeq', 'ineq', 'plusplus', 'dot-as-operator', 'kern-dotty', 'kern-bars'] desc = 'PHP' [composite.julia] @@ -286,12 +298,12 @@ desc = 'Coq' [composite.matlab] tag = 'MTLB' -buildup = ['center-ops', 'arrow', 'html-comment', 'trig', 'llgg', 'eqeq', 'tildeeq', 'ineq', 'plusplus', 'kern-dotty', 'kern-bars'] +buildup = ['center-ops', 'arrow', 'trig', 'llgg', 'eqeq', 'tildeeq', 'ineq', 'plusplus', 'kern-dotty', 'kern-bars'] desc = 'Matlab' [composite.verilog] tag = 'VRLG' -buildup = ['center-ops', 'arrow', 'html-comment', 'trig', 'llgg', 'llggeq', 'eqeqeq', 'eqeq', 'exeqeq', 'exeq', 'plusplus', 'brst', 'kern-dotty', 'kern-bars'] +buildup = ['center-ops', 'arrow', 'trig', 'llgg', 'llggeq', 'eqeqeq', 'eqeq', 'exeqeq', 'exeq', 'plusplus', 'brst', 'kern-dotty', 'kern-bars'] desc = 'Verilog' [composite.wolfram] diff --git a/utility/export-data/ligation-data.mjs b/utility/export-data/ligation-data.mjs index 56de0b8c6..4c6cc365d 100644 --- a/utility/export-data/ligation-data.mjs +++ b/utility/export-data/ligation-data.mjs @@ -40,9 +40,9 @@ const ligationSamplesNarrow = [ ["<->", "<-->", "<--->", "<---->", "<=>", "<==>", "<===>", "<====>", "::", ":::", "__"], [ "<~~", - "<~", - "<~>", - "~>", + "", + "/>", "~~>", "==", "!=",