Add ligation for ==, !=, <=, >=, ===, !==, ====, !=== and /= (in Haskell-ish languages). Fixes #249

This commit is contained in:
belleve 2018-01-30 13:04:58 +08:00
parent 05a49f1d3f
commit 3d67e4b904
2 changed files with 99 additions and 38 deletions

View file

@ -206,19 +206,38 @@ export : define [apply] : begin
include : DotAt [mix SB RIGHTSB (5/6)] (parenMid - equalHalfSpace * 2.5) DOTRADIUS
save 'twodotapproxeq' 0x2252
define [equalHole x] : VBar x (parenMid - equalHalfSpace) (parenMid + equalHalfSpace) [adviceBlackness 5]
# Ligation glyphs
sketch # equal.fc
include markset.plus
include : HBar SB WIDTH (parenMid + equalHalfSpace) OPERATORSTROKE
include : HBar SB WIDTH (parenMid - equalHalfSpace) OPERATORSTROKE
include : difference
union
HBar SB (WIDTH - O) (parenMid + equalHalfSpace) OPERATORSTROKE
HBar SB (WIDTH - O) (parenMid - equalHalfSpace) OPERATORSTROKE
equalHole WIDTH
save 'equal.fc'
sketch # equal.cf
include markset.plus
include : HBar 0 RIGHTSB (parenMid + equalHalfSpace) OPERATORSTROKE
include : HBar 0 RIGHTSB (parenMid - equalHalfSpace) OPERATORSTROKE
include : difference
union
HBar O RIGHTSB (parenMid + equalHalfSpace) OPERATORSTROKE
HBar O RIGHTSB (parenMid - equalHalfSpace) OPERATORSTROKE
equalHole 0
save 'equal.cf'
sketch # equal.cc
include markset.plus
include : difference
union
HBar O (WIDTH - O) (parenMid + equalHalfSpace) OPERATORSTROKE
HBar O (WIDTH - O) (parenMid - equalHalfSpace) OPERATORSTROKE
union
equalHole 0
equalHole WIDTH
save 'equal.cc'
sketch # multiply
include markset.plus
local radius : (RIGHTSB - SB) / 2
@ -497,6 +516,27 @@ export : define [apply] : begin
branch
include : GreaterShapeB (parenMid + dH - lessEqDist) (parenMid - dH - lessEqDist) SB RIGHTSB OPERATORSTROKE
save 'greatereqslant' 0x2A7E
# Ligation
sketch # lesseq
local l : 0.3 * WIDTH
local r : 2 * WIDTH - l
include markset.plus
branch
include : LessShape (parenMid + dH + lessEqDist) (parenMid - dH + lessEqDist) l r
save 'less.lig2'
branch
include : HBar (l - WIDTH) (r - WIDTH) (parenMid - dH - lessEqDist) OPERATORSTROKE
save 'eq.at-ltgteq.lig2'
sketch # greatereq
local l : 0.3 * WIDTH
local r : 2 * WIDTH - l
include markset.plus
branch
include : GreaterShape (parenMid + dH + lessEqDist) (parenMid - dH + lessEqDist) l r
save 'greater.lig2'
do
define lesslessSW : adviceBlackness 4
@ -562,28 +602,7 @@ export : define [apply] : begin
include : HBar SB RIGHTSB (parenMid - equalHalfSpace * 1.5) OPERATORSTROKE
save 'ident' 0x2261
sketch # ident.fc
include markset.plus
include : HBar SB WIDTH (parenMid + equalHalfSpace * 1.5) OPERATORSTROKE
include : HBar SB WIDTH parenMid OPERATORSTROKE
include : HBar SB WIDTH (parenMid - equalHalfSpace * 1.5) OPERATORSTROKE
save 'ident.fc'
sketch # ident.cf
include markset.plus
include : HBar 0 RIGHTSB (parenMid + equalHalfSpace * 1.5) OPERATORSTROKE
include : HBar 0 RIGHTSB parenMid OPERATORSTROKE
include : HBar 0 RIGHTSB (parenMid - equalHalfSpace * 1.5) OPERATORSTROKE
save 'ident.cf'
sketch # ident.cc
include markset.plus
include : HBar 0 WIDTH (parenMid + equalHalfSpace * 1.5) OPERATORSTROKE
include : HBar 0 WIDTH parenMid OPERATORSTROKE
include : HBar 0 WIDTH (parenMid - equalHalfSpace * 1.5) OPERATORSTROKE
save 'ident.cc'
sketch # ident
sketch # iiiident
include markset.plus
include : HBar SB RIGHTSB (parenMid + equalHalfSpace * 2.25) OPERATORSTROKE
include : HBar SB RIGHTSB (parenMid + equalHalfSpace * 0.75) OPERATORSTROKE
@ -698,13 +717,14 @@ export : define [apply] : begin
### 'Negative Operators'
define [notGlyph unicode oldid top bot prop shift] : create-glyph ('not' + oldid) : glyph-construction
assign-unicode unicode
include glyphs.(oldid)
include : dispiro
widths.center [adviceBlackness 4]
flat ([fallback shift 0] + [mix SB RIGHTSB [fallback prop 0.25]]) [fallback bot operBot]
curl ([fallback shift 0] + [mix RIGHTSB SB [fallback prop 0.25]]) [fallback top operTop]
define [notGlyph unicode oldid top bot prop shift newid]
create-glyph [fallback newid ('not' + oldid)] : glyph-construction
if unicode : assign-unicode unicode
include glyphs.(oldid)
include : dispiro
widths.center [adviceBlackness 4]
flat ([fallback shift 0] + [mix SB RIGHTSB [fallback prop 0.25]]) [fallback bot operBot]
curl ([fallback shift 0] + [mix RIGHTSB SB [fallback prop 0.25]]) [fallback top operTop]
define [notGlyph.right unicode oldid top bot prop shift] : notGlyph unicode oldid top bot prop (-OPERATORSTROKE * 0.5)
define [notGlyph.left unicode oldid top bot prop shift] : notGlyph unicode oldid top bot prop (OPERATORSTROKE * 0.5)
@ -732,6 +752,9 @@ export : define [apply] : begin
notGlyph 0x2278 'lessgreater'
notGlyph 0x2279 'greaterless'
notGlyph.right 0x2204 'exists' (CAP - DESCENDER / 2) (DESCENDER / 2) 0.4
notGlyph null 'equal.fc' nothing nothing nothing (WIDTH * 0.5) 'equal.fc.neg'
notGlyph null 'equal.fc' nothing nothing nothing (WIDTH * 1.0) 'equal.fc.neg3'
notGlyph null 'equal.fc' nothing nothing nothing (WIDTH * 1.5) 'equal.fc.neg4'
### 'Large Operators'
sketch # sum

