Ligation breakdown for C-likes 1 (#1555)

This commit is contained in:
be5invis 2023-02-20 22:53:57 -08:00
parent 5d594676de
commit d3b8e339a2
9 changed files with 1132 additions and 843 deletions

View file

@ -97,39 +97,6 @@ async function deriveFixed_DropFeatures(font, fFixed) {
feature.params = null; feature.params = null;
} }
} }
markSweepLookups(font.gsub);
}
function markSweepLookups(table) {
let lookupSet = new Set();
for (const feature of table.features) {
for (const lookup of feature.lookups) {
lookupSet.add(lookup);
}
}
do {
let sizeBefore = lookupSet.size;
for (const lookup of table.lookups) {
if (lookup instanceof Ot.Gsub.Chaining || lookup instanceof Ot.Gpos.Chaining) {
for (const rule of lookup.rules) {
for (const app of rule.applications) lookupSet.add(app.apply);
}
}
}
let sizeAfter = lookupSet.size;
if (sizeBefore >= sizeAfter) break;
} while (true);
let front = 0;
for (let rear = 0; rear < table.lookups.length; rear++) {
if (lookupSet.has(table.lookups[rear])) {
table.lookups[front++] = table.lookups[rear];
}
}
table.lookups.length = front;
return lookupSet;
} }
async function readTTF(argv) { async function readTTF(argv) {

View file

@ -1,3 +1,5 @@
import { CliProc } from "ot-builder";
import { convertGlyphs } from "./glyphs.mjs"; import { convertGlyphs } from "./glyphs.mjs";
import { convertGsub, convertGpos, convertGdef } from "./layout.mjs"; import { convertGsub, convertGpos, convertGdef } from "./layout.mjs";
@ -6,5 +8,8 @@ export function convertOtd(baseFont, otl, gs) {
const gsub = convertGsub(otl.GSUB, glyphs); const gsub = convertGsub(otl.GSUB, glyphs);
const gpos = convertGpos(otl.GPOS, glyphs); const gpos = convertGpos(otl.GPOS, glyphs);
const gdef = convertGdef(otl.GDEF, glyphs); const gdef = convertGdef(otl.GDEF, glyphs);
return { ...baseFont, glyphs, cmap, gsub, gpos, gdef };
const font = { ...baseFont, glyphs, cmap, gsub, gpos, gdef };
CliProc.consolidateFont(font);
return font;
} }

View file

@ -133,7 +133,37 @@ define [buildLigationsImpl sink para $LigGroup$] : begin
{'asterisk'} ~> {'asterisk/sMid'} {'asterisk'} ~> {'asterisk/sMid'}
{'parenRight'} ~> look-around {'parenRight'} ~> look-around
LigGroup "Bracket-Colon" : if [hasLG 'center-ops'] : begin
CreateLigationLookup : list
chain-rule # (:
{'parenLeft' 'bracketLeft' 'braceLeft'} ~> look-around
{'colon'} ~> {'colon/mid'}
chain-rule # :)
{'colon'} ~> {'colon/mid'}
{'parenRight' 'bracketRight' 'braceRight'} ~> look-around
LigGroup "Operator centering" : if [hasLG 'center-ops'] : begin LigGroup "Operator centering" : if [hasLG 'center-ops'] : begin
define triggerL {}
define triggerR {}
define skipL { 'slash' 'backslash' 'at' 'ampersand' 'percent' 'numberSign' }
define skipR { 'slash' 'backslash' 'at' 'ampersand' 'percent' 'numberSign' }
if [hasLG 'center-op-trigger-plus-minus-l'] : triggerL.push 'plus' 'minus' 'hyphen'
if [hasLG 'center-op-trigger-plus-minus-r'] : triggerR.push 'plus' 'minus' 'hyphen'
if [hasLG 'center-op-trigger-equal-l'] : triggerL.push 'equal' 'ident'
if [hasLG 'center-op-trigger-equal-r'] : triggerR.push 'equal' 'ident'
if [hasLG 'center-op-trigger-bar-l'] : triggerL.push 'bar'
if [hasLG 'center-op-trigger-bar-r'] : triggerR.push 'bar'
if [hasLG 'center-op-trigger-slash-l'] : triggerL.push 'slash' 'backslash'
if [hasLG 'center-op-trigger-slash-r'] : triggerR.push 'slash' 'backslash'
if [hasLG 'center-op-trigger-angle-inside']
begin [triggerR.push 'less'] [triggerL.push 'greater']
if [hasLG 'center-op-trigger-angle-outside']
begin [triggerL.push 'less'] [triggerR.push 'greater']
if [not : hasLG 'center-op-trigger-bar-l'] : skipL.push 'bar'
if [not : hasLG 'center-op-trigger-bar-r'] : skipR.push 'bar'
define [acops] : if [hasLG 'bar-triggers-op-centering'] define [acops] : if [hasLG 'bar-triggers-op-centering']
begin {'less' 'greater' 'hyphen' 'equal' 'plus' 'slash' 'bar' 'backslash'} begin {'less' 'greater' 'hyphen' 'equal' 'plus' 'slash' 'bar' 'backslash'}
@ -142,64 +172,48 @@ define [buildLigationsImpl sink para $LigGroup$] : begin
begin {'at' 'ampersand' 'percent' 'numberSign'} begin {'at' 'ampersand' 'percent' 'numberSign'}
begin {'slash' 'bar' 'backslash' 'at' 'ampersand' 'percent' 'numberSign'} begin {'slash' 'bar' 'backslash' 'at' 'ampersand' 'percent' 'numberSign'}
define [centerAsterisk] : {'asterisk'} ~> {'asterisk/sMid'} define opcGroups : list
define [centerColon] : {'colon'} ~> {'colon/mid'} {'asterisk'} ~> {'asterisk/sMid'}
define [centerCaret] : {'asciiCaret'} ~> {'asciiCaret.low'} {'asciiCaret'} ~> {'asciiCaret.low'}
define [centerTilde] : {'asciiTilde'} ~> {'asciiTilde.low'} {'asciiTilde'} ~> {'asciiTilde.low'}
define [centerPeriod] : {'period'} ~> {'period/mid'}
define [deCenterPeriod] : {'period/mid'} ~> {'period'}
define centerizeGroups : list centerAsterisk centerColon centerCaret centerTilde if [hasLG 'center-op-influence-dot'] : opcGroups.push : {'period'} ~> {'period/mid'}
if [hasLG 'dot-oper'] : centerizeGroups.push centerPeriod if [hasLG 'center-op-influence-colon'] : opcGroups.push : {'colon'} ~> {'colon/mid'}
define centerizeL : centerizeGroups.map : x => [x].left.0 define opcFrom : opcGroups.map : x => x.left.0
define centerizeR : centerizeGroups.map : lambda [x] : begin define opcTo : opcGroups.map : x => x.right.0
local left [x].left define C : opcFrom ~> opcTo
local right [x].right
while (right <@ Function) : set right [right left]
return : if right (right.0 || left.0) (left.0)
define [Cg] : centerizeL ~> centerizeR # Triggering
do "Bracket-colon"
CreateLigationLookup : list CreateLigationLookup : list
chain-rule # (: chain-rule C C skipL skipL triggerL # **##+
{'parenLeft' 'bracketLeft' 'braceLeft'} ~> look-around chain-rule C C skipL triggerL # **#+
centerColon chain-rule C C triggerL # **+
chain-rule # :) chain-rule C skipL skipL triggerL # *##+
centerColon chain-rule C skipL triggerL # *#+
{'parenRight' 'bracketRight' 'braceRight'} ~> look-around chain-rule C triggerL # *+
chain-rule triggerR skipR skipR C # +##*
chain-rule triggerR skipR C # +#*
chain-rule triggerR C # +*
do "Operator Centering" # Extension
CreateLigationLookup : list CreateLigationLookup : list
chain-rule [Cg] [Cg] [acskip] [acskip] [acops] # ::+ chain-rule opcTo skipR skipR C # *##* --->
chain-rule [Cg] [Cg] [acskip] [acops] # ::+ chain-rule opcTo skipR C # *#* --->
chain-rule [Cg] [Cg] [acops] # ::+ chain-rule opcTo C # ** --->
chain-rule [Cg] [acskip] [acskip] [acops] # :+
chain-rule [Cg] [acskip] [acops] # :+
chain-rule [Cg] [acops] # :+
chain-rule [acops] [acskip] [acskip] [Cg] # +:
chain-rule [acops] [acskip] [Cg] # +:
chain-rule [acops] [Cg] # +:
do "Operator centering : Trailing"
CreateLigationLookup : list
chain-rule centerizeR [acskip] [acskip] [Cg]
chain-rule centerizeR [acskip] [Cg]
chain-rule centerizeR [Cg]
CreateReverseLigationLookup : list CreateReverseLigationLookup : list
reverse-rule [Cg] [acskip] [acskip] centerizeR reverse-rule C skipL skipL opcTo # *##* <---
reverse-rule [Cg] [acskip] centerizeR reverse-rule C skipL opcTo # *#* <---
reverse-rule [Cg] centerizeR reverse-rule C opcTo # ** <---
do "Operator centering : Apple fix" # AAPL FIX
# Apple (still) have problem when dealing with reverse chaining lookup # Apple (still) have problem when dealing with reverse chaining lookup
# They give up at run beginning. Fix them. # They give up at run beginning. Fix them.
CreateLigationLookup : list CreateLigationLookup : list
chain-rule [Cg] [acskip] [acskip] centerizeR chain-rule C skipR skipR opcTo
chain-rule [Cg] [acskip] centerizeR chain-rule C skipR opcTo
chain-rule [Cg] centerizeR chain-rule C opcTo
LigGroup "slash-asterisk" : if [hasLG 'slash-asterisk'] : begin LigGroup "slash-asterisk" : if [hasLG 'slash-asterisk'] : begin
CreateLigationLookup : list CreateLigationLookup : list

View file

@ -11,7 +11,7 @@ export function applyLigationData(data, para, argv) {
for (const gr in data.composite) { for (const gr in data.composite) {
const comp = data.composite[gr]; const comp = data.composite[gr];
if (!comp.tag) continue; if (!comp.tag) continue;
const ligSets = createBuildup(data.simple, comp.buildup); const ligSets = createBuildup(data.simple, data.composite, comp.buildup);
defaultBuildup[comp.tag] = ligSets; defaultBuildup[comp.tag] = ligSets;
hives[`ligset-inherit-${gr}`] = { caltBuildup: ligSets }; hives[`ligset-inherit-${gr}`] = { caltBuildup: ligSets };
} }
@ -37,11 +37,20 @@ export function applyLigationData(data, para, argv) {
} }
} }
function createBuildup(simple, buildup) { export function createBuildup(simple, composite, buildup) {
let ligSet = new Set(); let sink = new Set();
for (const s of buildup) { createBuildupImpl(sink, simple, composite, buildup);
if (!simple[s]) throw new Error("Cannot find simple ligation group " + s); return Array.from(sink);
ligSet.add(simple[s].ligGroup); }
}
return Array.from(ligSet); function createBuildupImpl(sink, simple, composite, buildup) {
for (const s of buildup) {
if (simple[s]) {
sink.add(simple[s].ligGroup);
} else if (composite[s]) {
createBuildupImpl(sink, simple, composite, composite[s].buildup);
} else {
throw new Error("Cannot find simple ligation group " + s);
}
}
} }

