summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkxl')
-rw-r--r--tex/context/base/mkxl/cont-new.mkxl2
-rw-r--r--tex/context/base/mkxl/context.mkxl2
-rw-r--r--tex/context/base/mkxl/driv-shp.lmt29
-rw-r--r--tex/context/base/mkxl/good-mth.lmt567
-rw-r--r--tex/context/base/mkxl/lpdf-lmt.lmt16
-rw-r--r--tex/context/base/mkxl/math-act.lmt355
-rw-r--r--tex/context/base/mkxl/math-fbk.lmt454
-rw-r--r--tex/context/base/mkxl/math-noa.lmt30
-rw-r--r--tex/context/base/mkxl/strc-syn.mkxl32
-rw-r--r--tex/context/base/mkxl/trac-vis.lmt28
10 files changed, 935 insertions, 580 deletions
diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl
index 722ac0f09..a3b960aa0 100644
--- a/tex/context/base/mkxl/cont-new.mkxl
+++ b/tex/context/base/mkxl/cont-new.mkxl
@@ -13,7 +13,7 @@
% \normalend % uncomment this to get the real base runtime
-\newcontextversion{2021.11.11 19:18}
+\newcontextversion{2021.11.13 20:33}
%D This file is loaded at runtime, thereby providing an excellent place for hacks,
%D patches, extensions and new features. There can be local overloads in cont-loc
diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl
index 8d42981fc..b52808856 100644
--- a/tex/context/base/mkxl/context.mkxl
+++ b/tex/context/base/mkxl/context.mkxl
@@ -29,7 +29,7 @@
%D {YYYY.MM.DD HH:MM} format.
\immutable\edef\contextformat {\jobname}
-\immutable\edef\contextversion{2021.11.11 19:18}
+\immutable\edef\contextversion{2021.11.13 20:33}
%overloadmode 1 % check frozen / warning
%overloadmode 2 % check frozen / error
diff --git a/tex/context/base/mkxl/driv-shp.lmt b/tex/context/base/mkxl/driv-shp.lmt
index ace259954..5e3bfd703 100644
--- a/tex/context/base/mkxl/driv-shp.lmt
+++ b/tex/context/base/mkxl/driv-shp.lmt
@@ -165,10 +165,13 @@ local flush_character do
local saved_r = pos_r
pos_r = lefttoright_code
- local data = fontdata[font] -- hm, so why pass data
- local fnt = font
- local fonts = data.fonts
- local siz = (data.parameters.factor or 1)/65536
+ local xoffset = data.xoffset
+ local yoffset = data.yoffset
+
+ local data = fontdata[font] -- offsets etc
+ local fnt = font
+ local fonts = data.fonts
+ local siz = (data.parameters.factor or 1)/65536
-- An alternative where we (here) locally define handlers like this:
--
@@ -182,6 +185,16 @@ local flush_character do
-- work as expected (so we end up in a nesting loop). I remember hitting this somewhat
-- unexpected feature before.
+if xoffset and xoffset ~= 0 then
+ if factor ~= 0 then
+ xoffset = xoffset + xoffset * factor / refactored -- expansion
+ end
+ pos_h = pos_h + xoffset * sx
+end
+if yoffset and yoffset ~= 0 then
+ pos_v = pos_v + yoffset * sy
+end
+
-- we assume resolved fonts: id mandate but maybe also size
local function flushchar(fnt,chr,f,e) -- can't be moved out of the function due to binding locals
@@ -528,14 +541,6 @@ local flush_character do
else
-- kind of messy that we do orientation here and offsets elsewhere .. this might change
local orientation = data.orientation -- 0 (none), 1, 2, 3 or 4 (none)
--- local x = data.xoffset
--- local y = data.yoffset
--- if x then
--- pos_h = pos_h + x * sx
--- end
--- if y then
--- pos_v = pos_v + y * sy
--- end
if orientation and (orientation == 1 or orientation == 3) then
-- we can get weird charactersbox tracing here
pushorientation(orientation,pos_h,pos_v)
diff --git a/tex/context/base/mkxl/good-mth.lmt b/tex/context/base/mkxl/good-mth.lmt
index 033b2cb88..0c8311efe 100644
--- a/tex/context/base/mkxl/good-mth.lmt
+++ b/tex/context/base/mkxl/good-mth.lmt
@@ -26,11 +26,9 @@ local trace_defining = false trackers.register("math.defining", function(
local report_math = logs.reporter("mathematics","initializing")
local nuts = nodes.nuts
-
local setlink = nuts.setlink
local nodepool = nuts.pool
-
local new_kern = nodepool.kern
local new_glyph = nodepool.glyph
local new_hlist = nodepool.hlist
@@ -38,174 +36,6 @@ local new_vlist = nodepool.vlist
local insertnodeafter = nuts.insertafter
-local helpers = fonts.helpers
-local upcommand = helpers.commands.up
-local rightcommand = helpers.commands.right
-local charcommand = helpers.commands.char
-local prependcommands = helpers.prependcommands
-
--- experiment, we have to load the definitions immediately as they precede
--- the definition so they need to be initialized in the typescript
-
-local function withscriptcode(tfmdata,unicode,data,action)
- if type(unicode) == "string" then
- local p, u = match(unicode,"^(.-):(.-)$")
- if u then
- u = tonumber(u)
- if u then
- local slots = fonts.helpers.mathscriptslots(tfmdata,u)
- if slots then
- if p == "*" then
- action(u,data)
- if type(slots) == "number" then
- action(slots,data)
- else
- for i=1,#slots do
- action(slots[i],data)
- end
- end
- else
- p = tonumber(p)
- if p then
- if type(slots) == "number" then
- action(slots,data)
- else
- action(slots[p],data)
- end
- end
- end
- end
- end
- end
- else
- action(unicode,data)
- end
-end
-
-local function finalize(tfmdata,feature,value,...)
--- if tfmdata.mathparameters then -- funny, cambria text has this
- local goodies = tfmdata.goodies
- if goodies then
- local virtualized = mathematics.virtualized
- for i=1,#goodies do
- local goodie = goodies[i]
- local mathematics = goodie.mathematics
- local dimensions = mathematics and mathematics.dimensions
- if dimensions then
- if trace_defining then
- report_math("overloading dimensions in %a @ %p",tfmdata.properties.fullname,tfmdata.parameters.size)
- end
- local characters = tfmdata.characters
- local descriptions = tfmdata.descriptions
- local parameters = tfmdata.parameters
- local factor = parameters.factor
- local hfactor = parameters.hfactor
- local vfactor = parameters.vfactor
- --
- tfmdata.type = "virtual"
- tfmdata.properties.virtualized = true
- --
- local function overloadone(unicode,data)
- local character = characters[unicode]
- if not character then
- local c = virtualized[unicode]
- if c then
- character = characters[c]
- end
- end
- if character then
- local width = data.width
- local height = data.height
- local depth = data.depth
- if trace_defining and (width or height or depth) then
- report_math("overloading dimensions of %C, width %p, height %p, depth %p",
- unicode,width or 0,height or 0,depth or 0)
- end
- if width then character.width = width * hfactor end
- if height then character.height = height * vfactor end
- if depth then character.depth = depth * vfactor end
- --
- local xoffset = data.xoffset
- local yoffset = data.yoffset
- if xoffset == "llx" then
- local d = descriptions[unicode]
- if d then
- xoffset = - d.boundingbox[1]
- character.width = character.width + xoffset * hfactor
- xoffset = rightcommand[xoffset]
- else
- xoffset = nil
- end
- elseif xoffset and xoffset ~= 0 then
- xoffset = rightcommand[xoffset * hfactor]
- else
- xoffset = nil
- end
- if yoffset and yoffset ~= 0 then
- yoffset = upcommand[yoffset * vfactor]
- else
- yoffset = nil
- end
- if xoffset or yoffset then
- local commands = character.commands
- if commands then
- prependcommands(commands,yoffset,xoffset)
- else
--- character.commands = { { "offset", xoffset or 0, yoffset or 0, unicode } }
- local slot = charcommand[unicode]
- if xoffset and yoffset then
- character.commands = { xoffset, yoffset, slot }
- elseif xoffset then
- character.commands = { xoffset, slot }
- else
- character.commands = { yoffset, slot }
- end
- end
- end
- elseif trace_defining then
- report_math("no overloading dimensions of %C, not in font",unicode)
- end
- end
- local function overload(dimensions)
- for unicode, data in next, dimensions do
- withscriptcode(tfmdata,unicode,data,overloadone)
- end
- end
- if value == nil then
- value = { "default" }
- end
- if value == "all" or value == true then
- for name, value in next, dimensions do
- overload(value)
- end
- else
- if type(value) == "string" then
- value = utilities.parsers.settings_to_array(value)
- end
- if type(value) == "table" then
- for i=1,#value do
- local d = dimensions[value[i]]
- if d then
- overload(d)
- end
- end
- end
- end
- end
- end
- end
-end
-
-registerotffeature {
- name = "mathdimensions",
- description = "manipulate math dimensions",
- -- default = true,
- manipulators = {
- base = finalize,
- node = finalize,
- }
-}
-
local function initialize(goodies)
local mathgoodies = goodies.mathematics
if mathgoodies then
@@ -233,122 +63,6 @@ end
fontgoodies.register("mathematics", initialize)
--- local enabled = false directives.register("fontgoodies.mathkerning",function(v) enabled = v end)
-
-local function initialize(tfmdata)
--- if enabled and tfmdata.mathparameters then -- funny, cambria text has this
- if tfmdata.mathparameters then -- funny, cambria text has this
- local goodies = tfmdata.goodies
- if goodies then
- local characters = tfmdata.characters
- if characters[0x1D44E] then -- 119886
- -- we have at least an italic a
- for i=1,#goodies do
- local mathgoodies = goodies[i].mathematics
- if mathgoodies then
- local kerns = mathgoodies.kerns
- if kerns then
- local function kernone(unicode,data)
- local chardata = characters[unicode]
- if chardata and (not chardata.mathkerns or data.force) then
- chardata.mathkerns = data
- end
- end
- for unicode, data in next, kerns do
- withscriptcode(tfmdata,unicode,data,kernone)
- end
- return
- end
- end
- end
- else
- return -- no proper math font anyway
- end
- end
- end
-end
-
-registerotffeature {
- name = "mathkerns",
- description = "math kerns",
- -- default = true,
- initializers = {
- base = initialize,
- node = initialize,
- }
-}
-
--- math italics (not really needed)
---
--- it would be nice to have a \noitalics\font option
-
-local function initialize(tfmdata)
- local goodies = tfmdata.goodies
- if goodies then
- local shared = tfmdata.shared
- for i=1,#goodies do
- local mathgoodies = goodies[i].mathematics
- if mathgoodies then
- local mathitalics = mathgoodies.italics
- if mathitalics then
- local properties = tfmdata.properties
- if properties.setitalics then
- mathitalics = mathitalics[file.nameonly(properties.name)] or mathitalics
- if mathitalics then
- if trace_goodies then
- report_goodies("loading mathitalics for font %a",properties.name)
- end
- local corrections = mathitalics.corrections
- local defaultfactor = mathitalics.defaultfactor
- -- properties.mathitalic_defaultfactor = defaultfactor -- we inherit outer one anyway (name will change)
- if corrections then
- fontgoodies.registerpostprocessor(tfmdata, function(tfmdata) -- this is another tfmdata (a copy)
- -- better make a helper so that we have less code being defined
- local properties = tfmdata.properties
- local parameters = tfmdata.parameters
- local characters = tfmdata.characters
- properties.mathitalic_defaultfactor = defaultfactor
- properties.mathitalic_defaultvalue = defaultfactor * parameters.quad
- if trace_goodies then
- report_goodies("assigning mathitalics for font %a",properties.name)
- end
- local quad = parameters.quad
- local hfactor = parameters.hfactor
- for k, v in next, corrections do
- local c = characters[k]
- if c then
- if v > -1 and v < 1 then
- c.italic = v * quad
- else
- c.italic = v * hfactor
- end
- else
- report_goodies("invalid mathitalics entry %U for font %a",k,properties.name)
- end
- end
- end)
- end
- return -- maybe not as these can accumulate
- end
- end
- end
- end
- end
- end
-end
-
-registerotffeature {
- name = "mathitalics",
- description = "additional math italic corrections",
- -- default = true,
- initializers = {
- base = initialize,
- node = initialize,
- }
-}
-
--- fontgoodies.register("mathitalics", initialize)
-
local function mathradicalaction(n,h,v,font,mchar,echar)
local characters = fontcharacters[font]
local mchardata = characters[mchar]
@@ -471,3 +185,284 @@ registerotffeature {
node = initialize,
}
}
+
+-- local helpers = fonts.helpers
+-- local upcommand = helpers.commands.up
+-- local rightcommand = helpers.commands.right
+-- local charcommand = helpers.commands.char
+-- local prependcommands = helpers.prependcommands
+--
+-- -- experiment, we have to load the definitions immediately as they precede
+-- -- the definition so they need to be initialized in the typescript
+--
+-- local function withscriptcode(tfmdata,unicode,data,action)
+-- if type(unicode) == "string" then
+-- local p, u = match(unicode,"^(.-):(.-)$")
+-- if u then
+-- u = tonumber(u)
+-- if u then
+-- local slots = helpers.mathscriptslots(tfmdata,u)
+-- if slots then
+-- if p == "*" then
+-- action(u,data)
+-- if type(slots) == "number" then
+-- action(slots,data)
+-- else
+-- for i=1,#slots do
+-- action(slots[i],data)
+-- end
+-- end
+-- else
+-- p = tonumber(p)
+-- if p then
+-- if type(slots) == "number" then
+-- action(slots,data)
+-- else
+-- action(slots[p],data)
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- else
+-- action(unicode,data)
+-- end
+-- end
+--
+-- local function finalize(tfmdata,feature,value,...)
+-- -- if tfmdata.mathparameters then -- funny, cambria text has this
+-- local goodies = tfmdata.goodies
+-- if goodies then
+-- local virtualized = mathematics.virtualized
+-- for i=1,#goodies do
+-- local goodie = goodies[i]
+-- local mathematics = goodie.mathematics
+-- local dimensions = mathematics and mathematics.dimensions
+-- if dimensions then
+-- if trace_defining then
+-- report_math("overloading dimensions in %a @ %p",tfmdata.properties.fullname,tfmdata.parameters.size)
+-- end
+-- local characters = tfmdata.characters
+-- local descriptions = tfmdata.descriptions
+-- local parameters = tfmdata.parameters
+-- local factor = parameters.factor
+-- local hfactor = parameters.hfactor
+-- local vfactor = parameters.vfactor
+-- --
+-- tfmdata.type = "virtual"
+-- tfmdata.properties.virtualized = true
+-- --
+-- local function overloadone(unicode,data)
+-- local character = characters[unicode]
+-- if not character then
+-- local c = virtualized[unicode]
+-- if c then
+-- character = characters[c]
+-- end
+-- end
+-- if character then
+-- local width = data.width
+-- local height = data.height
+-- local depth = data.depth
+-- if trace_defining and (width or height or depth) then
+-- report_math("overloading dimensions of %C, width %p, height %p, depth %p",
+-- unicode,width or 0,height or 0,depth or 0)
+-- end
+-- if width then character.width = width * hfactor end
+-- if height then character.height = height * vfactor end
+-- if depth then character.depth = depth * vfactor end
+-- --
+-- local xoffset = data.xoffset
+-- local yoffset = data.yoffset
+-- if xoffset == "llx" then
+-- local d = descriptions[unicode]
+-- if d then
+-- xoffset = - d.boundingbox[1]
+-- character.width = character.width + xoffset * hfactor
+-- xoffset = rightcommand[xoffset]
+-- else
+-- xoffset = nil
+-- end
+-- elseif xoffset and xoffset ~= 0 then
+-- xoffset = rightcommand[xoffset * hfactor]
+-- else
+-- xoffset = nil
+-- end
+-- if yoffset and yoffset ~= 0 then
+-- yoffset = upcommand[yoffset * vfactor]
+-- else
+-- yoffset = nil
+-- end
+-- if xoffset or yoffset then
+-- local commands = character.commands
+-- if commands then
+-- prependcommands(commands,yoffset,xoffset)
+-- else
+-- -- character.commands = { { "offset", xoffset or 0, yoffset or 0, unicode } }
+-- local slot = charcommand[unicode]
+-- if xoffset and yoffset then
+-- character.commands = { xoffset, yoffset, slot }
+-- elseif xoffset then
+-- character.commands = { xoffset, slot }
+-- else
+-- character.commands = { yoffset, slot }
+-- end
+-- end
+-- end
+-- elseif trace_defining then
+-- report_math("no overloading dimensions of %C, not in font",unicode)
+-- end
+-- end
+-- local function overload(dimensions)
+-- for unicode, data in next, dimensions do
+-- withscriptcode(tfmdata,unicode,data,overloadone)
+-- end
+-- end
+-- if value == nil then
+-- value = { "default" }
+-- end
+-- if value == "all" or value == true then
+-- for name, value in next, dimensions do
+-- overload(value)
+-- end
+-- else
+-- if type(value) == "string" then
+-- value = utilities.parsers.settings_to_array(value)
+-- end
+-- if type(value) == "table" then
+-- for i=1,#value do
+-- local d = dimensions[value[i]]
+-- if d then
+-- overload(d)
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+--
+-- registerotffeature {
+-- name = "mathdimensions",
+-- description = "manipulate math dimensions",
+-- -- default = true,
+-- manipulators = {
+-- base = finalize,
+-- node = finalize,
+-- }
+-- }
+
+-- local enabled = false directives.register("fontgoodies.mathkerning",function(v) enabled = v end)
+--
+-- local function initialize(tfmdata)
+-- if tfmdata.mathparameters then -- funny, cambria text has this
+-- local goodies = tfmdata.goodies
+-- if goodies then
+-- local characters = tfmdata.characters
+-- if characters[0x1D44E] then -- 119886
+-- -- we have at least an italic a
+-- for i=1,#goodies do
+-- local mathgoodies = goodies[i].mathematics
+-- if mathgoodies then
+-- local kerns = mathgoodies.kerns
+-- if kerns then
+-- local function kernone(unicode,data)
+-- local chardata = characters[unicode]
+-- if chardata and (not chardata.mathkerns or data.force) then
+-- chardata.mathkerns = data
+-- end
+-- end
+-- for unicode, data in next, kerns do
+-- withscriptcode(tfmdata,unicode,data,kernone)
+-- end
+-- return
+-- end
+-- end
+-- end
+-- else
+-- return -- no proper math font anyway
+-- end
+-- end
+-- end
+-- end
+--
+-- registerotffeature {
+-- name = "mathkerns",
+-- description = "math kerns",
+-- -- default = true,
+-- initializers = {
+-- base = initialize,
+-- node = initialize,
+-- }
+-- }
+
+-- -- math italics (not really needed)
+--
+-- local function initialize(tfmdata)
+-- local goodies = tfmdata.goodies
+-- if goodies then
+-- local shared = tfmdata.shared
+-- for i=1,#goodies do
+-- local mathgoodies = goodies[i].mathematics
+-- if mathgoodies then
+-- local mathitalics = mathgoodies.italics
+-- if mathitalics then
+-- local properties = tfmdata.properties
+-- if properties.setitalics then
+-- mathitalics = mathitalics[file.nameonly(properties.name)] or mathitalics
+-- if mathitalics then
+-- if trace_goodies then
+-- report_goodies("loading mathitalics for font %a",properties.name)
+-- end
+-- local corrections = mathitalics.corrections
+-- local defaultfactor = mathitalics.defaultfactor
+-- -- properties.mathitalic_defaultfactor = defaultfactor -- we inherit outer one anyway (name will change)
+-- if corrections then
+-- fontgoodies.registerpostprocessor(tfmdata, function(tfmdata) -- this is another tfmdata (a copy)
+-- -- better make a helper so that we have less code being defined
+-- local properties = tfmdata.properties
+-- local parameters = tfmdata.parameters
+-- local characters = tfmdata.characters
+-- properties.mathitalic_defaultfactor = defaultfactor
+-- properties.mathitalic_defaultvalue = defaultfactor * parameters.quad
+-- if trace_goodies then
+-- report_goodies("assigning mathitalics for font %a",properties.name)
+-- end
+-- local quad = parameters.quad
+-- local hfactor = parameters.hfactor
+-- for k, v in next, corrections do
+-- local c = characters[k]
+-- if c then
+-- if v > -1 and v < 1 then
+-- c.italic = v * quad
+-- else
+-- c.italic = v * hfactor
+-- end
+-- else
+-- report_goodies("invalid mathitalics entry %U for font %a",k,properties.name)
+-- end
+-- end
+-- end)
+-- end
+-- return -- maybe not as these can accumulate
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+--
+-- registerotffeature {
+-- name = "mathitalics",
+-- description = "additional math italic corrections",
+-- -- default = true,
+-- initializers = {
+-- base = initialize,
+-- node = initialize,
+-- }
+-- }
+--
+-- -- fontgoodies.register("mathitalics", initialize)
diff --git a/tex/context/base/mkxl/lpdf-lmt.lmt b/tex/context/base/mkxl/lpdf-lmt.lmt
index 463cc8352..6e6812d81 100644
--- a/tex/context/base/mkxl/lpdf-lmt.lmt
+++ b/tex/context/base/mkxl/lpdf-lmt.lmt
@@ -260,7 +260,7 @@ function flushers.updatefontstate(font)
end
end
--- helpers
+-- helpers (maybe in collapse mode we have to go %.9N)
local f_cm = formatters["%.6N %.6N %.6N %.6N %.6N %.6N cm"]
local f_tm = formatters["%.6N %.6N %.6N %.6N %.6N %.6N Tm"]
@@ -570,11 +570,15 @@ do
tj_delta = 0
cw = 0
--
+ -- print("setup font",where)
+ --
fs = fontparameters.size * bpfactor
if collapse then
local sc = fs / 10
if f then
- sc = sc * f
+-- sc = sc * f
+sx = sx * f
+sy = sy * f
end
-- kind of special:
if format == "opentype" or format == "type1" then
@@ -587,7 +591,9 @@ do
tmry = tmry * sc
else
if f then
- fs = fs * f
+-- fs = fs * f
+sx = sx * f
+sy = sy * f
end
-- kind of special:
if format == "opentype" or format == "type1" then
@@ -697,22 +703,18 @@ do
flushers.character = function(current,pos_h,pos_v,pos_r,font,char,data,f,e,factor,sx,sy) -- ,naturalwidth,width)
if sx ~= f_x_scale or sy ~= f_y_scale or need_tf or font ~= f_cur or f_pdf ~= f_pdf_cur or fs ~= fs_cur or mode == "page" then
-- if sx ~= f_x_scale or sy ~= f_y_scale or need_tf or font ~= f_cur or f_pdf ~= f_pdf_cur or fs ~= fs_cur then
--- print("f",1)
pdf_goto_textmode()
setup_fontparameters(1,font,factor,f,e,sx,sy) -- too often due to page
set_font()
-- elseif mode == "page" then
--- print("f",4)
-- pdf_goto_textmode()
set_font()
elseif cur_f ~= f then -- when ok move up (maybe no longer needed)
--- print("f",2)
pdf_goto_textmode()
setup_fontparameters(2,font,factor,f,e,sx,sy)
set_font()
-- elseif cur_tmrx ~= tmrx or cur_factor ~= factor or cur_f ~= f or cur_e ~= e then
elseif cur_tmrx ~= tmrx or cur_factor ~= factor or cur_e ~= e then
--- print("f",3)
setup_fontparameters(3,font,factor,f,e,sx,sy)
need_tm = true
end
diff --git a/tex/context/base/mkxl/math-act.lmt b/tex/context/base/mkxl/math-act.lmt
index 56730f2eb..afaf79593 100644
--- a/tex/context/base/mkxl/math-act.lmt
+++ b/tex/context/base/mkxl/math-act.lmt
@@ -12,11 +12,14 @@ if not modules then modules = { } end modules ['math-act'] = {
local type, next = type, next
local fastcopy, insert, remove = table.fastcopy, table.insert, table.remove
local formatters = string.formatters
+local byte = string.byte
local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end)
local trace_collecting = false trackers.register("math.collecting", function(v) trace_collecting = v end)
+local trace_tweaking = false trackers.register("math.tweaks", function(v) trace_tweaking = v end)
local report_math = logs.reporter("mathematics","initializing")
+local report_mathtweak = logs.reporter("mathematics","tweak")
local context = context
local commands = commands
@@ -46,7 +49,7 @@ appendgroup("mathparameters","before") -- user
appendgroup("mathparameters","system") -- private
appendgroup("mathparameters","after" ) -- user
-function fonts.constructors.assignmathparameters(original,target)
+function fonts.constructors.assignmathparameters(original,target) -- wrong way around
local runner = mathfontparameteractions.runner
if runner then
runner(original,target)
@@ -186,62 +189,320 @@ end
local mathtweaks = { }
mathematics.tweaks = mathtweaks
-local function adapt(targetcharacters,originalcharacters,k,v,compact,n)
- local character = targetcharacters[k]
- if character then
- local width = character.width
- local italic = character.italic
- local offsetfactor = v[1] or 1
- local widthfactor = v[2] or 1
- local italicfactor = v[3] or 1
- if width then
- character.advance = width -- so advance is oldwidth
- character.xoffset = offsetfactor * width
- character.width = widthfactor * width
- end
- if italic then
- character.italic = italicfactor * italic
+local function report_tweak(fmt,target,original,...)
+ local metadata = original.shared.rawdata.metadata
+ local parameters = target.parameters
+ report_mathtweak(
+ "%a, size %p, math size %i, %s",
+ metadata and metadata.fontname or "unknown",
+ parameters.size or 655360,
+ parameters.mathsize or 1,
+ string.formatters[fmt](...)
+ )
+end
+
+do
+
+ local stepper = utilities.parsers.stepper
+
+ local function adapt(target,original,targetcharacters,originalcharacters,k,v,compact,n)
+ local character = targetcharacters[k]
+ if character then
+ local width = character.width
+ local italic = character.italic
+ local offsetfactor = v[1] or 1
+ local widthfactor = v[2] or 1
+ local italicfactor = v[3] or 1
+ if width then
+ character.advance = width -- so advance is oldwidth
+ character.xoffset = offsetfactor * width
+ character.width = widthfactor * width
+ end
+ if italic then
+ character.italic = italicfactor * italic
+ elseif width and italicfactor ~= 1 then
+ character.italic = italicfactor * width
+ end
+ if trace_tweaking then
+ report_tweak("adapting dimensions of %U ",target,original,k)
+ end
+ local smaller = originalcharacters[k].smaller
+ if compact and smaller and smaller ~= k then
+ adapt(target,original,targetcharacters,originalcharacters,smaller,v,compact,n+1)
+ end
+ else
+ report_math("no character %U",k)
end
- local smaller = originalcharacters[k].smaller
- if compact and smaller and smaller ~= k then
- adapt(targetcharacters,originalcharacters,smaller,v,compact,n+1)
+ end
+
+ function mathtweaks.dimensions(target,original,parameters)
+ local list = parameters.list
+ if list then
+ local targetcharacters = target.characters
+ local originalcharacters = original.characters
+ local compact = target.parameters.textscale and true or false
+ for k, v in next, list do
+ local t = type(k)
+ if t == "number" then
+ adapt(target,original,targetcharacters,originalcharacters,k,v,compact,1)
+ elseif t == "string" then
+ stepper(k,function(n) adapt(target,original,targetcharacters,originalcharacters,n,v,compact,1) end)
+ end
+ end
end
- else
- report_math("no character %U",k)
end
+
end
-function mathtweaks.dimensions(target,original,list)
- local targetcharacters = target.characters
- local originalcharacters = original.characters
- local compact = target.parameters.textscale and true or false
- for k, v in next, list do
- adapt(targetcharacters,originalcharacters,k,v,compact,1)
+do
+
+ local list = {
+ { 0x2032, true, },
+ { 0x2033, true, 0x2032, 2 },
+ { 0x2034, true, 0x2032, 3 },
+ { 0x2057, true, 0x2032, 4 },
+ { 0x2035, false, },
+ { 0x2036, false, 0x2035, 2 },
+ { 0x2037, false, 0x2035, 3 },
+ }
+
+ local function fix(target,original,characters,factor,scale,newheight,code,mandate)
+ local char = characters[code]
+ if char then
+ local oldheight = scale * char.height
+ char.yoffset = newheight - oldheight
+ char.height = newheight
+ if scale ~= 1 then
+ char.width = scale * char.width
+ char.commands = {
+ { "slot", 0, code, scale }
+ }
+ end
+ if trace_tweaking then
+ report_tweak("fixing prime %U ",target,original,code)
+ end
+ local small = char.smaller
+ if small then
+ fix(target,original,characters,factor,scale,newheight,small,false)
+ end
+ elseif mandate then
+ report_math("missing %U prime in font %a",code,original.properties.fullname)
+ end
+ end
+
+ function mathtweaks.fixprimes(target,original,parameters)
+ local characters = target.characters
+ local factor = parameters.factor or 0.85
+ local scale = parameters.scale or 1
+ local newheight = factor * target.mathparameters.AccentBaseHeight
+ for i=1,#list do
+ local entry = list[i]
+ fix(target,original,characters,factor,scale,newheight,entry[1],entry[2])
+ end
+ end
+
+ local function fake(target,original,characters,factor,n,single,multiple)
+ local csingle = characters[single]
+ local cmultiple = characters[multiple]
+ local width = csingle.width
+ local hoffset = factor * width
+ cmultiple.width = width + (n - 1) * hoffset
+ cmultiple.commands = {
+ { "offset", 0, 0, single },
+ { "offset", hoffset, 0, single },
+ n > 2 and { "offset", 2 * hoffset, 0, single } or nil,
+ n > 3 and { "offset", 3 * hoffset, 0, single } or nil,
+ }
+ if trace_tweaking then
+ report_tweak("faking %U with %i primes",target,original,multiple,n)
+ end
+ local ssingle = csingle.smaller
+ local smultiple = cmultiple.smaller
+ if ssingle and smultiple then
+ fake(target,original,characters,factor,n,ssingle,smultiple)
+ else
+ --weird font
+ end
+ end
+
+ function mathtweaks.fakeprimes(target,original,parameters)
+ local characters = target.characters
+ local factor = parameters.factor or .75
+ for i=1,#list do
+ local entry = list[i]
+ local n = entry[4]
+ if n then
+ fake(target,original,characters,factor,n,entry[3],entry[1])
+ end
+ end
end
+
end
-function mathtweaks.action(target,original,action,...)
+function mathtweaks.action(target,original,parameters)
+ local action = parameters.action
if type(action) == "function" then
- action(target,original,...)
+ action(target,original,parameters)
+ end
+end
+
+do
+
+ local list = {
+ { 0x00A0, "s", 1 }, -- nbsp
+ { 0x2000, "q", 1/2 }, -- enquad
+ { 0x2001, "q", 1 }, -- emquad
+ { 0x2002, "q", 1/2 }, -- enspace
+ { 0x2003, "q", 1 }, -- emspace
+ { 0x2004, "q", 1/3 }, -- threeperemspace
+ { 0x2005, "q", 1/4 }, -- fourperemspace
+ { 0x2006, "q", 1/6 }, -- sixperemspace
+ { 0x2007, "c", byte('0') }, -- figurespace
+ { 0x2008, "c", byte('.') }, -- punctuationspace
+ { 0x2009, "q", 1/8 }, -- breakablethinspace
+ { 0x200A, "q", 1/8 }, -- hairspace
+ { 0x200B, "q", 0 }, -- zerowidthspace
+ { 0x202F, "q", 1/8 }, -- narrownobreakspace
+ { 0x205F, "s", 1/2 }, -- math thinspace
+ }
+
+ function mathtweaks.checkspacing(target,original,parameters)
+ local characters = target.characters
+ local parameters = target.parameters
+ for i=1,#list do
+ local entry = list[i]
+ local unicode = entry[1]
+ local data = characters[unicode]
+ if not data then
+ local method = entry[2]
+ local fraction = entry[3]
+ local width = 0
+ if how == "c" then
+ width = characters[fraction].width -- char
+ elseif how == "s" then
+ width = fraction * parameters.space -- space
+ else
+ width = fraction * parameters.quad -- quad
+ end
+ if trace_tweaking then
+ report_tweak("setting width of %U to %p",target,original,unicode,width)
+ end
+ characters[unicode] = { width = width }
+ end
+ end
end
+
end
+do
-local reported = { }
+ local list = {
+ 0x221A,
+ }
-function mathtweaks.version(target,original,expected)
- local metadata = original.shared.rawdata.metadata
- if metadata then
- local version = metadata.version
- if version then
- local fontname = metadata.fontname
- -- version = tonumber(string.match(version,"%d+.%d+"))
- if not reported[fontname] and version ~= expected then
- report_math("tweaking %a, version %a found, version %a expected",fontname,version,expected)
- reported[fontname] = true
+ local function fix(target,original,characters,unicode)
+ local data = characters[unicode]
+ if data then
+ local height = data.height or 0
+ local depth = data.depth or 0
+ if depth > height then
+ if trace_tweaking then
+ report_tweak("swapping height and depth of radical %U",target,original,unicode)
+ end
+ data.height = depth
+ data.depth = height
+ data.yoffset = depth - height
end
+ local small = data.smaller
+ if small then
+ fix(target,original,characters,small)
+ end
+ end
+ end
+
+ function mathtweaks.fixradicals(target,original,parameters)
+ local characters = target.characters
+ for i=1,#list do
+ local unicode = list[i]
+ fix(target,original,characters,unicode)
end
end
+
+end
+
+do
+
+ -- For Ton, who needs the high minus and plus for calculator signs in Dutch
+ -- school math books.
+
+ local list = {
+ { 0x207A, 0x002B, true },
+ { 0x207B, 0x2212, true },
+ { 0x208A, 0x002B, false },
+ { 0x208B, 0x2212, false },
+ }
+
+ local function add(target,original,characters,unicode,template,super,baseheight,scale)
+ if not characters[unicode] then
+ local origdata = characters[template]
+ if origdata then
+ local width = scale * (origdata.width or 0)
+ local height = scale * (origdata.height or 0)
+ local depth = scale * (origdata.depth or 0)
+ local half = - (height + depth) / 2
+ local offset = super and baseheight/2 or -baseheight/4
+ characters[unicode] = {
+ width = width,
+ height = height + offset,
+ depth = depth - offset,
+ yoffset = offset,
+ unicode = unicode,
+ -- index = origdata.index,
+ -- scale = scale,
+ commands = {
+ -- { "up", yoffset },
+ { "slot", 0, template, scale }
+ },
+ }
+ if trace_tweaking then
+ report_tweak("adding script %U scaled %0.3f",target,original,unicode,scale)
+ end
+ -- no need for smaller
+ end
+ end
+ end
+
+ function mathtweaks.addscripts(target,original,parameters)
+ local characters = target.characters
+ local baseheight = target.mathparameters.AccentBaseHeight
+ local scaledown = parameters.scale or target.mathparameters.ScriptScriptPercentScaleDown / 100
+ for i=1,#list do
+ local entry = list[i]
+ if entry then
+ add(target,original,characters,entry[1],entry[2],entry[3],baseheight,scaledown)
+ end
+ end
+ end
+
+end
+
+do
+
+ function mathtweaks.version(target,original,parameters)
+ local metadata = original.shared.rawdata.metadata
+ if metadata then
+ local version = metadata.version
+ if version then
+ local expected = parameters.expected
+ -- version = tonumber(string.match(version,"%d+.%d+"))
+ if version ~= expected then
+ report_tweak("version %a found, version %a expected",target,original,version,expected)
+ reported[fontname] = true
+ end
+ end
+ end
+ end
+
end
local function applytweaks(when,target,original)
@@ -260,16 +521,10 @@ local function applytweaks(when,target,original)
for i=1,#tweaks do
local tweak = tweaks[i]
local tvalue = type(tweak)
- if tvalue == "function" then
- -- old
- tweak(target,original)
- elseif tvalue == "table" then
- local command = tweak[1]
- if type(command) == "string" then
- local action = mathtweaks[command]
- if action then
- action(target,original,table.unpack(tweak,2))
- end
+ if type(tweak) == "table" then
+ local action = mathtweaks[tweak.tweak or ""]
+ if action then
+ action(target,original,tweak)
end
end
end
diff --git a/tex/context/base/mkxl/math-fbk.lmt b/tex/context/base/mkxl/math-fbk.lmt
index 4c58a2bb6..32ad909f7 100644
--- a/tex/context/base/mkxl/math-fbk.lmt
+++ b/tex/context/base/mkxl/math-fbk.lmt
@@ -7,7 +7,8 @@ if not modules then modules = { } end modules ['math-fbk'] = {
}
-- This will partly be redone and go via definitions in goodies where we can share
--- some across fonts.
+-- some across fonts. That makes most sense for those patches that might need some
+-- finetuning depending on the font.
local next, type = next, type
@@ -169,71 +170,6 @@ end
-- a few examples:
-local function reference(index,char)
- if index then
- return { "slot", index, char }
- else
- return charcommand[char]
- end
-end
-
-local function raised(data,replacement,down)
- 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],
- reference(data.scriptindex,replacement)
- }
- }
- end
-end
-
--- virtualcharacters[0x207A] = 0x2212
--- virtualcharacters[0x207B] = 0x002B
--- 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
-
--- 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 commands = { }
--- for i=1,n-1 do
--- width = width + delta
--- commands[#commands+1] = c
--- commands[#commands+1] = -delta
--- end
--- commands[#commands+1] = c
--- return {
--- width = width,
--- height = character.height,
--- depth = character.depth,
--- commands = commands,
--- }
--- end
--- end
-
--- virtualcharacters[0x222C] = function(data)
--- return repeated(data,0x222B,2,1/8)
--- end
-
--- virtualcharacters[0x222D] = function(data)
--- return repeated(data,0x222B,3,1/8)
--- end
-
local addextra = mathematics.extras.add
addextra(0xFE350) -- MATHEMATICAL DOUBLE ARROW LEFT END
@@ -310,8 +246,6 @@ virtualcharacters[0xFE352] = function(data)
end
end
--- we could move the defs from math-act here
-
local function accent_to_extensible(target,newchr,original,oldchr,height,depth,swap,offset,unicode)
local characters = target.characters
local olddata = characters[oldchr]
@@ -422,53 +356,6 @@ virtualcharacters[0xFE33F] = function(data)
return accent_to_extensible(target,0xFE33F,data.original,0x0305,height,depth,nil,nil,0x203E)
end
--- spacing (no need for a cache of widths)
-
-local c_zero = byte('0')
-local c_period = byte('.')
-
-local function spacefraction(data,fraction)
- local width = fraction * data.target.parameters.space
- return {
- width = width,
- commands = { rightcommand[width] }
- }
-end
-
-local function charfraction(data,char)
- local width = data.target.characters[char].width
- return {
- width = width,
- commands = { rightcommand[width] }
- }
-end
-
-local function quadfraction(data,fraction)
- local width = fraction * data.target.parameters.quad
- return {
- width = width,
- commands = { rightcommand[width] }
- }
-end
-
-virtualcharacters[0x00A0] = function(data) return spacefraction(data,1) end -- nbsp
-virtualcharacters[0x2000] = function(data) return quadfraction (data,1/2) end -- enquad
-virtualcharacters[0x2001] = function(data) return quadfraction (data,1) end -- emquad
-virtualcharacters[0x2002] = function(data) return quadfraction (data,1/2) end -- enspace
-virtualcharacters[0x2003] = function(data) return quadfraction (data,1) end -- emspace
-virtualcharacters[0x2004] = function(data) return quadfraction (data,1/3) end -- threeperemspace
-virtualcharacters[0x2005] = function(data) return quadfraction (data,1/4) end -- fourperemspace
-virtualcharacters[0x2006] = function(data) return quadfraction (data,1/6) end -- sixperemspace
-virtualcharacters[0x2007] = function(data) return charfraction (data,c_zero) end -- figurespace
-virtualcharacters[0x2008] = function(data) return charfraction (data,c_period) end -- punctuationspace
-virtualcharacters[0x2009] = function(data) return quadfraction (data,1/8) end -- breakablethinspace
-virtualcharacters[0x200A] = function(data) return quadfraction (data,1/8) end -- hairspace
-virtualcharacters[0x200B] = function(data) return quadfraction (data,0) end -- zerowidthspace
-virtualcharacters[0x202F] = function(data) return quadfraction (data,1/8) end -- narrownobreakspace
-virtualcharacters[0x205F] = function(data) return spacefraction(data,1/2) end -- math thinspace
-
---
-
local function smashed(data,unicode,swap,private)
local target = data.target
local original = data.original
@@ -514,73 +401,250 @@ end
virtualcharacters[0xFE302] = function(data) return smashed(data,0x0302,0xFE302) end
virtualcharacters[0xFE303] = function(data) return smashed(data,0x0303,0xFE303) end
--- another crazy hack .. doesn't work as we define scrscr first .. we now have smaller
--- primes so we have smaller primes for the moment, big ones will become an option ..
--- these primes in fonts are a real mess .. kind of a dead end, so don't wonder about
--- the values below
-
-local function smashed(data,unicode,optional)
- local oldchar = data.characters[unicode]
- if oldchar then
- local height = 0.85 * data.target.mathparameters.AccentBaseHeight
- local newchar = table.copy(oldchar)
- newchar.yoffset = height - oldchar.height
- newchar.height = height
- return newchar
- elseif not optional then
- report_fallbacks("missing %U prime in font %a",unicode,data.target.properties.fullname)
- end
-end
+---------------------------------------------------------------------------------
+-- these are moved to math-act.lmt
+---------------------------------------------------------------------------------
-addextra(0xFE932) -- SMASHED PRIME 0x02032
-addextra(0xFE933) -- SMASHED PRIME 0x02033
-addextra(0xFE934) -- SMASHED PRIME 0x02034
-addextra(0xFE957) -- SMASHED PRIME 0x02057
-
-addextra(0xFE935) -- SMASHED BACKWARD PRIME 0x02035
-addextra(0xFE936) -- SMASHED BACKWARD PRIME 0x02036
-addextra(0xFE937) -- SMASHED BACKWARD PRIME 0x02037
-
-virtualcharacters[0xFE932] = function(data) return smashed(data,0x02032) end
-virtualcharacters[0xFE933] = function(data) return smashed(data,0x02033) end
-virtualcharacters[0xFE934] = function(data) return smashed(data,0x02034) end
-virtualcharacters[0xFE957] = function(data) return smashed(data,0x02057) end
-
-virtualcharacters[0xFE935] = function(data) return smashed(data,0x02035,true) end
-virtualcharacters[0xFE936] = function(data) return smashed(data,0x02036,true) end
-virtualcharacters[0xFE937] = function(data) return smashed(data,0x02037,true) end
-
-local hack = nil
-
-function mathematics.getridofprime(target,original)
--- local mathsize = specification.mathsize
--- if mathsize == 1 or mathsize == 2 or mathsize == 3) then
- local mathparameters = original.mathparameters
- if mathparameters and next(mathparameters) then
- local changed = original.changed
- if changed then
- hack = changed[0x02032]
- changed[0x02032] = nil
- changed[0x02033] = nil
- changed[0x02034] = nil
- changed[0x02057] = nil
- changed[0x02035] = nil
- changed[0x02036] = nil
- changed[0x02037] = nil
- end
- end
-end
+-- local function reference(index,char)
+-- if index then
+-- return { "slot", index, char }
+-- else
+-- return charcommand[char]
+-- end
+-- end
+--
+-- local function raised(data,replacement,down)
+-- 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],
+-- reference(data.scriptindex,replacement)
+-- }
+-- }
+-- end
+-- end
+--
+-- 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
-function mathematics.setridofprime(target,original)
- local mathparameters = original.mathparameters
- if mathparameters and next(mathparameters) and original.changed then
- target.characters[0xFE931] = target.characters[hack or 0x2032]
- hack = nil
- end
-end
+---------------------------------------------------------------------------------
+-- these are moved to math-act.lmt
+---------------------------------------------------------------------------------
-utilities.sequencers.appendaction("beforecopyingcharacters","system","mathematics.getridofprime")
-utilities.sequencers.appendaction("aftercopyingcharacters", "system","mathematics.setridofprime")
+-- 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 commands = { }
+-- for i=1,n-1 do
+-- width = width + delta
+-- commands[#commands+1] = c
+-- commands[#commands+1] = -delta
+-- end
+-- commands[#commands+1] = c
+-- return {
+-- width = width,
+-- height = character.height,
+-- depth = character.depth,
+-- commands = commands,
+-- }
+-- end
+-- end
+--
+-- virtualcharacters[0x222C] = function(data)
+-- return repeated(data,0x222B,2,1/8)
+-- end
+--
+-- virtualcharacters[0x222D] = function(data)
+-- return repeated(data,0x222B,3,1/8)
+-- end
+
+---------------------------------------------------------------------------------
+-- these are moved to math-act.lmt
+---------------------------------------------------------------------------------
+
+-- -- spacing (no need for a cache of widths)
+--
+-- local c_zero = byte('0')
+-- local c_period = byte('.')
+--
+-- local function spacefraction(data,fraction)
+-- local width = fraction * data.target.parameters.space
+-- return {
+-- width = width,
+-- -- commands = { rightcommand[width] }
+-- }
+-- end
+--
+-- local function charfraction(data,char)
+-- local width = data.target.characters[char].width
+-- return {
+-- width = width,
+-- -- commands = { rightcommand[width] }
+-- }
+-- end
+--
+-- local function quadfraction(data,fraction)
+-- local width = fraction * data.target.parameters.quad
+-- return {
+-- width = width,
+-- -- commands = { rightcommand[width] }
+-- }
+-- end
+--
+-- virtualcharacters[0x00A0] = function(data) return spacefraction(data,1) end -- nbsp
+-- virtualcharacters[0x2000] = function(data) return quadfraction (data,1/2) end -- enquad
+-- virtualcharacters[0x2001] = function(data) return quadfraction (data,1) end -- emquad
+-- virtualcharacters[0x2002] = function(data) return quadfraction (data,1/2) end -- enspace
+-- virtualcharacters[0x2003] = function(data) return quadfraction (data,1) end -- emspace
+-- virtualcharacters[0x2004] = function(data) return quadfraction (data,1/3) end -- threeperemspace
+-- virtualcharacters[0x2005] = function(data) return quadfraction (data,1/4) end -- fourperemspace
+-- virtualcharacters[0x2006] = function(data) return quadfraction (data,1/6) end -- sixperemspace
+-- virtualcharacters[0x2007] = function(data) return charfraction (data,c_zero) end -- figurespace
+-- virtualcharacters[0x2008] = function(data) return charfraction (data,c_period) end -- punctuationspace
+-- virtualcharacters[0x2009] = function(data) return quadfraction (data,1/8) end -- breakablethinspace
+-- virtualcharacters[0x200A] = function(data) return quadfraction (data,1/8) end -- hairspace
+-- virtualcharacters[0x200B] = function(data) return quadfraction (data,0) end -- zerowidthspace
+-- virtualcharacters[0x202F] = function(data) return quadfraction (data,1/8) end -- narrownobreakspace
+-- virtualcharacters[0x205F] = function(data) return spacefraction(data,1/2) end -- math thinspace
+
+-- -- another crazy hack .. doesn't work as we define scrscr first .. we now have smaller
+-- -- primes so we have smaller primes for the moment, big ones will become an option ..
+-- -- these primes in fonts are a real mess .. kind of a dead end, so don't wonder about
+-- -- the values below
+--
+-- local function smashed(data,unicode,optional)
+-- local oldchar = data.characters[unicode]
+-- if oldchar then
+-- local height = 0.85 * data.target.mathparameters.AccentBaseHeight
+-- local newchar = table.copy(oldchar)
+-- newchar.yoffset = height - oldchar.height
+-- newchar.height = height
+-- return newchar
+-- elseif not optional then
+-- report_fallbacks("missing %U prime in font %a",unicode,data.target.properties.fullname)
+-- end
+-- end
+--
+-- addextra(0xFE932) -- SMASHED PRIME 0x02032
+-- addextra(0xFE933) -- SMASHED PRIME 0x02033
+-- addextra(0xFE934) -- SMASHED PRIME 0x02034
+-- addextra(0xFE957) -- SMASHED PRIME 0x02057
+--
+-- addextra(0xFE935) -- SMASHED BACKWARD PRIME 0x02035
+-- addextra(0xFE936) -- SMASHED BACKWARD PRIME 0x02036
+-- addextra(0xFE937) -- SMASHED BACKWARD PRIME 0x02037
+--
+-- virtualcharacters[0xFE932] = function(data) return smashed(data,0x02032) end
+-- virtualcharacters[0xFE933] = function(data) return smashed(data,0x02033) end
+-- virtualcharacters[0xFE934] = function(data) return smashed(data,0x02034) end
+-- virtualcharacters[0xFE957] = function(data) return smashed(data,0x02057) end
+--
+-- virtualcharacters[0xFE935] = function(data) return smashed(data,0x02035,true) end
+-- virtualcharacters[0xFE936] = function(data) return smashed(data,0x02036,true) end
+-- virtualcharacters[0xFE937] = function(data) return smashed(data,0x02037,true) end
+--
+-- local hack = nil
+--
+-- function mathematics.getridofprime(target,original)
+-- local mathparameters = original.mathparameters
+-- if mathparameters and next(mathparameters) then
+-- local changed = original.changed
+-- if changed then
+-- hack = changed[0x02032]
+-- changed[0x02032] = nil
+-- changed[0x02033] = nil
+-- changed[0x02034] = nil
+-- changed[0x02057] = nil
+-- changed[0x02035] = nil
+-- changed[0x02036] = nil
+-- changed[0x02037] = nil
+-- end
+-- end
+-- end
+--
+-- function mathematics.setridofprime(target,original)
+-- local mathparameters = original.mathparameters
+-- if mathparameters and next(mathparameters) and original.changed then
+-- target.characters[0xFE931] = target.characters[hack or 0x2032]
+-- hack = nil
+-- end
+-- end
+--
+-- utilities.sequencers.appendaction("beforecopyingcharacters","system","mathematics.getridofprime")
+-- utilities.sequencers.appendaction("aftercopyingcharacters", "system","mathematics.setridofprime")
+
+-- local list = {
+-- { 0x02032, true },
+-- { 0x02033, true },
+-- { 0x02034, true },
+-- { 0x02057, true },
+-- { 0x02035, false },
+-- { 0x02036, false },
+-- { 0x02037, false },
+-- }
+--
+-- function mathematics.fixprimes(target,original)
+-- local mathparameters = original.mathparameters
+-- if mathparameters and next(mathparameters) then
+-- for i=1,#list do
+-- local entry = list[i]
+-- local char = original.characters[entry[1]]
+-- if char then
+-- local height = 0.85 * orginal.mathparameters.AccentBaseHeight
+-- char.yoffset = height - char.height
+-- char.height = height
+-- return char
+-- elseif entry[1] then
+-- report_fallbacks("missing %U prime in font %a",unicode,original.properties.fullname)
+-- end
+-- end
+-- end
+-- end
+--
+-- utilities.sequencers.appendaction("beforecopyingcharacters","system","mathematics.fixprimes")
+
+---------------------------------------------------------------------------------
+-- this one is not used
+---------------------------------------------------------------------------------
+
+-- addextra(0xFE941) -- EXTREMELY IDENTICAL TO
+--
+-- virtualcharacters[0xFE941] = function(data) -- this character is only needed for mathpairs
+-- local characters = data.target.characters
+-- local parameters = data.target.parameters
+-- local basechar = characters[0x003D]
+-- local width = basechar.width or 0
+-- local height = basechar.height or 0
+-- local depth = basechar.depth or 0
+-- return {
+-- unicode = 0xFE941,
+-- width = width,
+-- 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],
+-- },
+-- }
+-- end
+
+---------------------------------------------------------------------------------
+-- these might move to math-act.lmt
+---------------------------------------------------------------------------------
-- actuarian (beware: xits has an ugly one)
@@ -638,31 +702,9 @@ virtualcharacters[0x2A75] = function(data) return equals(data,0x2A75,0x003D, 1/5
virtualcharacters[0x2A76] = function(data) return equals(data,0x2A76,0x003D, 1/5,3) end -- ===
virtualcharacters[0x2980] = function(data) return equals(data,0x2980,0x007C,-1/8,3) end -- |||
--- addextra(0xFE941) -- EXTREMELY IDENTICAL TO
---
--- virtualcharacters[0xFE941] = function(data) -- this character is only needed for mathpairs
--- local characters = data.target.characters
--- local parameters = data.target.parameters
--- local basechar = characters[0x003D]
--- local width = basechar.width or 0
--- local height = basechar.height or 0
--- local depth = basechar.depth or 0
--- return {
--- unicode = 0xFE941,
--- width = width,
--- 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],
--- },
--- }
--- end
-
--- lucida needs this
+---------------------------------------------------------------------------------
+-- these might move to math-act.lmt -- lucida needs this
+---------------------------------------------------------------------------------
virtualcharacters[0x305] = function(data)
local target = data.target
@@ -693,6 +735,10 @@ virtualcharacters[0x305] = function(data)
}
end
+---------------------------------------------------------------------------------
+-- these might move to math-act.lmt
+---------------------------------------------------------------------------------
+
local function threedots(data,shift)
local characters = data.target.characters
local parameters = data.target.parameters
diff --git a/tex/context/base/mkxl/math-noa.lmt b/tex/context/base/mkxl/math-noa.lmt
index 5ac095fd3..025333699 100644
--- a/tex/context/base/mkxl/math-noa.lmt
+++ b/tex/context/base/mkxl/math-noa.lmt
@@ -1927,20 +1927,32 @@ do
-- inner under over vcenter
local fixscripts = { }
+-- local movesub = {
+-- -- primes
+-- [0x2032] = 0xFE932,
+-- [0x2033] = 0xFE933,
+-- [0x2034] = 0xFE934,
+-- [0x2057] = 0xFE957,
+-- -- reverse primes
+-- [0x2035] = 0xFE935,
+-- [0x2036] = 0xFE936,
+-- [0x2037] = 0xFE937,
+-- }
+--
+-- mathematics.virtualize(movesub)
+
local movesub = {
-- primes
- [0x2032] = 0xFE932,
- [0x2033] = 0xFE933,
- [0x2034] = 0xFE934,
- [0x2057] = 0xFE957,
+ [0x2032] = 0x2032,
+ [0x2033] = 0x2033,
+ [0x2034] = 0x2034,
+ [0x2057] = 0x2057,
-- reverse primes
- [0x2035] = 0xFE935,
- [0x2036] = 0xFE936,
- [0x2037] = 0xFE937,
+ [0x2035] = 0x2035,
+ [0x2036] = 0x2036,
+ [0x2037] = 0x2037,
}
- mathematics.virtualize(movesub)
-
local nosuperscript_code = tex.mathoptioncodes.nosuperscript
local function fixsupscript(parent,current,current_char,new_char)
diff --git a/tex/context/base/mkxl/strc-syn.mkxl b/tex/context/base/mkxl/strc-syn.mkxl
index c6a62e607..e6081d0d9 100644
--- a/tex/context/base/mkxl/strc-syn.mkxl
+++ b/tex/context/base/mkxl/strc-syn.mkxl
@@ -101,6 +101,31 @@
%D
%D The lists are constructions (like descriptions are) and can be set up
%D likewise.
+%D
+%D You can show the currently accessed entries as follows:
+%D
+%D \starttyping
+%D \startchapter[title=One]
+%D test \FIRST\ test test \THIRD\ test \blank
+%D \placelistofsynonyms[myabbreviation]
+%D \resetsynonymsprogress[myabbreviation] % reset state
+%D \stopchapter
+%D
+%D \startchapter[title=Two]
+%D test \FIRST\ test test \SECOND\ test \blank
+%D \placelistofsynonyms[myabbreviation][criterium=current]
+%D \resetsynonymsprogress[myabbreviation] % reset state
+%D \stopchapter
+%D
+%D \startchapter[title=Three]
+%D test test test test test test \blank
+%D \placelistofsynonyms[myabbreviation][criterium=current] % also reset state
+%D \stopchapter
+%D
+%D \startchapter[title=All]
+%D \placelistofsynonyms[myabbreviation][criterium=all]
+%D \stopchapter
+%D \stoptyping
% todo: add 'define only' option to descriptions, then add sorting (also based on key)
% and call to definition -> replaces this module
@@ -339,8 +364,11 @@
\permanent \protected\def\currentsynonymmeaning {\clf_synonymmeaning{\currentsimplelist}{\currentsynonymtag}}
\permanent \protected\def\doifelsecurrentsynonymused {\clf_doifelsesynonymused{\currentsimplelist}{\currentsynonymtag}}
\permanent \protected\def\doifelsecurrentsynonymshown{\clf_doifelsesynonymshown{\currentsimplelist}{\currentsynonymtag}}
-\permanent \protected\def\resetusedsynonyms [#1]{\clf_resetusedsynonyms{#1}}
-\permanent \protected\def\resetshownsynonyms [#1]{\clf_resetshownsynonyms{#1}}
+\permanent \protected\def\resetusedsynonyms [#1]{\clf_resetsynonyms{#1}{used}}
+\permanent \protected\def\resetshownsynonyms [#1]{\clf_resetsynonyms{#1}{shown}}
+\permanent \protected\def\resetlistsynonyms [#1]{\clf_resetsynonyms{#1}{list}}
+\permanent \protected\def\resetsynonyms [#1]{\clf_resetsynonyms{#1}{all}}
+\permanent \protected\def\resetsynonymsprogress [#1]{\clf_resetsynonyms{#1}{progress}}
\aliased\let\rawsynonymname \clf_synonymname
\aliased\let\rawsynonymmeaning\clf_synonymmeaning
diff --git a/tex/context/base/mkxl/trac-vis.lmt b/tex/context/base/mkxl/trac-vis.lmt
index aa599485c..d08f3c282 100644
--- a/tex/context/base/mkxl/trac-vis.lmt
+++ b/tex/context/base/mkxl/trac-vis.lmt
@@ -147,7 +147,7 @@ local modes = {
visualizers.modes = modes
local usedfont, exheight, emwidth
-local l_penalty, l_glue, l_kern, l_fontkern, l_hbox, l_vbox, l_vtop, l_strut, l_whatsit, l_glyph, l_user, l_math, l_marginkern, l_mathkern, l_italic, l_origin, l_discretionary, l_expansion, l_line, l_space, l_depth,
+local l_penalty, l_glue, l_kern, l_fontkern, l_hbox, l_vbox, l_vtop, l_strut, l_whatsit, l_glyph, l_user, l_math, l_marginkern, l_mathkern, l_mathshape, l_italic, l_origin, l_discretionary, l_expansion, l_line, l_space, l_depth,
l_dir, l_whatsit, l_mark, l_insert
local enabled = false
@@ -207,6 +207,7 @@ local function initialize()
l_italic = layers.italic
l_marginkern = layers.marginkern
l_mathkern = layers.mathkern
+ l_mathshapekern = layers.mathshapekern
l_origin = layers.origin
l_discretionary = layers.discretionary
l_expansion = layers.expansion
@@ -432,6 +433,7 @@ local fontkern, italickern, marginkern, mathkern do
local f_cache = caches["fontkern"]
local i_cache = caches["italickern"]
+ local s_cache = caches["shapekern"]
local m_cache = caches["marginkern"]
local l_cache = caches["mathkern"]
@@ -471,6 +473,10 @@ local fontkern, italickern, marginkern, mathkern do
return somekern(head,current,i_cache,"trace:do",l_italic)
end
+ mathshapekern = function(head,current)
+ return somekern(head,current,s_cache,"trace:do",l_mathshapekern)
+ end
+
marginkern = function(head,current)
return somekern(head,current,m_cache,"trace:do",l_marginkern)
end
@@ -1214,11 +1220,10 @@ local ruledmathkern do
local h_cache = caches["horizontalmathkern"]
local v_cache = caches["verticalmathkern"]
- ruledmathkern = function(head,current,subtype)
- local kern = getkern(current)
- local vertical = subtype == verticalmathkern_code
- local cache = vertical and v_cache or h_cache
- local info = cache[kern]
+ ruledmathkern = function(head,current,vertical)
+ local kern = getkern(current)
+ local cache = vertical and v_cache or h_cache
+ local info = cache[kern]
if not info then
local amount = formatters["%s:%0.3f"](vertical and "MV" or "MH",kern*pt_factor)
if kern > 0 then
@@ -1321,6 +1326,7 @@ do
local italickern_code = kerncodes.italiccorrection
local leftmarginkern_code = kerncodes.leftmarginkern
local rightmarginkern_code = kerncodes.rightmarginkern
+ local mathshapekern_code = kerncodes.mathshapekern
local horizontalmathkern_code = kerncodes.horizontalmathkern
local verticalmathkern_code = kerncodes.verticalmathkern
----- userkern_code = kerncodes.userkern
@@ -1560,13 +1566,19 @@ do
end
elseif subtype == verticalmathkern_code then
if trace_mathkern or trace_kern then
- head, current = ruledmathkern(head,current,subtype)
+ head, current = ruledmathkern(head,current,true)
end
elseif subtype == horizontalmathkern_code then
if trace_mathkern then
head, current = mathkern(head,current)
elseif trace_kern then
- head, current = ruledmathkern(head,current,subtype)
+ head, current = ruledmathkern(head,current,false)
+ end
+ elseif subtype == mathshapekern_code then
+ if trace_mathkern or trace_italic then
+ head, current = mathshapekern(head,current)
+ elseif trace_kern then
+ head, current = ruledmathkern(head,current,false)
end
else
if trace_kern then