summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/math-fbk.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/math-fbk.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/math-fbk.lua201
1 files changed, 89 insertions, 112 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-fbk.lua b/Master/texmf-dist/tex/context/base/mkiv/math-fbk.lua
index 963461de5cf..7aa8c437fa1 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/math-fbk.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/math-fbk.lua
@@ -20,22 +20,10 @@ local sortedhash = table.sortedhash
local fallbacks = { }
mathematics.fallbacks = fallbacks
-local helpers = fonts.helpers
-local prependcommands = helpers.prependcommands
-local charcommand = helpers.commands.char
-local leftcommand = helpers.commands.left
-local rightcommand = helpers.commands.right
-local upcommand = helpers.commands.up
-local downcommand = helpers.commands.down
-local dummycommand = helpers.commands.dummy
-local popcommand = helpers.commands.pop
-local pushcommand = helpers.commands.push
-
local virtualcharacters = { }
-local hashes = fonts.hashes
-local identifiers = hashes.identifiers
-local lastmathids = hashes.lastmathids
+local identifiers = fonts.hashes.identifiers
+local lastmathids = fonts.hashes.lastmathids
-- we need a trick (todo): if we define scriptscript, script and text in
-- that order we could use their id's .. i.e. we could always add a font
@@ -127,8 +115,6 @@ function fallbacks.apply(target,original)
}
target.mathrelation = data
--
- local fullname = trace_fallbacks and target.properties.fullname
- --
for k, v in sortedhash(virtualcharacters) do
if not characters[k] then
local tv = type(v)
@@ -146,7 +132,7 @@ function fallbacks.apply(target,original)
-- something else
end
if trace_fallbacks and characters[k] then
- report_fallbacks("extending math font %a with %U",fullname,k)
+ report_fallbacks("extending math font %a with %U",target.properties.fullname,k)
end
end
end
@@ -165,21 +151,22 @@ local function reference(index,char)
if index then
return { "slot", index, char }
else
- return charcommand[char]
+ return { "char", char }
end
end
-local function raised(data,replacement,down)
- local character = data.scriptdata.characters[replacement]
+local function raised(data,down)
+ local replacement = data.replacement
+ local character = data.scriptdata.characters[replacement]
if character then
- local size = data.size
return {
width = character.width,
height = character.height,
depth = character.depth,
commands = {
- down and downcommand[size/4] or upcommand[size/2],
+ { "down", down and data.size/4 or -data.size/2 }, -- maybe exheight
reference(data.scriptindex,replacement)
+ -- { "slot", data.scriptindex or 0, char } -- hm, data.mathrelation.scriptindex
}
}
end
@@ -190,18 +177,33 @@ end
-- virtualcharacters[0x208A] = 0x2212
-- virtualcharacters[0x208B] = 0x002B
-virtualcharacters[0x207A] = function(data) return raised(data,0x002B) end
-virtualcharacters[0x207B] = function(data) return raised(data,0x2212) end
-virtualcharacters[0x208A] = function(data) return raised(data,0x002B,true) end
-virtualcharacters[0x208B] = function(data) return raised(data,0x2212,true) end
+virtualcharacters[0x207A] = function(data)
+ data.replacement = 0x002B
+ return raised(data)
+end
+
+virtualcharacters[0x207B] = function(data)
+ data.replacement = 0x2212
+ return raised(data)
+end
+
+virtualcharacters[0x208A] = function(data)
+ data.replacement = 0x002B
+ return raised(data,true)
+end
+
+virtualcharacters[0x208B] = function(data)
+ data.replacement = 0x2212
+ return raised(data,true)
+end
-- local function repeated(data,char,n,fraction)
-- local character = data.characters[char]
-- if character then
-- local width = character.width
-- local delta = width - character.italic -- width * fraction
--- local c = charcommand[char]
--- local r = rightcommand[right]
+-- local c = { "char", char }
+-- local r = { "right", right }
-- local commands = { }
-- for i=1,n-1 do
-- width = width + delta
@@ -232,9 +234,14 @@ addextra(0xFE350) -- MATHEMATICAL DOUBLE ARROW LEFT END
addextra(0xFE351) -- MATHEMATICAL DOUBLE ARROW MIDDLE PART
addextra(0xFE352) -- MATHEMATICAL DOUBLE ARROW RIGHT END
-local leftarrow = charcommand[0x2190]
-local relbar = charcommand[0x2212]
-local rightarrow = charcommand[0x2192]
+local push = { "push" }
+local pop = { "pop" }
+local leftarrow = { "char", 0x2190 }
+local relbar = { "char", 0x2212 }
+local rightarrow = { "char", 0x2192 }
+-- local leftarrow = { "slot", 0, 0x2190 }
+-- local relbar = { "slot", 0, 0x2212 }
+-- local rightarrow = { "slot", 0, 0x2192 }
virtualcharacters[0xFE350] = function(data)
-- return combined(data,0x2190,0x2212) -- leftarrow relbar
@@ -247,11 +254,11 @@ virtualcharacters[0xFE350] = function(data)
height = size,
depth = size,
commands = {
- pushcommand,
- downcommand[size/2],
+ push,
+ { "down", size/2 },
leftarrow,
- popcommand,
- upcommand[size/2],
+ pop,
+ { "down", -size/2 },
relbar,
}
}
@@ -268,11 +275,11 @@ virtualcharacters[0xFE351] = function(data)
height = size,
depth = size,
commands = {
- pushcommand,
- downcommand[size/2],
+ push,
+ { "down", size/2 },
relbar,
- popcommand,
- upcommand[size/2],
+ pop,
+ { "down", -size/2 },
relbar,
}
}
@@ -290,12 +297,12 @@ virtualcharacters[0xFE352] = function(data)
height = size,
depth = size,
commands = {
- pushcommand,
- downcommand[size/2],
+ push,
+ { "down", size/2 },
relbar,
- popcommand,
- rightcommand[chartwo.width - charone.width],
- upcommand[size/2],
+ pop,
+ { "right", chartwo.width - charone.width },
+ { "down", -size/2 },
rightarrow,
}
}
@@ -318,12 +325,10 @@ local function accent_to_extensible(target,newchr,original,oldchr,height,depth,s
height = height or 0
depth = depth or 0
end
- local oldheight = olddata.height or 0
- local correction = swap and
- downcommand[oldheight - height]
- or downcommand[oldheight + (offset or 0)]
+ local correction = swap and { "down", (olddata.height or 0) - height } or { "down", olddata.height + (offset or 0)}
local newdata = {
- commands = { correction, charcommand[oldchr] },
+ commands = { correction, { "slot", 1, oldchr } },
+ -- commands = { correction, { "slot", 0, oldchr } },
width = olddata.width,
height = height,
depth = depth,
@@ -335,12 +340,14 @@ local function accent_to_extensible(target,newchr,original,oldchr,height,depth,s
local oldnextdata = characters[nextglyph]
if oldnextdata then
local newnextdata = {
- commands = { correction, charcommand[nextglyph] },
+ commands = { correction, { "slot", 1, nextglyph } },
+ -- commands = { correction, { "slot", 0, nextglyph } },
width = oldnextdata.width,
height = height,
depth = depth,
}
- local newnextglyph = addprivate(target,formatters["M-N-%H"](nextglyph),newnextdata)
+-- local newnextglyph = addprivate(target,formatters["M-N-%H"](nextglyph),newnextdata)
+ local newnextglyph = addprivate(target,nil,newnextdata)
newdata.next = newnextglyph
local nextnextglyph = oldnextdata.next
if nextnextglyph == nextglyph then
@@ -365,12 +372,14 @@ local function accent_to_extensible(target,newchr,original,oldchr,height,depth,s
local olddata = characters[oldglyph]
if olddata then
local newdata = {
- commands = { correction, charcommand[oldglyph] },
+ commands = { correction, { "slot", 1, oldglyph } },
+ -- commands = { correction, { "slot", 0, oldglyph } },
width = olddata.width,
height = height,
depth = depth,
}
- hvi.glyph = addprivate(target,formatters["M-H-%H"](oldglyph),newdata)
+-- hvi.glyph = addprivate(target,formatters["M-H-%H"](oldglyph),newdata)
+ hvi.glyph = addprivate(target,nil,newdata)
else
report_fallbacks("error in fallback: no valid horiz_variants, slot %X, index %i",oldglyph,i)
end
@@ -384,16 +393,15 @@ end
virtualcharacters[0x203E] = function(data)
local target = data.target
- local height = 0
- local depth = 0
- -- local mathparameters = target.mathparameters
- -- if mathparameters then
- -- height = mathparameters.OverbarVerticalGap
- -- depth = mathparameters.UnderbarVerticalGap
- -- else
+ local height, depth = 0, 0
+-- local mathparameters = target.mathparameters
+-- if mathparameters then
+-- height = mathparameters.OverbarVerticalGap
+-- depth = mathparameters.UnderbarVerticalGap
+-- else
height = target.parameters.xheight/4
depth = height
- -- end
+-- end
return accent_to_extensible(target,0x203E,data.original,0x0305,height,depth,nil,nil,0x203E)
end
@@ -423,7 +431,7 @@ local function spacefraction(data,fraction)
local width = fraction * data.target.parameters.space
return {
width = width,
- commands = { rightcommand[width] }
+ commands = { { "right", width } }
}
end
@@ -431,7 +439,7 @@ local function charfraction(data,char)
local width = data.target.characters[char].width
return {
width = width,
- commands = { rightcommand[width] }
+ commands = { { "right", width } }
}
end
@@ -439,7 +447,7 @@ local function quadfraction(data,fraction)
local width = fraction * data.target.parameters.quad
return {
width = width,
- commands = { rightcommand[width] }
+ commands = { { "right", width } }
}
end
@@ -519,8 +527,9 @@ local function smashed(data,unicode,optional)
local shift = oldchar.height - height
local newchar = {
commands = {
- downcommand[shift],
- charcommand[unicode],
+ { "down", shift },
+ { "slot", 0, unicode },
+-- { "char", unicode },
},
height = height,
width = oldchar.width,
@@ -598,11 +607,11 @@ local function actuarian(data)
width = basewidth + 4 * linewidth,
unicode = 0x20E7,
commands = {
- rightcommand[2 * linewidth],
- downcommand[- baseheight - 3 * linewidth],
+ { "right", 2 * linewidth },
+ { "down", - baseheight - 3 * linewidth },
{ "rule", linewidth, basewidth + 4 * linewidth },
- leftcommand[linewidth],
- downcommand[baseheight + 4 * linewidth],
+ { "right", -linewidth },
+ { "down", baseheight + 4 * linewidth },
{ "rule", baseheight + 5 * linewidth, linewidth },
},
}
@@ -620,11 +629,11 @@ local function equals(data,unicode,snippet,advance,n) -- mathpair needs them
unicode = unicode,
width = n*basechar.width + (n-1)*advance,
commands = {
- charcommand[snippet],
- rightcommand[advance],
- charcommand[snippet],
- n > 2 and rightcommand[advance] or nil,
- n > 2 and charcommand[snippet] or nil,
+ { "char", snippet },
+ { "right", advance },
+ { "char", snippet },
+ n > 2 and { "right", advance } or nil,
+ n > 2 and { "char", snippet } or nil,
},
}
end
@@ -648,43 +657,11 @@ virtualcharacters[0x2980] = function(data) return equals(data,0x2980,0x007C,-1/8
-- height = height, -- we cheat (no time now)
-- depth = depth, -- we cheat (no time now)
-- commands = {
--- upcommand[height/2], -- sort of works
--- charcommand[0x003D],
--- leftcommand[width],
--- downcommand[height], -- sort of works
--- charcommand[0x003D],
+-- { "down", - height/2 }, -- sort of works
+-- { "char", 0x003D },
+-- { "right", -width },
+-- { "down", height }, -- sort of works
+-- { "char", 0x003D },
-- },
-- }
-- end
-
--- lucida needs this
-
-virtualcharacters[0x305] = function(data)
- local target = data.target
- local height = target.parameters.xheight/8
- local width = target.parameters.emwidth/2
- local depth = height
- local used = 0.8 * width
- return {
- width = width,
- height = height,
- depth = depth,
- commands = { { "rule", height, width } },
- horiz_variants = {
- {
- advance = width,
- ["end"] = used,
- glyph = 0x305,
- start = 0,
- },
- {
- advance = width,
- ["end"] = 0,
- extender = 1,
- glyph = 0x305,
- start = used,
- },
- }
- }
-end
-