1404
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -10,8 +10,8 @@
"dependencies": { "dependencies": {
"@iarna/toml": "^2.2.5", "@iarna/toml": "^2.2.5",
"@msgpack/msgpack": "^2.8.0", "@msgpack/msgpack": "^2.8.0",
"ot-builder": "^1.6.0", "ot-builder": "^1.6.1",
"otb-ttc-bundle": "^1.6.0", "otb-ttc-bundle": "^1.6.1",
"semver": "^7.3.8", "semver": "^7.3.8",
"spiro": "^3.0.0", "spiro": "^3.0.0",
"toposort": "^2.0.2", "toposort": "^2.0.2",
@ -23,11 +23,11 @@
"devDependencies": { "devDependencies": {
"@unicode/unicode-14.0.0": "^1.3.1", "@unicode/unicode-14.0.0": "^1.3.1",
"cldr": "^7.3.0", "cldr": "^7.3.0",
"eslint": "^8.32.0", "eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0", "eslint-config-prettier": "^8.6.0",
"eslint-plugin-import": "^2.27.5", "eslint-plugin-import": "^2.27.5",
"patel": "^0.38.0", "patel": "^0.38.0",
"prettier": "^2.8.3", "prettier": "^2.8.4",
"verda": "^1.11.0", "verda": "^1.11.0",
"which": "^3.0.0" "which": "^3.0.0"
}, },

View file

@ -1,8 +1,59 @@
[simple.center-ops] [simple.center-ops]
ligGroup = 'center-ops' ligGroup = 'center-ops'
samples = [":=", ":-", ":+", "<*", "<*>", "*>", "+:", "-:", "=:", "<***>", "<:", ":>"] samples = [":=", ":-", ":+", "<*", "<*>", "*>", "+:", "-:", "=:", "<***>", "<:", ":>", "*-", "-*", "*=", "=*", "*+", "+*"]
desc = 'Vertically align some of the operators (like `*`) to the center position it is before or after a "center" operator (like `+`)' desc = 'Vertically align some of the operators (like `*`) to the center position it is before or after a "center" operator (like `+`)'
[simple.center-op-trigger-plus-minus-l]
ligGroup = 'center-op-trigger-plus-minus-l'
samples = ["*+", "*-", ":+", ":-", ".+", ".-"]
desc = 'Plus (`+`) and Minus (`-`) will trigger other operator characters at left to be centered'
[simple.center-op-trigger-plus-minus-r]
ligGroup = 'center-op-trigger-plus-minus-r'
samples = ["+*", "-*", "+:", "-:", "+.", "-."]
desc = 'Plus (`+`) and Minus (`-`) will trigger other operator characters at right to be centered'
[simple.center-op-trigger-equal-l]
ligGroup = 'center-op-trigger-equal-l'
samples = ["*=", ":=", ".="]
desc = 'Equal (`=`) will trigger other operator characters at left to be centered'
[simple.center-op-trigger-equal-r]
ligGroup = 'center-op-trigger-equal-r'
samples = ["=*", "=:", "=."]
desc = 'Equal (`=`) will trigger other operator characters at right to be centered'
[simple.center-op-trigger-bar-l]
ligGroup = 'center-op-trigger-bar-l'
samples = ["*|", ":|"]
desc = 'Bars (`|`) will trigger other operator characters at left to be centered'
[simple.center-op-trigger-bar-r]
ligGroup = 'center-op-trigger-bar-r'
samples = ["|*", "|:"]
desc = 'Bars (`|`) will trigger other operator characters at right to be centered'
[simple.center-op-trigger-angle-inside]
ligGroup = 'center-op-trigger-angle-inside'
samples = ["<:", "<:>", ":>", "<*", "<*>", "*>", "<.", "<.>", ".>"]
desc = 'Less (`<`) and Greater (`>`) will trigger other operator characters at inside to be centered'
[simple.center-op-trigger-angle-outside]
ligGroup = 'center-op-trigger-angle-outside'
samples = [">*", "*<"]
desc = 'Less (`<`) and Greater (`>`) will trigger other operator characters at outside to be centered'
[simple.center-op-influence-dot]
ligGroup = "center-op-influence-dot"
samples = ["<.", "<.>", ".>"]
desc = 'Treat dot (`.`) as operator and perform chained centering'
[simple.center-op-influence-colon]
ligGroup = "center-op-influence-colon"
samples = ["<:", "<:>", ":>", ":=", "=:", ":-", "-:"]
[simple.arrow] [simple.arrow]
ligGroup = "arrow" ligGroup = "arrow"
samples = ["<--", "<---", "<<-", "<-", "->", "->>", "-->", "--->", "<->", "<-->", "<--->", "<---->", "<==", "<===", "<<=", "=>", "=>>", "==>", "===>", "<=>", "<==>", "<===>", "<====>", "<~~", "<~", "<~>", "~>", "~~>", "-------->"] samples = ["<--", "<---", "<<-", "<-", "->", "->>", "-->", "--->", "<->", "<-->", "<--->", "<---->", "<==", "<===", "<<=", "=>", "=>>", "==>", "===>", "<=>", "<==>", "<===>", "<====>", "<~~", "<~", "<~>", "~>", "~~>", "-------->"]
@ -141,16 +192,6 @@ samples = ["<<=", ">>="]
sampleRank = 2 sampleRank = 2
desc = 'Enable ligation for `<<=`, `>>=` as shift operator' desc = 'Enable ligation for `<<=`, `>>=` as shift operator'
[simple.dot-as-operator]
ligGroup = "dot-oper"
samples = ["<.", "<.>", ".>"]
desc = 'Treat dot (`.`) as operator and perform chained centering'
[simple.bar-triggers-op-centering]
ligGroup = "bar-triggers-op-centering"
samples = [":|", ":|:", "|:"]
desc = 'Bars (`/`, `|`, `\`) will trigger operator centering'
[simple.lteq-as-arrow] [simple.lteq-as-arrow]
ligGroup = "arrowZALE" ligGroup = "arrowZALE"
samples = ["<="] samples = ["<="]
@ -206,107 +247,347 @@ desc = 'Make contiguous hyphen-minuses (like `--`) connected as a straight solid
################################################################################################### ###################################################################################################
# Non-tagged composites, used for inheritance
[composite.--default-center-ops--]
buildup = [
'center-ops',
'center-op-trigger-plus-minus-l',
'center-op-trigger-plus-minus-r',
'center-op-trigger-equal-l',
'center-op-trigger-equal-r',
'center-op-trigger-angle-inside',
'center-op-trigger-angle-outside',
'center-op-influence-colon',
]
[composite.--c-center-ops--]
buildup = [
'center-ops',
'center-op-trigger-equal-l',
]
[composite.--default-equality-inequality--]
buildup = [ 'eqeq', 'exeq', 'ineq' ]
[composite.--c-equality-inequality--]
buildup = [ 'eqeqeq', 'eqeq', 'exeqeq', 'exeq', 'ineq' ]
[composite.--raku-equality-inequality--]
buildup = [ 'eqeqeq', 'eqeq', 'exeqeqeq', 'exeq', 'ineq' ]
[composite.--ml-equality-inequality--]
buildup = [ 'eqeq', 'ltgt-ne', 'ineq' ]
[composite.--fstar-equality-inequality--]
buildup = [ 'eqeq', 'ltgt-ne', 'eqeqeq', 'eqexeq', 'ineq' ]
[composite.--haskell-equality-inequality--]
buildup = [ 'eqeq', 'slasheq', 'ineq' ]
[composite.--matlab-equality-inequality--]
buildup = [ 'eqeq', 'tildeeq', 'ineq' ]
[composite.--verilog-equality-inequality--]
buildup = [ 'eqeqeq', 'eqeq', 'exeqeq', 'exeq' ]
[composite.--wolfram-equality-inequality--]
buildup = [ 'eqeq', 'exeq', 'eqexeq-dl', 'ineq' ]
[composite.--default-kern--]
buildup = [ 'kern-dotty', 'kern-bars' ]
# This feature is on by default by many software # This feature is on by default by many software
[composite.default-calt] [composite.default-calt]
tag = 'calt' tag = 'calt'
buildup = ['center-ops', 'arrow', 'html-comment', 'ltgt-diamond-tag', 'ltgt-slash-tag', 'trig', 'slash-asterisk', 'llgg', 'llggeq', 'eqeq', 'exeq', 'ineq', 'plusplus', 'kern-dotty', 'kern-bars']
brief = 'Default' brief = 'Default'
desc = 'Default setting in text editors' desc = 'Default setting in text editors'
readmeDesc = 'Inherit default ligation set' readmeDesc = 'Inherit default ligation set'
buildup = [
'--default-center-ops--',
'--default-equality-inequality--',
'--default-kern--',
'arrow',
'html-comment',
'ltgt-diamond-tag',
'ltgt-slash-tag',
'trig',
'slash-asterisk',
'llgg',
'llggeq',
'plusplus',
]
[composite.dlig] [composite.dlig]
tag = 'dlig' tag = 'dlig'
buildup = ['center-ops', 'arrow', 'html-comment', 'ltgt-diamond-tag', 'ltgt-slash-tag', 'trig', 'slash-asterisk', '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']
brief = 'Discretionary' brief = 'Discretionary'
desc = 'Discretionary ligatures' desc = 'Discretionary ligatures'
buildup = [
'--default-center-ops--',
'center-op-influence-dot',
'--default-equality-inequality--',
'--default-kern--',
'arrow',
'arrow2',
'html-comment',
'ltgt-diamond-tag',
'ltgt-slash-tag',
'trig',
'slash-asterisk',
'llgg',
'plusplus',
'logic',
'brst',
'brace-bar',
'brack-bar',
'connected-underscore',
'connected-number-sign',
'connected-tilde-as-wave',
'connected-hyphen'
]
[composite.clike] [composite.clike]
tag = 'CLIK' tag = 'CLIK'
buildup = ['center-ops', 'arrow', 'html-comment', 'ltgt-diamond-tag', 'ltgt-slash-tag', 'trig', 'slash-asterisk', 'llgg', 'llggeq', 'eqeqeq', 'eqeq', 'exeqeq', 'exeq', 'ineq', 'plusplus', 'kern-dotty', 'kern-bars']
desc = 'C-Like' desc = 'C-Like'
buildup = [
'--c-center-ops--',
'--c-equality-inequality--',
'--default-kern--',
'arrow',
'html-comment',
'ltgt-diamond-tag',
'ltgt-slash-tag',
'trig',
'slash-asterisk',
'llgg',
'llggeq',
'plusplus',
]
[composite.javascript] [composite.javascript]
tag = 'JSPT' tag = 'JSPT'
buildup = ['center-ops', 'arrow', 'html-comment', 'ltgt-diamond-tag', 'ltgt-slash-tag', 'trig', 'slash-asterisk', 'llgg', 'llggeq', 'eqeqeq', 'eqeq', 'exeqeq', 'exeq', 'ineq', 'plusplus', 'kern-dotty', 'kern-bars']
desc = 'JavaScript' desc = 'JavaScript'
buildup = [
'--c-center-ops--',
'--c-equality-inequality--',
'--default-kern--',
'arrow',
'html-comment',
'ltgt-diamond-tag',
'ltgt-slash-tag',
'trig',
'slash-asterisk',
'llgg',
'llggeq',
'plusplus',
]
[composite.php] [composite.php]
tag = 'PHPX' tag = 'PHPX'
buildup = ['center-ops', 'arrow', 'html-comment', 'ltgt-diamond-tag', 'ltgt-slash-tag', 'trig', 'slash-asterisk', 'llgg', 'llggeq', 'eqeqeq', 'eqeq', 'exeqeq', 'exeq', 'ineq', 'plusplus', 'dot-as-operator', 'kern-dotty', 'kern-bars']
desc = 'PHP' desc = 'PHP'
buildup = [
'--default-center-ops--',
'center-op-influence-dot',
'--c-equality-inequality--',
'--default-kern--',
'arrow',
'html-comment',
'ltgt-diamond-tag',
'ltgt-slash-tag',
'trig',
'slash-asterisk',
'llgg',
'llggeq',
'plusplus',
]
[composite.julia] [composite.julia]
tag = 'JLIA' tag = 'JLIA'
buildup = ['center-ops', 'arrow', 'trig', 'llgg', 'llggeq', 'eqeqeq', 'eqeq', 'exeqeq', 'exeq', 'ineq', 'plusplus', 'dot-as-operator', 'kern-dotty', 'kern-bars']
desc = 'Julia' desc = 'Julia'
buildup = [
'--default-center-ops--',
'center-op-influence-dot',
'--c-equality-inequality--',
'--default-kern--',
'arrow',
'trig',
'llgg',
'llggeq',
'plusplus',
]
[composite.raku] [composite.raku]
tag = 'RAKU' tag = 'RAKU'
buildup = ['center-ops', 'arrow', 'trig', 'llgg', 'llggeq', 'eqeqeq', 'eqeq', 'exeqeqeq', 'exeq', 'ineq', 'plusplus', 'dot-as-operator', 'kern-dotty', 'kern-bars']
desc = 'Raku' desc = 'Raku'
buildup = [
'--default-center-ops--',
'center-op-influence-dot',
'--raku-equality-inequality--',
'--default-kern--',
'arrow',
'trig',
'llgg',
'llggeq',
'plusplus',
]
[composite.ml] [composite.ml]
tag = 'MLXX' tag = 'MLXX'
buildup = ['center-ops', 'arrow', 'trig', 'eqeq', 'ltgt-ne', 'ineq', 'brst', 'plusplus', 'logic', 'kern-dotty', 'kern-bars']
desc = 'ML' desc = 'ML'
buildup = [
'--default-center-ops--',
'--ml-equality-inequality--',
'--default-kern--',
'arrow',
'trig',
'brst',
'plusplus',
'logic',
]
[composite.fsharp] [composite.fsharp]
tag = 'FSHP' tag = 'FSHP'
buildup = ['center-ops', 'arrow', 'trig', 'eqeq', 'ltgt-ne', 'ineq', 'brst', 'plusplus', 'logic', 'kern-dotty', 'kern-bars']
desc = 'F#' desc = 'F#'
buildup = [ 'ml' ]
[composite.fstar] [composite.fstar]
tag = 'FSTA' tag = 'FSTA'
buildup = ['center-ops', 'arrow', 'trig', 'eqeq', 'ltgt-ne', 'eqeqeq', 'eqexeq', 'ineq', 'brst', 'plusplus', 'logic', 'kern-dotty', 'kern-bars']
desc = 'F*' desc = 'F*'
buildup = [
'--default-center-ops--',
'--fstar-equality-inequality--',
'--default-kern--',
'arrow',
'trig',
'brst',
'plusplus',
'logic',
]
[composite.haskell] [composite.haskell]
tag = 'HSKL' tag = 'HSKL'
buildup = ['center-ops', 'arrow', 'arrow2', 'trig', 'llgg', 'eqeq', 'slasheq', 'ineq', 'ltgt-diamond', 'plusplus', 'dot-as-operator', 'kern-dotty', 'kern-bars', 'logic']
desc = 'Haskell' desc = 'Haskell'
buildup = [
'--default-center-ops--',
'center-op-influence-dot',
'--haskell-equality-inequality--',
'--default-kern--',
'arrow',
'arrow2',
'trig',
'llgg',
'ltgt-diamond',
'plusplus',
'logic',
]
[composite.idris] [composite.idris]
tag = 'IDRS' tag = 'IDRS'
buildup = ['center-ops', 'arrow', 'arrow2', 'trig', 'llgg', 'eqeq', 'slasheq', 'ineq', 'ltgt-diamond', 'plusplus', 'dot-as-operator', 'kern-dotty', 'kern-bars', 'logic']
desc = 'Idris' desc = 'Idris'
buildup = [ 'haskell' ]
[composite.elm] [composite.elm]
tag = 'ELMX' tag = 'ELMX'
buildup = ['center-ops', 'arrow', 'arrow2', 'trig', 'llgg', 'eqeq', 'slasheq', 'ineq', 'ltgt-diamond', 'plusplus', 'dot-as-operator', 'kern-dotty', 'kern-bars', 'logic']
desc = 'Elm' desc = 'Elm'
buildup = [ 'haskell' ]
[composite.purescript] [composite.purescript]
tag = 'PURS' tag = 'PURS'
buildup = ['center-ops', 'arrow', 'arrow2', 'trig', 'llgg', 'eqeq', 'slasheq', 'ineq', 'ltgt-diamond', 'plusplus', 'dot-as-operator', 'kern-dotty', 'kern-bars', 'logic']
desc = 'PureScript' desc = 'PureScript'
buildup = [ 'haskell' ]
[composite.swift] [composite.swift]
tag = 'SWFT' tag = 'SWFT'
buildup = ['center-ops', 'arrow', 'arrow2', 'trig', 'slash-asterisk', 'llgg', 'eqeq', 'exeq', 'ineq', 'ltgt-diamond', 'plusplus', 'kern-dotty', 'kern-bars']
desc = 'Swift' desc = 'Swift'
buildup = [
'--default-center-ops--',
'--default-equality-inequality--',
'--default-kern--',
'arrow',
'arrow2',
'trig',
'slash-asterisk',
'llgg',
'ltgt-diamond',
'plusplus',
]
[composite.dafny] [composite.dafny]
tag = 'DFNY' tag = 'DFNY'
buildup = ['center-ops', 'arrow', 'arrow2', 'trig', 'slash-asterisk', 'llgg', 'eqeq', 'exeq', 'ineq', 'ltgt-diamond', 'plusplus', 'bar-triggers-op-centering', 'kern-dotty', 'kern-bars']
desc = 'Dafny' desc = 'Dafny'
buildup = [
'--default-center-ops--',
'center-op-trigger-bar-l',
'center-op-trigger-bar-r',
'--default-equality-inequality--',
'--default-kern--',
'arrow',
'arrow2',
'trig',
'slash-asterisk',
'llgg',
'ltgt-diamond',
'plusplus',
]
[composite.coq] [composite.coq]
tag = 'COQX' tag = 'COQX'
buildup = ['center-ops', 'arrow', 'arrow2', 'trig', 'llgg', 'eqeq', 'ltgt-ne', 'ineq', 'plusplus', 'dot-as-operator', 'logic', 'brst', 'kern-dotty', 'kern-bars']
desc = 'Coq' desc = 'Coq'
buildup = [
'--default-center-ops--',
'center-op-influence-dot',
'--ml-equality-inequality--',
'--default-kern--',
'arrow',
'arrow2',
'trig',
'llgg',
'plusplus',
'logic',
'brst',
]
[composite.matlab] [composite.matlab]
tag = 'MTLB' tag = 'MTLB'
buildup = ['center-ops', 'arrow', 'trig', 'llgg', 'eqeq', 'tildeeq', 'ineq', 'plusplus', 'kern-dotty', 'kern-bars'] buildup = [
'--default-center-ops--',
'--matlab-equality-inequality--',
'--default-kern--',
'arrow',
'trig',
'llgg',
'plusplus',
]
desc = 'Matlab' desc = 'Matlab'
[composite.verilog] [composite.verilog]
tag = 'VRLG' tag = 'VRLG'
buildup = ['center-ops', 'arrow', 'trig', 'slash-asterisk', 'llgg', 'llggeq', 'eqeqeq', 'eqeq', 'exeqeq', 'exeq', 'plusplus', 'brst', 'kern-dotty', 'kern-bars'] buildup = [
'--default-center-ops--',
'--verilog-equality-inequality--',
'--default-kern--',
'arrow',
'trig',
'slash-asterisk',
'llgg',
'llggeq',
'plusplus',
'brst',
]
desc = 'Verilog' desc = 'Verilog'
[composite.wolfram] [composite.wolfram]
tag = 'WFLM' tag = 'WFLM'
buildup = ['center-ops', 'arrow', 'trig', 'ltgt-diamond', 'eqeq', 'exeq', 'eqexeq-dl', 'ineq', 'brst', 'plusplus', 'logic', 'colon-greater-as-colon-arrow', 'kern-dotty', 'kern-bars']
brief = 'Wolfram' brief = 'Wolfram'
desc = 'Wolfram Language (Mathematica)' desc = 'Wolfram Language (Mathematica)'
buildup = [
'--default-center-ops--',
'--wolfram-equality-inequality--',
'--default-kern--',
'arrow',
'trig',
'ltgt-diamond',
'brst',
'plusplus',
'logic',
'colon-greater-as-colon-arrow',
]

View file

@ -4,6 +4,8 @@ import url from "url";
import * as toml from "@iarna/toml"; import * as toml from "@iarna/toml";
import { createBuildup } from "../../font-src/support/ligation-data.mjs";
const ligationSamplesNarrow = [ const ligationSamplesNarrow = [
[ [
"-<<", "-<<",
@ -58,8 +60,8 @@ const ligationSamplesNarrow = [
[ [
"<:", "<:",
":=", ":=",
":-", "*=",
":+", "*+",
"<*", "<*",
"<*>", "<*>",
"*>", "*>",
@ -69,8 +71,8 @@ const ligationSamplesNarrow = [
"<.", "<.",
"<.>", "<.>",
".>", ".>",
"+:", "+*",
"-:", "=*",
"=:", "=:",
":>" ":>"
], ],
@ -93,6 +95,7 @@ const ligationSamplesNarrow = [
"<!---" "<!---"
] ]
]; ];
function buildLigationSet(ligData, getKey) { function buildLigationSet(ligData, getKey) {
const ligationSets = new Map([ const ligationSets = new Map([
["*off", { tag: "calt", rank: 0, desc: "Ligation Off", brief: "Off", ligSets: [] }] ["*off", { tag: "calt", rank: 0, desc: "Ligation Off", brief: "Off", ligSets: [] }]
@ -103,15 +106,12 @@ function buildLigationSet(ligData, getKey) {
const key = getKey(comp); const key = getKey(comp);
let item = ligationSets.get(key); let item = ligationSets.get(key);
if (!item) { if (!item) {
let ligSets = new Set(); let ligSets = createBuildup(ligData.simple, ligData.composite, comp.buildup);
for (const s of comp.buildup) {
ligSets.add(ligData.simple[s].ligGroup);
}
item = { item = {
selector: sel, selector: sel,
tag: comp.tag, tag: comp.tag,
rank: 1, rank: 1,
ligSets: [...ligSets], ligSets,
tagName: [comp.tag], tagName: [comp.tag],
desc: comp.desc, desc: comp.desc,
brief: comp.brief || comp.desc brief: comp.brief || comp.desc
@ -125,6 +125,7 @@ function buildLigationSet(ligData, getKey) {
} }
return ligationSets; return ligationSets;
} }
export async function parseLigationData() { export async function parseLigationData() {
const __dirname = url.fileURLToPath(new URL(".", import.meta.url)); const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const ligToml = await fs.promises.readFile( const ligToml = await fs.promises.readFile(

View file

@ -4,13 +4,25 @@ function* makeSample(theme, args) {
const groupSet = new Set(args.ligSets); const groupSet = new Set(args.ligSets);
for (const row of args.ligationSamples) { for (const row of args.ligationSamples) {
for (const sampleStr of row) { for (const sampleStr of row) {
let rank = 0; let sat = [];
for (const [lgName, lg] of Object.entries(args.ligationCherry)) { for (const [lgName, lg] of Object.entries(args.ligationCherry)) {
if (!groupSet.has(lg.ligGroup)) continue;
if (!new Set(lg.samples || []).has(sampleStr)) continue; if (!new Set(lg.samples || []).has(sampleStr)) continue;
const rankT = lg.sampleRank || 1; const rankT = lg.sampleRank || 1;
if (rankT > rank) rank = rankT;
if (!sat[rankT]) {
sat[rankT] = { required: 1, satisfied: 0 };
} else {
sat[rankT].required += 1;
} }
if (groupSet.has(lg.ligGroup)) {
sat[rankT].satisfied += 1;
}
}
let rank = sat.length - 1;
for (; rank >= 1 && (!sat[rank] || sat[rank].satisfied < sat[rank].required); rank--);
yield [{ color: theme[rank > 1 ? "stress" : rank > 0 ? "body" : "dimmed"] }, sampleStr]; yield [{ color: theme[rank > 1 ? "stress" : rank > 0 ? "body" : "dimmed"] }, sampleStr];
yield " "; yield " ";
} }