summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/math-vfu.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/math-vfu.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/math-vfu.lua178
1 files changed, 133 insertions, 45 deletions
diff --git a/Master/texmf-dist/tex/context/base/math-vfu.lua b/Master/texmf-dist/tex/context/base/math-vfu.lua
index 49bf00ffe92..c3f23416622 100644
--- a/Master/texmf-dist/tex/context/base/math-vfu.lua
+++ b/Master/texmf-dist/tex/context/base/math-vfu.lua
@@ -8,15 +8,22 @@ if not modules then modules = { } end modules ['math-vfu'] = {
-- All these math vectors .. thanks to Aditya and Mojca they become
-- better and better. If you have problems with math fonts or miss
--- characters report it to the ConTeXt mailing list.
+-- characters report it to the ConTeXt mailing list. Also thanks to
+-- Boguslaw for finding a couple of errors.
+
+-- 20D6 -> 2190
+-- 20D7 -> 2192
local type, next = type, next
local max = math.max
+local format = string.format
local fonts, nodes, mathematics = fonts, nodes, mathematics
-local trace_virtual = false trackers.register("math.virtual", function(v) trace_virtual = v end)
-local trace_timings = false trackers.register("math.timings", function(v) trace_timings = v end)
+local trace_virtual = false trackers.register("math.virtual", function(v) trace_virtual = v end)
+local trace_timings = false trackers.register("math.timings", function(v) trace_timings = v end)
+
+local add_optional = false directives.register("math.virtual.optional",function(v) add_optional = v end)
local report_virtual = logs.reporter("fonts","virtual math")
@@ -28,8 +35,6 @@ fonts.encodings.math = mathencodings -- better is then: fonts.encodings.vecto
local vfmath = allocate()
fonts.handlers.vf.math = vfmath
-vfmath.optional = false
-
local shared = { }
--~ local push, pop, back = { "push" }, { "pop" }, { "slot", 1, 0x2215 }
@@ -85,12 +90,12 @@ local function arrow(main,characters,id,size,unicode,arrow,minus,isleft)
elseif isleft then
chr.horiz_variants = {
{ extender = 0, glyph = arrow },
- { extender = 1, glyph = minus },
+ { extender = 1, glyph = minus },
}
else
chr.horiz_variants = {
- { extender = 0, glyph = minus },
- { extender = 1, glyph = arrow },
+ { extender = 1, glyph = minus },
+ { extender = 0, glyph = arrow },
}
end
end
@@ -136,7 +141,7 @@ local function make(main,characters,id,size,n,m)
end
end
-local function minus(main,characters,id,size,unicode)
+local function minus(main,characters,id,size,unicode) -- push/pop needed?
local minus = characters[0x002D]
if minus then
local mu = size/18
@@ -148,6 +153,47 @@ local function minus(main,characters,id,size,unicode)
end
end
+-- fails: pdf:page: pdf:direct: ... some funny displacement
+
+-- this does not yet work ... { "scale", 2, 0, 0, 3 } .. commented code
+--
+-- this does not work ... no interpretation going on here
+--
+-- local nodeinjections = backends.nodeinjections
+-- { "node", nodeinjections.save() },
+-- { "node", nodeinjections.transform(.7,0,0,.7) },
+-- commands[#commands+1] = { "node", nodeinjections.restore() }
+
+local done = { }
+
+local function raise(main,characters,id,size,unicode,private,n) -- this is a real fake mess
+ local raised = characters[private]
+ if raised then
+ if not done[unicode] then
+ report_virtual("temporary too large U+%05X due to issues in luatex backend",unicode)
+ done[unicode] = true
+ end
+ local up = 0.85 * main.parameters.x_height
+ local slot = { "slot", id, private }
+ local commands = {
+ push,
+ { "down", - up },
+ -- { "scale", .7, 0, 0, .7 },
+ slot,
+ }
+ for i=2,n do
+ commands[#commands+1] = slot
+ end
+ commands[#commands+1] = pop
+ characters[unicode] = {
+ width = .7 * n * raised.width,
+ height = .7 * (raised.height + up),
+ depth = .7 * (raised.depth - up),
+ commands = commands,
+ }
+ end
+end
+
local function dots(main,characters,id,size,unicode)
local c = characters[0x002E]
if c then
@@ -313,8 +359,8 @@ function vfmath.addmissing(main,id,size)
dots (main,characters,id,size,0x22F1) -- ddots
dots (main,characters,id,size,0x22F0) -- udots
minus (main,characters,id,size,0xFF501)
- arrow (main,characters,id,size,0x2190,0xFE190,0xFF501,true) -- left
- arrow (main,characters,id,size,0x2192,0xFE192,0xFF501,false) -- right
+ arrow (main,characters,id,size,0x2190,0x2190,0xFF501,true) -- left
+ arrow (main,characters,id,size,0x2192,0x2192,0xFF501,false) -- right
vertbar (main,characters,id,size,0x0007C,0.10,0xFF601) -- big : 0.85 bodyfontsize
vertbar (main,characters,id,size,0xFF601,0.30,0xFF602) -- Big : 1.15 bodyfontsize
vertbar (main,characters,id,size,0xFF602,0.30,0xFF603) -- bigg : 1.45 bodyfontsize
@@ -340,6 +386,19 @@ function vfmath.addmissing(main,id,size)
jointwo (main,characters,id,size,0x27FA,0x021D0,joinrelfactor,0x021D2) -- \Leftarrow\joinrel\Rightarrow
jointhree(main,characters,id,size,0x27FB,0x02190,joinrelfactor,0x0002D,0,0xFE324) -- \leftarrow\joinrel\relbar\mapsfromchar
jointhree(main,characters,id,size,0x27FC,0xFE321,0,0x0002D,joinrelfactor,0x02192) -- \mapstochar\relbar\joinrel\rightarrow
+ jointwo (main,characters,id,size,0x2254,0x03A,0,0x03D) -- := (≔)
+
+ -- raise (main,characters,id,size,0x02032,0xFE325,1) -- prime
+ -- raise (main,characters,id,size,0x02033,0xFE325,2) -- double prime
+ -- raise (main,characters,id,size,0x02034,0xFE325,3) -- triple prime
+
+ -- there are more (needs discussion first):
+
+ -- characters[0x20D6] = characters[0x2190]
+ -- characters[0x20D7] = characters[0x2192]
+
+ characters[0x02B9] = characters[0x2032] -- we're nice
+
end
local unique = 0 -- testcase: \startTEXpage \math{!\text{-}\text{-}\text{-}} \stopTEXpage
@@ -362,13 +421,13 @@ end)
function vfmath.define(specification,set,goodies)
local name = specification.name -- symbolic name
local size = specification.size -- given size
- local loaded, fontlist, main = { }, { }, nil
+ local loaded, fontlist, names, main = { }, { }, { }, nil
local start = (trace_virtual or trace_timings) and os.clock()
local okset, n = { }, 0
for s=1,#set do
local ss = set[s]
local ssname = ss.name
- if ss.optional and vfmath.optional then
+ if add_optional and ss.optional then
if trace_virtual then
report_virtual("loading font %s subfont %s with name %s at %s is skipped",name,s,ssname,size)
end
@@ -379,7 +438,17 @@ function vfmath.define(specification,set,goodies)
if ss.main then
main = s
end
- local f, id = fonts.constructors.readanddefine(ssname,size)
+ local alreadyloaded = names[ssname] -- for px we load one twice (saves .04 sec)
+ local f, id
+ if alreadyloaded then
+ f, id = alreadyloaded.f, alreadyloaded.id
+ if trace_virtual then
+ report_virtual("loading font %s subfont %s with name %s is reused",name,s,ssname)
+ end
+ else
+ f, id = fonts.constructors.readanddefine(ssname,size)
+ names[ssname] = { f = f, id = id }
+ end
if not f or id == 0 then
report_virtual("loading font %s subfont %s with name %s at %s is skipped, not found",name,s,ssname,size)
else
@@ -387,7 +456,9 @@ function vfmath.define(specification,set,goodies)
okset[n] = ss
loaded[n] = f
fontlist[n] = { id = id, size = size }
- if not shared[s] then shared[n] = { } end
+ if not shared[s] then
+ shared[n] = { }
+ end
if trace_virtual then
report_virtual("loading font %s subfont %s with name %s at %s as id %s using encoding %s",name,s,ssname,size,id,ss.vector or "none")
end
@@ -471,9 +542,9 @@ function vfmath.define(specification,set,goodies)
setmetatableindex(goodies,parent.goodies)
end
--
- properties.virtualized = true
- properties.italic_correction = true
- properties.has_math = true
+ properties.virtualized = true
+ properties.hasitalics = true
+ properties.hasmath = true
--
local fullname = properties.fullname -- parent via mt
if fullname then
@@ -494,7 +565,7 @@ function vfmath.define(specification,set,goodies)
local ss, fs = okset[s], loaded[s]
if not fs then
-- skip, error
- elseif ss.optional and vfmath.optional then
+ elseif add_optional and ss.optional then
-- skip, redundant
else
local newparameters = fs.parameters
@@ -534,6 +605,7 @@ function vfmath.define(specification,set,goodies)
local offset = 0xFF000
local vector = mathencodings[vectorname]
local rotcev = reverse[vectorname]
+ local isextension = ss.extension
if vector and rotcev then
local fc, fd, si = fs.characters, fs.descriptions, shared[s]
local skewchar = ss.skewchar
@@ -564,9 +636,10 @@ function vfmath.define(specification,set,goodies)
local kerns = fci.kerns
local width = fci.width
local italic = fci.italic
- -- if italic then
- -- width = width + italic -- old interpretation of otf math specs
- -- end
+ if italic and isextension then
+ -- int_a^b
+ width = width + italic
+ end
if kerns then
local krn = { }
for k, v in next, kerns do -- kerns is sparse
@@ -586,7 +659,7 @@ function vfmath.define(specification,set,goodies)
kerns = krn,
commands = ref,
}
- if skewchar and kerns then
+ if skewchar then
local k = kerns[skewchar]
if k then
t.top_accent = width/2 + k
@@ -602,9 +675,10 @@ function vfmath.define(specification,set,goodies)
commands = ref,
}
end
+--~ report_virtual("%05X %s %s",unicode,fci.height or "NO HEIGHT",fci.depth or "NO DEPTH")
end
end
- if ss.extension then
+ if isextension then
-- todo: if multiple ex, then 256 offsets per instance
local extension = mathencodings["large-to-small"]
local variants_done = fs.variants_done
@@ -615,11 +689,12 @@ function vfmath.define(specification,set,goodies)
ref = { { 'slot', s, index } }
si[index] = ref
end
+ local italic = fci.italic
local t = {
- width = fci.width,
+ width = fci.width + italic, -- watch this !
height = fci.height,
depth = fci.depth,
- italic = fci.italic,
+ italic = italic,
commands = ref,
}
local n = fci.next
@@ -665,6 +740,7 @@ function vfmath.define(specification,set,goodies)
if not fci then
-- do nothing
else
+ -- probably never entered
local ref = si[index]
if not ref then
ref = { { 'slot', s, index } }
@@ -723,6 +799,7 @@ function vfmath.define(specification,set,goodies)
fonts.constructors.assignmathparameters(main,main)
--
main.MathConstants = main.mathparameters -- we directly pass it to TeX (bypasses the scaler) so this is needed
+--~ inspect(main.MathConstants)
--
if trace_virtual or trace_timings then
report_virtual("loading and virtualizing font %s at size %s took %0.3f seconds",name,size,os.clock()-start)
@@ -783,20 +860,26 @@ mathencodings["large-to-small"] = {
[0x02044] = 0x0E, -- /
}
+-- Beware: these are (in cm/lm) below the baseline due to limitations
+-- in the tfm format bu the engien (combined with the mathclass) takes
+-- care of it. If we need them in textmode, we should make them virtual
+-- and move them up but we're in no hurry with that.
+
mathencodings["tex-ex"] = {
[0x0220F] = 0x51, -- prod
- [0x0222B] = 0x52, -- intop
[0x02210] = 0x60, -- coprod
[0x02211] = 0x50, -- sum
+ [0x0222B] = 0x52, -- intop
+ [0x0222E] = 0x48, -- ointop
[0x022C0] = 0x56, -- bigwedge
[0x022C1] = 0x57, -- bigvee
[0x022C2] = 0x54, -- bigcap
[0x022C3] = 0x53, -- bigcup
- [0x02A04] = 0x55, -- biguplus
- [0x02A02] = 0x4E, -- bigotimes
+ [0x02A00] = 0x4A, -- bigodot -- fixed BJ
[0x02A01] = 0x4C, -- bigoplus
- [0x02A03] = 0x4A, -- bigodot
- [0x0222E] = 0x48, -- ointop
+ [0x02A02] = 0x4E, -- bigotimes
+ -- [0x02A03] = , -- bigudot --
+ [0x02A04] = 0x55, -- biguplus
[0x02A06] = 0x46, -- bigsqcup
}
@@ -911,8 +994,10 @@ mathencodings["tex-mi"] = {
[0x021C1] = 0x2B, -- rightharpoondown
[0xFE322] = 0x2C, -- lhook (hook for combining arrows)
[0xFE323] = 0x2D, -- rhook (hook for combining arrows)
- [0x022B3] = 0x2E, -- triangleright (TODO: which one is right?)
- [0x022B2] = 0x2F, -- triangleleft (TODO: which one is right?)
+ [0x025B7] = 0x2E, -- triangleright : cf lmmath / BJ
+ [0x025C1] = 0x2F, -- triangleleft : cf lmmath / BJ
+ [0x022B3] = 0x2E, -- triangleright : cf lmmath this a cramped triangles / BJ / see *
+ [0x022B2] = 0x2F, -- triangleleft : cf lmmath this a cramped triangles / BJ / see *
-- [0x00041] = 0x30, -- 0
-- [0x00041] = 0x31, -- 1
-- [0x00041] = 0x32, -- 2
@@ -1044,7 +1129,7 @@ mathencodings["tex-sy"] = {
-- [0x02201] = 0x00, -- complement
-- [0x02206] = 0x00, -- increment
-- [0x02204] = 0x00, -- not exists
---~ [0x000B7] = 0x01, -- cdot
+-- [0x000B7] = 0x01, -- cdot
[0x022C5] = 0x01, -- cdot
[0x000D7] = 0x02, -- times
[0x0002A] = 0x03, -- *
@@ -1181,6 +1266,8 @@ mathencodings["tex-sy"] = {
[0x02661] = 0x7E, -- heartsuit
[0x02660] = 0x7F, -- spadesuit
[0xFE321] = 0x37, -- mapstochar
+
+ [0xFE325] = 0x30, -- prime 0x02032
}
-- The names in masm10.enc can be trusted best and are shown in the first
@@ -1193,11 +1280,11 @@ mathencodings["tex-ma"] = {
[0x022A0] = 0x02, -- squaremultiply \boxtimes
[0x025A1] = 0x03, -- square \square \Box
[0x025A0] = 0x04, -- squaresolid \blacksquare
- [0x000B7] = 0x05, -- squaresmallsolid \centerdot
+ [0x025AA] = 0x05, -- squaresmallsolid \centerdot
[0x022C4] = 0x06, -- diamond \Diamond \lozenge
- [0x029EB] = 0x07, -- diamondsolid \blacklozenge
- [0x021BA] = 0x08, -- clockwise \circlearrowright
- [0x021BB] = 0x09, -- anticlockwise \circlearrowleft
+ [0x02666] = 0x07, -- diamondsolid \blacklozenge
+ [0x021BB] = 0x08, -- clockwise \circlearrowright
+ [0x021BA] = 0x09, -- anticlockwise \circlearrowleft
[0x021CC] = 0x0A, -- harpoonleftright \rightleftharpoons
[0x021CB] = 0x0B, -- harpoonrightleft \leftrightharpoons
[0x0229F] = 0x0C, -- squareminus \boxminus
@@ -1255,9 +1342,10 @@ mathencodings["tex-ma"] = {
[0x02277] = 0x3F, -- greaterorless \gtrless
[0x0228F] = 0x40, -- squareimage \sqsubset
[0x02290] = 0x41, -- squareoriginal \sqsupset
- -- wrong:
- [0x022B3] = 0x42, -- triangleright \rhd \vartriangleright
- [0x022B2] = 0x43, -- triangleleft \lhd \vartriangleleft
+ -- wrong: see **
+ -- [0x022B3] = 0x42, -- triangleright \rhd \vartriangleright
+ -- [0x022B2] = 0x43, -- triangleleft \lhd \vartriangleleft
+ -- cf lm
[0x022B5] = 0x44, -- trianglerightequal \unrhd \trianglerighteq
[0x022B4] = 0x45, -- triangleleftequal \unlhd \trianglelefteq
--
@@ -1292,7 +1380,7 @@ mathencodings["tex-ma"] = {
[0x022D0] = 0x62, -- subsetdbl \Subset
[0x022D1] = 0x63, -- supersetdbl \Supset
[0x022D3] = 0x64, -- uniondbl \doublecup \Cup
- [0x00100] = 0x65, -- intersectiondbl \doublecap \Cap
+ [0x022D2] = 0x65, -- intersectiondbl \doublecap \Cap
[0x022CF] = 0x66, -- uprise \curlywedge
[0x022CE] = 0x67, -- downfall \curlyvee
[0x022CB] = 0x68, -- multiopenleft \leftthreetimes
@@ -1308,7 +1396,7 @@ mathencodings["tex-ma"] = {
[0x024C7] = 0x72, -- circleR \circledR
[0x024C8] = 0x73, -- circleS \circledS
[0x022D4] = 0x74, -- fork \pitchfork
- [0x02245] = 0x75, -- dotplus \dotplus
+ [0x02214] = 0x75, -- dotplus \dotplus
[0x0223D] = 0x76, -- revsimilar \backsim
[0x022CD] = 0x77, -- revasymptequal \backsimeq -- AM: Check this! I mapped it to simeq.
[0x0231E] = 0x78, -- rightanglesw \llcorner
@@ -1413,8 +1501,8 @@ mathencodings["tex-mb"] = {
[0x1D54F] = 0x58, -- X
[0x1D550] = 0x59, -- Y
[0x02124] = 0x5A, -- Z (blackboard Z)
- [0x02132] = 0x60, -- hatwide \Finv
- [0x02141] = 0x61, -- hatwider \Game
+ [0x02132] = 0x60, -- finv \Finv
+ [0x02141] = 0x61, -- fmir \Game
-- [0x0] = 0x62, tildewide
-- [0x0] = 0x63, tildewider
-- [0x0] = 0x64, Finv