View file

@ -8,11 +8,11 @@ export : define [progLigNameMap] : object
.XFS_ {'brst', 'plusplus', 'logic', 'fsharp'}
.XFS0 {'brst', 'plusplus', 'logic', 'fsharp'}
.XFST {'brst', 'plusplus', 'logic', 'fstar'}
.XHS_ {'arrow2', 'plusplus', 'dotoper', 'logic', 'haskell'}
.XHS0 {'arrow2', 'plusplus', 'dotoper', 'logic', 'haskell'}
.XIDR {'arrow2', 'plusplus', 'dotoper', 'logic', 'idris'}
.XELM {'arrow2', 'plusplus', 'dotoper', 'logic', 'elm'}
.PURS {'arrow2', 'plusplus', 'dotoper', 'logic', 'purescript'}
.XHS_ {'arrow2', 'plusplus', 'dotoper', 'logic', 'haskellish', 'haskell'}
.XHS0 {'arrow2', 'plusplus', 'dotoper', 'logic', 'haskellish', 'haskell'}
.XIDR {'arrow2', 'plusplus', 'dotoper', 'logic', 'haskellish', 'idris'}
.XELM {'arrow2', 'plusplus', 'dotoper', 'logic', 'haskellish', 'elm'}
.PURS {'arrow2', 'plusplus', 'dotoper', 'logic', 'haskellish', 'purescript'}
.XPTL {'arrow2', 'plusplus', 'patel'}
.SWFT {'arrow2', 'plusplus', 'swift'}
.XV__ {'arrow2', 'plusplus', 'dotoper', 'logic', 'brst', 'coq'}
@ -417,3 +417,41 @@ export : define [buildLigations chain-rule lookupOrder commonList features looku
chain-rule
{'backslash'} ~> [only 'logic' {'backslash.left'}]
{'slash'} ~> [only 'logic' {'slash.right'}]
# == and ===
do "equals" : includeLookup
.type 'gsub_chaining'
.subtables : list
chain-rule
{'equal'} ~> {'equal.fc'}
{'equal'} ~> {'equal.cc'}
{'equal'} ~> {'equal.cc'}
{'equal'} ~> {'equal.cf'}
chain-rule
{'exclam'} ~> {'equal.fc.neg4'}
{'equal'} ~> {'equal.cc'}
{'equal'} ~> {'equal.cc'}
{'equal'} ~> {'equal.cf'}
chain-rule
{'equal'} ~> {'equal.fc'}
{'equal'} ~> {'equal.cc'}
{'equal'} ~> {'equal.cf'}
chain-rule
{'exclam'} ~> {'equal.fc.neg3'}
{'equal'} ~> {'equal.cc'}
{'equal'} ~> {'equal.cf'}
chain-rule
{'equal'} ~> {'equal.fc'}
{'equal'} ~> {'equal.cf'}
chain-rule
{'exclam'} ~> {'equal.fc.neg'}
{'equal'} ~> {'equal.cf'}
chain-rule
{'slash'} ~> [only 'haskellish' {'equal.fc.neg'}]
{'equal'} ~> [only 'haskellish' {'equal.cf'}]
chain-rule
{'less'} ~> {'less.lig2'}
{'equal'} ~> {'eq.at-ltgteq.lig2'}
chain-rule
{'greater'} ~> {'greater.lig2'}
{'equal'} ~> {'eq.at-ltgteq.lig2'}