Add ligation set for chaining number signs (#894).

This commit is contained in:
be5invis 2021-02-15 02:26:56 -08:00
parent 412e335479
commit 0481e59da6
4 changed files with 73 additions and 43 deletions

1
changes/5.1.0.md Normal file
View file

@ -0,0 +1 @@
* Add ligation set for chaining number signs (#894).

View file

@ -1061,52 +1061,74 @@ glyph-block Symbol-Punctuation-Slashes-And-Number-Sign : begin
define nsBot : mix SymbolMid ParenBot 0.85 define nsBot : mix SymbolMid ParenBot 0.85
define fine : AdviceStroke 3.5 define fine : AdviceStroke 3.5
define pFineOpen (1 / 8) define [HspT l r] : ((r - l) - (fine * 2 * HVContrast)) * 0.3
define l : SB - fine / 2
define r : RightSB + fine / 2
define hsp : ((r - l) - (fine * 2 * HVContrast)) * 0.3
define [UprightHBars] : union define [UprightHBars lx l r p] : union
HBar l r [mix nsTop nsBot 0.3] HBar lx r [mix nsTop nsBot 0.3]
HBar l r [mix nsTop nsBot 0.7] HBar lx r [mix nsTop nsBot 0.7]
define [UprightVBars p] : union
VBarLeft (l + hsp + p * fine) nsBot nsTop fine
VBarRight (r - hsp - p * fine) nsBot nsTop fine
define [UprightHBarsOpen lx l r p] : begin
define hsp : HspT l r
return : difference
UprightHBars lx l r p
Rect nsTop nsBot
l + hsp + fine * (0.5 + p)
r - hsp - fine * (0.5 + p)
create-glyph 'numberSign.upright' : union define [UprightVBars lx l r p] : begin
UprightHBars define hsp : HspT l r
UprightVBars 0 return : union
VBarLeft (l + hsp + p * fine) nsBot nsTop fine
VBarRight (r - hsp - p * fine) nsBot nsTop fine
create-glyph 'numberSign.uprightOpen' : union define [SlantedDim l r] : begin
UprightVBars pFineOpen define hsp : HspT l r
difference define x : hsp + fine / 2 * HVContrast
UprightHBars define w : (r - l) * 0.15
Rect nsTop nsBot (l + hsp + fine * (0.5 + pFineOpen)) (r - hsp - fine * (0.5 + pFineOpen)) define shift : w / 3
return : object hsp x w shift
define x : hsp + fine / 2 * HVContrast define [SlantedHBars lx l r p] : begin
define w : (r - l) * 0.15 define [object shift] : SlantedDim l r
define shift : w / 3 return : union
define [SlantedHBars] : union HBar (lx + shift) (r + shift) [mix nsTop nsBot 0.3]
HBar (l + shift) (r + shift) [mix nsTop nsBot 0.3] HBar (lx - shift) (r - shift) [mix nsTop nsBot 0.7]
HBar (l - shift) (r - shift) [mix nsTop nsBot 0.7] define [SlantedHBarsOpen lx l r p] : begin
define [SlantedVBars p] : union define [object x w] : SlantedDim l r
SlashShape (l + x - w + p * fine) (l + x + w + p * fine) nsTop nsBot fine return : difference
SlashShape (r - x - w - p * fine) (r - x + w - p * fine) nsTop nsBot fine SlantedHBars lx l r p
create-glyph 'numberSign.slanted' : union [SlantedHBars] [SlantedVBars 0]
create-glyph 'numberSign.slantedOpen' : union
SlantedVBars pFineOpen
difference
SlantedHBars
spiro-outline spiro-outline
corner (l + x + w + pFineOpen * fine) nsTop corner (l + x + w + p * fine) nsTop
corner (r - x + w - pFineOpen * fine) nsTop corner (r - x + w - p * fine) nsTop
corner (r - x - w - pFineOpen * fine) nsBot corner (r - x - w - p * fine) nsBot
corner (l + x - w + pFineOpen * fine) nsBot corner (l + x - w + p * fine) nsBot
define [SlantedVBars lx l r p] : begin
define [object x w] : SlantedDim l r
return : union
SlashShape (l + x - w + p * fine) (l + x + w + p * fine) nsTop nsBot fine
SlashShape (r - x - w - p * fine) (r - x + w - p * fine) nsTop nsBot fine
define NumberSignConfig : object
upright { UprightHBars UprightVBars 0 }
uprightOpen { UprightHBarsOpen UprightVBars (1 / 8) }
slanted { SlantedHBars SlantedVBars 0 }
slantedOpen { SlantedHBarsOpen SlantedVBars (1 / 8) }
foreach { suffix { FHBars FVBars p } } [Object.entries NumberSignConfig] : do
define l : SB - fine / 2
define r : RightSB + fine / 2
create-glyph "numberSign.\(suffix)" : union
FHBars l l r p
FVBars l l r p
create-glyph "numberSign.jr.\(suffix)" : union
FHBars (r - Width) l r p
FVBars (r - Width) l r p
select-variant 'numberSign' '#' select-variant 'numberSign' '#'
select-variant 'numberSign.jr' (follow -- 'numberSign')
glyph-block Symbol-Punctuation-Dashes : begin glyph-block Symbol-Punctuation-Dashes : begin

View file

@ -42,10 +42,7 @@ define [buildLigationsImpl sink para featureName mappedFeature rankedLookups] :
define regexLookAround [less.concat hyphen equal exclam greater anyBar] define regexLookAround [less.concat hyphen equal exclam greater anyBar]
define [acops] {'less' 'greater' 'hyphen' 'equal' 'plus'} define [acops] {'less' 'greater' 'hyphen' 'equal' 'plus'}
define [acskip] { define [acskip] {'slash' 'bar' 'at' 'ampersand' 'percent' 'numberSign'}
'slash' 'bar' 'at' 'ampersand' 'percent'
'numberSign' 'numberSign.upright' 'numberSign.slanted'
}
local ligationLookupName : 'lig_' + featureName + '{' + mappedFeature + '}' local ligationLookupName : 'lig_' + featureName + '{' + mappedFeature + '}'
@ -276,6 +273,12 @@ define [buildLigationsImpl sink para featureName mappedFeature rankedLookups] :
{'underscore' 'underscore.jr'} ~> look-around {'underscore' 'underscore.jr'} ~> look-around
{'underscore'} ~> {'underscore.jr'} {'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 do "triangles" : if [hasLG 'trig'] : begin
CreateLigationLookup : list CreateLigationLookup : list
chain-rule # <| chain-rule # <|

View file

@ -120,7 +120,7 @@ desc = 'Enable ligation for `<!--` and `<!---`'
[simple.colon-greater-as-colon-arrow] [simple.colon-greater-as-colon-arrow]
ligGroup = "colon-greater" ligGroup = "colon-greater"
desc = 'Transform `:>` into `:` and a narrow arrow.' desc = 'Transform `:>` into `:` and a narrow arrow'
[simple.brace-bar] [simple.brace-bar]
ligGroup = 'brace-bar' ligGroup = 'brace-bar'
@ -134,6 +134,10 @@ desc = 'Enable ligation for `[|` and `|]`'
ligGroup = 'connected-underscore' ligGroup = 'connected-underscore'
desc = 'Make contiguous underscores (like `__`) connected' desc = 'Make contiguous underscores (like `__`) connected'
[simple.connected-number-sign]
ligGroup = 'connected-number-sign'
desc = 'Make contiguous number signs (like `##`) connected'
################################################################################################### ###################################################################################################
# This feature is on by default by many software # This feature is on by default by many software
@ -146,7 +150,7 @@ readmeDesc = 'Inherit default ligation set'
[composite.dlig] [composite.dlig]
tag = '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'] 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']
brief = 'Discretionary' brief = 'Discretionary'
desc = 'Discretionary ligatures' desc = 'Discretionary ligatures'