diff options
author | Hans Hagen <pragma@wxs.nl> | 2022-10-21 21:37:10 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2022-10-21 21:37:10 +0200 |
commit | 5d31142615a7efaf833be860e412995b42bf9c3c (patch) | |
tree | f2c6470f09089ef3005659783b834989ee7e1989 /tex/context/base | |
parent | c0c1dea1daf21f2c21f6d8094f54f67138998baf (diff) | |
download | context-5d31142615a7efaf833be860e412995b42bf9c3c.tar.gz |
2022-10-21 21:13:00
Diffstat (limited to 'tex/context/base')
43 files changed, 1297 insertions, 1182 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index e1de3bd24..506b3f703 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2022.10.15 10:32} +\newcontextversion{2022.10.21 21:11} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 85524aa83..828709ead 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2022.10.15 10:32} +\edef\contextversion{2022.10.21 21:11} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-cs.mkii b/tex/context/base/mkii/mult-cs.mkii index b5e93a66c..8f5571627 100644 --- a/tex/context/base/mkii/mult-cs.mkii +++ b/tex/context/base/mkii/mult-cs.mkii @@ -93,7 +93,6 @@ \setinterfacevariable{author}{autor} \setinterfacevariable{auto}{auto} \setinterfacevariable{autointro}{autouvod} -\setinterfacevariable{autopunctuation}{autopunctuation} \setinterfacevariable{back}{zpet} \setinterfacevariable{background}{pozadi} \setinterfacevariable{backmatter}{epilogy} @@ -677,9 +676,13 @@ \setinterfaceconstant{authoretaltext}{authoretaltext} \setinterfaceconstant{auto}{auto} \setinterfaceconstant{autocase}{autocase} +\setinterfaceconstant{autofencing}{autofencing} \setinterfaceconstant{autofile}{autofile} \setinterfaceconstant{autofocus}{autoostreni} \setinterfaceconstant{autohang}{autohang} +\setinterfaceconstant{autonumbers}{autonumbers} +\setinterfaceconstant{autopunctuation}{autopunctuation} +\setinterfaceconstant{autospacing}{autospacing} \setinterfaceconstant{autostrut}{autostrut} \setinterfaceconstant{autowidth}{autosirka} \setinterfaceconstant{availableheight}{availableheight} diff --git a/tex/context/base/mkii/mult-it.mkii b/tex/context/base/mkii/mult-it.mkii index 18840146a..cb91a058e 100644 --- a/tex/context/base/mkii/mult-it.mkii +++ b/tex/context/base/mkii/mult-it.mkii @@ -676,6 +676,7 @@ \setinterfaceconstant{authoretaltext}{authoretaltext} \setinterfaceconstant{auto}{auto} \setinterfaceconstant{autocase}{autocase} +\setinterfaceconstant{autofencing}{autofencing} \setinterfaceconstant{autofile}{autofile} \setinterfaceconstant{autofocus}{autofocus} \setinterfaceconstant{autohang}{autohang} diff --git a/tex/context/base/mkiv/char-ini.lua b/tex/context/base/mkiv/char-ini.lua index 4deb21401..6fe56a062 100644 --- a/tex/context/base/mkiv/char-ini.lua +++ b/tex/context/base/mkiv/char-ini.lua @@ -406,24 +406,24 @@ local blocks = allocate { ["lisusupplement"] = { first = 0x11FB0, last = 0x11FBF, description = "Lisu Supplement" }, ["lowercasebold"] = { first = 0x1D41A, last = 0x1D433, math = true }, ["lowercaseboldfraktur"] = { first = 0x1D586, last = 0x1D59F, math = true }, - ["lowercasebolditalic"] = { first = 0x1D482, last = 0x1D49B, math = true }, - ["lowercaseboldscript"] = { first = 0x1D4EA, last = 0x1D503, math = true }, + ["lowercasebolditalic"] = { first = 0x1D482, last = 0x1D49B, math = true, italic = true }, + ["lowercaseboldscript"] = { first = 0x1D4EA, last = 0x1D503, math = true, italic = true }, ["lowercasedoublestruck"] = { first = 0x1D552, last = 0x1D56B, math = true }, ["lowercasefraktur"] = { first = 0x1D51E, last = 0x1D537, math = true }, ["lowercasegreekbold"] = { first = 0x1D6C2, last = 0x1D6DB, math = true }, - ["lowercasegreekbolditalic"] = { first = 0x1D736, last = 0x1D74F, math = true }, - ["lowercasegreekitalic"] = { first = 0x1D6FC, last = 0x1D715, math = true }, + ["lowercasegreekbolditalic"] = { first = 0x1D736, last = 0x1D74F, math = true, italic = true }, + ["lowercasegreekitalic"] = { first = 0x1D6FC, last = 0x1D715, math = true, italic = true }, ["lowercasegreeknormal"] = { first = 0x003B1, last = 0x003C9, math = true }, ["lowercasegreeksansserifbold"] = { first = 0x1D770, last = 0x1D789, math = true }, - ["lowercasegreeksansserifbolditalic"] = { first = 0x1D7AA, last = 0x1D7C3, math = true }, - ["lowercaseitalic"] = { first = 0x1D44E, last = 0x1D467, math = true }, + ["lowercasegreeksansserifbolditalic"] = { first = 0x1D7AA, last = 0x1D7C3, math = true, italic = true }, + ["lowercaseitalic"] = { first = 0x1D44E, last = 0x1D467, math = true, italic = true }, ["lowercasemonospace"] = { first = 0x1D68A, last = 0x1D6A3, math = true }, ["lowercasenormal"] = { first = 0x00061, last = 0x0007A, math = true }, ["lowercasesansserifbold"] = { first = 0x1D5EE, last = 0x1D607, math = true }, - ["lowercasesansserifbolditalic"] = { first = 0x1D656, last = 0x1D66F, math = true }, - ["lowercasesansserifitalic"] = { first = 0x1D622, last = 0x1D63B, math = true }, + ["lowercasesansserifbolditalic"] = { first = 0x1D656, last = 0x1D66F, math = true, italic = true }, + ["lowercasesansserifitalic"] = { first = 0x1D622, last = 0x1D63B, math = true, italic = true }, ["lowercasesansserifnormal"] = { first = 0x1D5BA, last = 0x1D5D3, math = true }, - ["lowercasescript"] = { first = 0x1D4B6, last = 0x1D4CF, math = true }, + ["lowercasescript"] = { first = 0x1D4B6, last = 0x1D4CF, math = true, italic = true }, ["lowsurrogates"] = { first = 0x0DC00, last = 0x0DFFF, description = "Low Surrogates" }, ["lycian"] = { first = 0x10280, last = 0x1029F, description = "Lycian" }, ["lydian"] = { first = 0x10920, last = 0x1093F, description = "Lydian" }, @@ -561,24 +561,24 @@ local blocks = allocate { ["unifiedcanadianaboriginalsyllabicsextendeda"] = { first = 0x11AB0, last = 0x11ABF, description = "Unified Canadian Aboriginal Syllabics Extended-A" }, ["uppercasebold"] = { first = 0x1D400, last = 0x1D419, math = true }, ["uppercaseboldfraktur"] = { first = 0x1D56C, last = 0x1D585, math = true }, - ["uppercasebolditalic"] = { first = 0x1D468, last = 0x1D481, math = true }, - ["uppercaseboldscript"] = { first = 0x1D4D0, last = 0x1D4E9, math = true }, + ["uppercasebolditalic"] = { first = 0x1D468, last = 0x1D481, math = true, italic = true }, + ["uppercaseboldscript"] = { first = 0x1D4D0, last = 0x1D4E9, math = true, italic = true }, ["uppercasedoublestruck"] = { first = 0x1D538, last = 0x1D551, math = true }, -- gaps are filled in elsewhere ["uppercasefraktur"] = { first = 0x1D504, last = 0x1D51D, math = true }, ["uppercasegreekbold"] = { first = 0x1D6A8, last = 0x1D6C1, math = true }, - ["uppercasegreekbolditalic"] = { first = 0x1D71C, last = 0x1D735, math = true }, - ["uppercasegreekitalic"] = { first = 0x1D6E2, last = 0x1D6FB, math = true }, + ["uppercasegreekbolditalic"] = { first = 0x1D71C, last = 0x1D735, math = true, italic = true }, + ["uppercasegreekitalic"] = { first = 0x1D6E2, last = 0x1D6FB, math = true, italic = true }, ["uppercasegreeknormal"] = { first = 0x00391, last = 0x003AA, math = true }, ["uppercasegreeksansserifbold"] = { first = 0x1D756, last = 0x1D76F, math = true }, - ["uppercasegreeksansserifbolditalic"] = { first = 0x1D790, last = 0x1D7A9, math = true }, - ["uppercaseitalic"] = { first = 0x1D434, last = 0x1D44D, math = true }, + ["uppercasegreeksansserifbolditalic"] = { first = 0x1D790, last = 0x1D7A9, math = true, italic = true }, + ["uppercaseitalic"] = { first = 0x1D434, last = 0x1D44D, math = true, italic = true }, ["uppercasemonospace"] = { first = 0x1D670, last = 0x1D689, math = true }, ["uppercasenormal"] = { first = 0x00041, last = 0x0005A, math = true }, ["uppercasesansserifbold"] = { first = 0x1D5D4, last = 0x1D5ED, math = true }, - ["uppercasesansserifbolditalic"] = { first = 0x1D63C, last = 0x1D655, math = true }, - ["uppercasesansserifitalic"] = { first = 0x1D608, last = 0x1D621, math = true }, + ["uppercasesansserifbolditalic"] = { first = 0x1D63C, last = 0x1D655, math = true, italic = true }, + ["uppercasesansserifitalic"] = { first = 0x1D608, last = 0x1D621, math = true, italic = true }, ["uppercasesansserifnormal"] = { first = 0x1D5A0, last = 0x1D5B9, math = true }, - ["uppercasescript"] = { first = 0x1D49C, last = 0x1D4B5, math = true }, + ["uppercasescript"] = { first = 0x1D49C, last = 0x1D4B5, math = true, italic = true }, ["vai"] = { first = 0x0A500, last = 0x0A63F, description = "Vai" }, ["variationselectors"] = { first = 0x0FE00, last = 0x0FE0F, description = "Variation Selectors" }, ["variationselectorssupplement"] = { first = 0xE0100, last = 0xE01EF, description = "Variation Selectors Supplement" }, diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 400fc6983..191926e8f 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2022.10.15 10:32} +\newcontextversion{2022.10.21 21:11} %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/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index e0608818f..5dfadb660 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -49,7 +49,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2022.10.15 10:32} +\edef\contextversion{2022.10.21 21:11} %D Kind of special: diff --git a/tex/context/base/mkiv/font-con.lua b/tex/context/base/mkiv/font-con.lua index f650e5b03..5c156c2ba 100644 --- a/tex/context/base/mkiv/font-con.lua +++ b/tex/context/base/mkiv/font-con.lua @@ -534,7 +534,6 @@ function constructors.scale(tfmdata,specification) local realdimensions = properties.realdimensions local writingmode = properties.writingmode or "horizontal" local identity = properties.identity or "horizontal" - -- local vfonts = target.fonts if vfonts and #vfonts > 0 then target.fonts = fastcopy(vfonts) -- maybe we virtualize more afterwards diff --git a/tex/context/base/mkiv/font-ctx.lua b/tex/context/base/mkiv/font-ctx.lua index eead8abff..2c56b5613 100644 --- a/tex/context/base/mkiv/font-ctx.lua +++ b/tex/context/base/mkiv/font-ctx.lua @@ -1411,7 +1411,7 @@ do -- else too many locals context(function() busy = false mathematics.finishfallbacks(tfmdata,specification,fallbacks) -tfmdata.original = specification.specification + tfmdata.original = specification.specification local id = definefont(tfmdata) csnames[id] = specification.cs properties.id = id @@ -1449,7 +1449,7 @@ tfmdata.original = specification.specification end) return else -tfmdata.original = specification.specification + tfmdata.original = specification.specification local id = definefont(tfmdata) csnames[id] = specification.cs properties.id = id diff --git a/tex/context/base/mkiv/font-imp-italics.lua b/tex/context/base/mkiv/font-imp-italics.lua index 10a419daf..8b38c5893 100644 --- a/tex/context/base/mkiv/font-imp-italics.lua +++ b/tex/context/base/mkiv/font-imp-italics.lua @@ -13,29 +13,32 @@ local handlers = fonts.handlers local registerotffeature = handlers.otf.features.register local registerafmfeature = handlers.afm.features.register -local function initialize(tfmdata,key,value) - local factor = tonumber(value) or 1 - for unicode, character in next, tfmdata.characters do - local olditalic = character.italic - if olditalic and olditalic ~= 0 then - character.width = character.width + olditalic - character.italic = 0 - character.bottomright = -factor * olditalic - end - end -end - -local specification = { - name = "italicwidths", - description = "add italic to width", - manipulators = { - base = initialize, - node = initialize, -- only makes sense for math - } -} - -registerotffeature(specification) -registerafmfeature(specification) +-- This is a precursor to what we do in lmtx now via tweaks but at some point I +-- might make this a mkiv features too using staircase kerns. + +-- local function initialize(tfmdata,key,value) +-- local factor = tonumber(value) or 1 +-- for unicode, character in next, tfmdata.characters do +-- local olditalic = character.italic +-- if olditalic and olditalic ~= 0 then +-- character.width = character.width + olditalic +-- character.italic = 0 +-- character.bottomright = -factor * olditalic -- lmtx only +-- end +-- end +-- end +-- +-- local specification = { +-- name = "italicwidths", +-- description = "add italic to width", +-- manipulators = { +-- base = initialize, +-- node = initialize, -- only makes sense for math +-- } +-- } +-- +-- registerotffeature(specification) +-- registerafmfeature(specification) local function initialize(tfmdata,value) -- hm, always value if value then diff --git a/tex/context/base/mkiv/font-imp-math.lua b/tex/context/base/mkiv/font-imp-math.lua index c0185ca34..624f39f02 100644 --- a/tex/context/base/mkiv/font-imp-math.lua +++ b/tex/context/base/mkiv/font-imp-math.lua @@ -16,57 +16,41 @@ local registerotffeature = fonts.handlers.otf.features.register local setmetatableindex = table.setmetatableindex --- requested for latex but not supported unless really needed in context: +-- local splitter = lpeg.splitat(",",tonumber) +-- local lpegmatch = lpeg.match -- --- registerotffeature { --- name = "ignoremathconstants", --- description = "ignore math constants table", --- initializers = { --- base = function(tfmdata,value) --- if value then --- tfmdata.mathparameters = nil +-- local function initialize(tfmdata,value) +-- local mathparameters = tfmdata.mathparameters +-- if mathparameters then +-- local sup, sub +-- if type(value) == "string" then +-- sup, sub = lpegmatch(splitter,value) +-- if not sup then +-- sub, sup = 0, 0 +-- elseif not sub then +-- sub, sup = sup, 0 -- end +-- elseif type(value) == "number" then +-- sup, sub = 0, value +-- end +-- if sup then +-- mathparameters.NoLimitSupFactor = sup -- end +-- if sub then +-- mathparameters.NoLimitSubFactor = sub +-- end +-- end +-- end +-- +-- registerotffeature { +-- name = "mathnolimitsmode", +-- description = "influence nolimits placement", +-- initializers = { +-- base = initialize, +-- node = initialize, -- } -- } --- tfmdata.properties.mathnolimitsmode = tonumber(value) or 0 - -local splitter = lpeg.splitat(",",tonumber) -local lpegmatch = lpeg.match - -local function initialize(tfmdata,value) - local mathparameters = tfmdata.mathparameters - if mathparameters then - local sup, sub - if type(value) == "string" then - sup, sub = lpegmatch(splitter,value) - if not sup then - sub, sup = 0, 0 - elseif not sub then - sub, sup = sup, 0 - end - elseif type(value) == "number" then - sup, sub = 0, value - end - if sup then - mathparameters.NoLimitSupFactor = sup - end - if sub then - mathparameters.NoLimitSubFactor = sub - end - end -end - -registerotffeature { - name = "mathnolimitsmode", - description = "influence nolimits placement", - initializers = { - base = initialize, - node = initialize, - } -} - local function initialize(tfmdata,value) tfmdata.properties.nostackmath = value and true end diff --git a/tex/context/base/mkiv/font-pre.mkiv b/tex/context/base/mkiv/font-pre.mkiv index 445dedd25..5cd107c23 100644 --- a/tex/context/base/mkiv/font-pre.mkiv +++ b/tex/context/base/mkiv/font-pre.mkiv @@ -401,10 +401,11 @@ % liga=yes, % makes no sense % tlig=yes, % makes no sense % trep=yes, % makes no sense - mathnolimitsmode={0,800}, % this looks okay on the average font + % mathnolimitsmode={0,800}, % this looks okay on the average font mathalternates=yes, - mathitalics=yes, % we pass them - mathdimensions=all, + emulatelmtx=yes, + % mathitalics=yes, % we pass them + % mathdimensions=all, % mathkerns=yes, % mathgaps=yes, language=dflt, diff --git a/tex/context/base/mkiv/good-mth.lua b/tex/context/base/mkiv/good-mth.lua index 751ab2438..e25782e9e 100644 --- a/tex/context/base/mkiv/good-mth.lua +++ b/tex/context/base/mkiv/good-mth.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['good-mth'] = { + if not modules then modules = { } end modules ['good-mth'] = { version = 1.000, comment = "companion to font-lib.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -47,151 +47,151 @@ 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) - for i=1,#slots do - action(slots[i],data) - end - else - p = tonumber(p) - if p then - action(slots[p],data) - 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 - 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] * hfactor - character.width = character.width + xoffset - 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 - 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 +-- 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) +-- for i=1,#slots do +-- action(slots[i],data) +-- end +-- else +-- p = tonumber(p) +-- if p then +-- action(slots[p],data) +-- end +-- end +-- end +-- end +-- end +-- else +-- action(unicode,data) +-- end +-- end -registerotffeature { - name = "mathdimensions", - description = "manipulate math dimensions", - -- default = true, - manipulators = { - base = finalize, - node = finalize, - } -} +-- 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 +-- 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] * hfactor +-- character.width = character.width + xoffset +-- 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 +-- 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 @@ -222,119 +222,117 @@ 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) +-- 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 -- --- it would be nice to have a \noitalics\font option +-- registerotffeature { +-- name = "mathkerns", +-- description = "math kerns", +-- -- default = true, +-- initializers = { +-- base = initialize, +-- node = initialize, +-- } +-- } -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) +-- -- 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, +-- } +-- } local function mathradicalaction(n,h,v,font,mchar,echar) local characters = fontcharacters[font] diff --git a/tex/context/base/mkiv/lpdf-ano.lua b/tex/context/base/mkiv/lpdf-ano.lua index ebed9aec6..2bc485ff1 100644 --- a/tex/context/base/mkiv/lpdf-ano.lua +++ b/tex/context/base/mkiv/lpdf-ano.lua @@ -108,6 +108,10 @@ local pdf_named = pdfconstant("Named") local autoprefix = "#" local usedautoprefixes = { } +function codeinjections.setautoprefix(prefix) + autoprefix = prefix ~= "" and prefix or autoprefix +end + local function registerautoprefix(name) local internal = autoprefix .. name if usedautoprefixes[internal] == nil then diff --git a/tex/context/base/mkiv/math-act.lua b/tex/context/base/mkiv/math-act.lua index 5aa3f0ff0..a77fdc020 100644 --- a/tex/context/base/mkiv/math-act.lua +++ b/tex/context/base/mkiv/math-act.lua @@ -6,10 +6,13 @@ if not modules then modules = { } end modules ['math-act'] = { license = "see context related readme files" } --- Here we tweak some font properties (if needed). +-- Here we tweak some font properties (if needed). Per mid octover 2022 we also provide +-- an lmtx emulation mode which means that we removed some other code. Some of that was +-- experimental, some transitional, some is now obsolete). Using emulation mode also +-- means that we are unlikely to test some aspects of the math engines extensively. local type, next = type, next -local fastcopy, insert, remove = table.fastcopy, table.insert, table.remove +local fastcopy, insert, remove, copytable = table.fastcopy, table.insert, table.remove, table.copy local formatters = string.formatters local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end) @@ -75,41 +78,43 @@ local how = { NoLimitSubFactor = "unscaled", } -function mathematics.scaleparameters(target,original) - if not target.properties.math_is_scaled then - local mathparameters = target.mathparameters - if mathparameters and next(mathparameters) then - local parameters = target.parameters - local factor = parameters.factor - local hfactor = parameters.hfactor - local vfactor = parameters.vfactor - for name, value in next, mathparameters do - local h = how[name] - if h == "unscaled" then - -- kept - elseif h == "horizontal" then - value = value * hfactor - elseif h == "vertical"then - value = value * vfactor - else - value = value * factor - end - mathparameters[name] = value +local function scaleparameters(mathparameters,parameters) + if mathparameters and next(mathparameters) and parameters then + local factor = parameters.factor + local hfactor = parameters.hfactor + local vfactor = parameters.vfactor + for name, value in next, mathparameters do + local h = how[name] + if h == "unscaled" then + -- kept + elseif h == "horizontal" then + value = value * hfactor + elseif h == "vertical"then + value = value * vfactor + else + value = value * factor end + mathparameters[name] = value end - target.properties.math_is_scaled = true end end --- AccentBaseHeight vs FlattenedAccentBaseHeight - -function mathematics.checkaccentbaseheight(target,original) - local mathparameters = target.mathparameters - if mathparameters and mathparameters.AccentBaseHeight == 0 then - mathparameters.AccentBaseHeight = target.parameters.x_height -- needs checking +function mathematics.scaleparameters(target,original) + if not target.properties.math_is_scaled then + scaleparameters(target.mathparameters,target.parameters) + target.properties.math_is_scaled = true end end +-- -- AccentBaseHeight vs FlattenedAccentBaseHeight +-- +-- function mathematics.checkaccentbaseheight(target,original) +-- local mathparameters = target.mathparameters +-- if mathparameters and mathparameters.AccentBaseHeight == 0 then +-- mathparameters.AccentBaseHeight = target.parameters.x_height -- needs checking +-- end +-- end + function mathematics.checkprivateparameters(target,original) local mathparameters = target.mathparameters if mathparameters then @@ -180,29 +185,65 @@ function mathematics.overloadparameters(target,original) end end +local mathtweaks = { subsets = table.setmetatableindex("table") } +mathematics.tweaks = mathtweaks + +local apply_tweaks = true + +directives.register("math.applytweaks", function(v) + apply_tweaks = v; +end) + local function applytweaks(when,target,original) - local goodies = original.goodies - if goodies then - for i=1,#goodies do - local goodie = goodies[i] - local mathematics = goodie.mathematics - local tweaks = mathematics and mathematics.tweaks - if type(tweaks) == "table" then - tweaks = tweaks[when] - if type(tweaks) == "table" then - if trace_defining then - report_math("tweaking math of %a @ %p (%s)",target.properties.fullname,target.parameters.size,when) - end - for i=1,#tweaks do - local tweak= tweaks[i] - local tvalue = type(tweak) - if tvalue == "function" then - tweak(target,original) + if apply_tweaks then + local goodies = original.goodies + if goodies then + local tweaked = target.tweaked or { } + if tweaked[when] then + if trace_defining then + report_math("tweaking math of %a @ %p (%s: %s)",target.properties.fullname,target.parameters.size,when,"done") + end + else + for i=1,#goodies do + local goodie = goodies[i] + local mathematics = goodie.mathematics + local tweaks = mathematics and mathematics.tweaks + if type(tweaks) == "table" then + tweaks = tweaks[when] + if type(tweaks) == "table" then + if trace_defining then + report_math("tweaking math of %a @ %p (%s: %s)",target.properties.fullname,target.parameters.size,when,"okay") + end + for i=1,#tweaks do + local tweak = tweaks[i] + local tvalue = type(tweak) + if type(tweak) == "table" then + local action = mathtweaks[tweak.tweak or ""] + if action then + local feature = tweak.feature + local features = target.specification.features.normal + if not feature or features[feature] == true then + local version = tweak.version + if version and version ~= target.tweakversion then + report_math("skipping tweak %a version %a",tweak.tweak,version) + elseif original then + action(target,original,tweak) + else + action(target,tweak) + end + end + end + end + end end end end + tweaked[when] = true + target.tweaked = tweaked end end + else + report_math("not tweaking math of %a @ %p (%s)",target.properties.fullname,target.parameters.size,when) end end @@ -222,118 +263,130 @@ end sequencers.appendaction("mathparameters","system","mathematics.overloadparameters") sequencers.appendaction("mathparameters","system","mathematics.scaleparameters") -sequencers.appendaction("mathparameters","system","mathematics.checkaccentbaseheight") -- should go in lfg instead +----------.appendaction("mathparameters","system","mathematics.checkaccentbaseheight") -- should go in lfg instead sequencers.appendaction("mathparameters","system","mathematics.checkprivateparameters") -- after scaling ! sequencers.appendaction("beforecopyingcharacters","system","mathematics.tweakbeforecopyingfont") sequencers.appendaction("aftercopyingcharacters", "system","mathematics.tweakaftercopyingfont") --- no, it's a feature now (see good-mth): --- --- sequencers.appendaction("aftercopyingcharacters", "system","mathematics.overloaddimensions") - --- a couple of predefined tweaks: - -local tweaks = { subsets = { } } -mathematics.tweaks = tweaks - --- function tweaks.fixbadprime(target,original) --- target.characters[0xFE325] = target.characters[0x2032] --- end - --- these could go to math-fbk - --- local virtualized = mathematics.virtualized --- --- local function accent_to_extensible(target,newchr,original,oldchr,height,depth,swap) --- local characters = target.characters --- -- if not characters[newchr] then -- xits needs an enforce --- local addprivate = fonts.helpers.addprivate --- local olddata = characters[oldchr] --- if olddata then --- if swap then --- swap = characters[swap] --- height = swap.depth --- depth = 0 --- else --- height = height or 0 --- depth = depth or 0 --- end --- local correction = swap and { "down", (olddata.height or 0) - height } or { "down", olddata.height } --- local newdata = { --- commands = { correction, { "slot", 1, oldchr } }, --- width = olddata.width, --- height = height, --- depth = depth, --- } --- characters[newchr] = newdata --- local nextglyph = olddata.next --- while nextglyph do --- local oldnextdata = characters[nextglyph] --- local newnextdata = { --- commands = { correction, { "slot", 1, nextglyph } }, --- width = oldnextdata.width, --- height = height, --- depth = depth, --- } --- local newnextglyph = addprivate(target,formatters["original-%H"](nextglyph),newnextdata) --- newdata.next = newnextglyph --- local nextnextglyph = oldnextdata.next --- if nextnextglyph == nextglyph then --- break --- else --- olddata = oldnextdata --- newdata = newnextdata --- nextglyph = nextnextglyph --- end --- end --- local hv = olddata.horiz_variants --- if hv then --- hv = fastcopy(hv) --- newdata.horiz_variants = hv --- for i=1,#hv do --- local hvi = hv[i] --- local oldglyph = hvi.glyph --- local olddata = characters[oldglyph] --- local newdata = { --- commands = { correction, { "slot", 1, oldglyph } }, --- width = olddata.width, --- height = height, --- depth = depth, --- } --- hvi.glyph = addprivate(target,formatters["original-%H"](oldglyph),newdata) --- end --- end --- end --- -- end --- end - --- function tweaks.fixoverline(target,original) --- 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 --- accent_to_extensible(target,0x203E,original,0x0305,height,depth) --- -- also crappy spacing for our purpose: push to top of baseline --- accent_to_extensible(target,0xFE3DE,original,0x23DE,height,depth,0x23DF) --- accent_to_extensible(target,0xFE3DC,original,0x23DC,height,depth,0x23DD) --- accent_to_extensible(target,0xFE3B4,original,0x23B4,height,depth,0x23B5) --- -- for symmetry --- target.characters[0xFE3DF] = original.characters[0x23DF] --- target.characters[0xFE3DD] = original.characters[0x23DD] --- target.characters[0xFE3B5] = original.characters[0x23B5] --- -- inspect(fonts.helpers.expandglyph(target.characters,0x203E)) --- -- inspect(fonts.helpers.expandglyph(target.characters,0x23DE)) --- end +do + + -- More than a year of testing, development, tweaking (and improving) fonts has resulted + -- in a math engine in \LUAMETATEX\ that is quite flexible. Basically we can drop italic + -- correction there. In \MKIV\ we can emulate this to some extend but we still need a bit + -- of mix because \LUAMETATEX\ lacks some features. A variant of the tweak below is now + -- also used in the plain code we ship. In \MKIV\ we dropped a few features that were a + -- prelude to this and, because most users switched to \LMTX, it is unlikely that other + -- tweaks wil be backported. There is also no need to adapt \LUATEX\ and eventually all + -- italic code might be removed from \LUAMETATEX\ (unless we want to be able to test the + -- alternative; I can live with a little ballast, especially because it took time to load + -- it). + + local italics = nil + local integrals = table.tohash { + 0x0222B, 0x0222C, 0x0222D, 0x0222E, 0x0222F, 0x02230, 0x02231, 0x02232, 0x02233, + 0x02A0B, 0x02A0C, 0x02A0D, 0x02A0E, 0x02A0F, 0x02A10, 0x02A11, 0x02A12, 0x02A13, + 0x02A14, 0x02A15, 0x02A16, 0x02A17, 0x02A18, 0x02A19, 0x02A1A, 0x02A1B, 0x02A1C, + 0x02320, 0x02321 + } + + function mathtweaks.emulatelmtx(target,original,parameters) + -- gaps are not known yet + if not italic then + italics = { } + local gaps = mathematics.gaps + for name, data in next, characters.blocks do + if data.math and data.italic then + for i=data.first,data.last do + italics[i] = true + local g = gaps[i] + if g then + italics[g] = true + end + end + end + end +-- table.save("temp.log", table.sortedkeys(italics)) + end + -- + local targetcharacters = target.characters + local targetdescriptions = target.descriptions + local factor = target.parameters.factor + local function getllx(u) + local d = targetdescriptions[u] + if d then + local b = d.boundingbox + if b then + local llx = b[1] + if llx < 0 then + return - llx + end + end + end + return false + end + -- beware: here we also do the weird ones + for u, c in next, targetcharacters do + local uc = c.unicode or u + if integrals[uc] then + -- skip this one + else + local accent = c.top_accent + local italic = c.italic + local width = c.width or 0 + local llx = getllx(u) + local bl, br, tl, tr + if llx then + llx = llx * factor + width = width + llx + bl = - llx + tl = bl + c.commands = { rightcommand[llx], charcommand[u] } + if accent then + accent = accent + llx + end + end + if accent then + if italics[uc] then + c.top_accent = accent + else + c.top_accent = nil + end + end + if italic and italic ~= 0 then + width = width + italic + br = - italic + end + c.width = width + if italic then + c.italic = nil + end + if bl or br or tl or tr then + -- watch out: singular and _ because we are post copying / scaling + c.mathkern = { + bottom_left = bl and { { height = 0, kern = bl } } or nil, + bottom_right = br and { { height = 0, kern = br } } or nil, + top_left = tl and { { height = c.height or 0, kern = tl } } or nil, + top_right = tr and { { height = c.height or 0, kern = tr } } or nil, + } + end + end + end + end --- sequencers.appendaction("aftercopyingcharacters", "system","mathematics.tweaks.fixoverline") -- for the moment always + function mathtweaks.parameters(target,original,parameters) + local newparameters = parameters.list + local oldparameters = target.mathparameters + if newparameters and oldparameters then + newparameters = copytable(newparameters) + scaleparameters(newparameters,target.parameters) + for name, newvalue in next, newparameters do + oldparameters[name] = newvalue + end + end + end --- helpers +end local setmetatableindex = table.setmetatableindex @@ -467,87 +520,6 @@ interfaces.implement { end } --- experiment - --- check: when true, only set when present in font --- force: when false, then not set when already set - --- todo: tounicode - --- function mathematics.injectfallbacks(target,original) --- local properties = original.properties --- if properties and properties.hasmath then --- local specification = target.specification --- if specification then --- local fallbacks = specification.fallbacks --- if fallbacks then --- local definitions = fonts.collections.definitions[fallbacks] --- if definitions then --- if trace_collecting then --- report_math("adding fallback characters to font %a",specification.hash) --- end --- local definedfont = fonts.definers.internal --- local copiedglyph = fonts.handlers.vf.math.copy_glyph --- local fonts = target.fonts --- local size = specification.size -- target.size --- local characters = target.characters --- if not fonts then --- fonts = { } --- target.fonts = fonts --- if not CONTEXTLMTXMODE or CONTEXTLMTXMODE == 0 then --- target.type = "virtual" --- target.properties.virtualized = true --- end --- end --- if #fonts == 0 then --- fonts[1] = { id = 0, size = size } -- sel, will be resolved later --- end --- local done = { } --- for i=1,#definitions do --- local definition = definitions[i] --- local name = definition.font --- local start = definition.start --- local stop = definition.stop --- local gaps = definition.gaps --- local check = definition.check --- local force = definition.force --- local rscale = definition.rscale or 1 --- local offset = definition.offset or start --- local id = definedfont { name = name, size = size * rscale } --- local index = #fonts + 1 --- fonts[index] = { id = id, size = size } --- local chars = fontchars[id] --- local function remap(unic,unicode,gap) --- -- local unic = unicode + offset - start --- if check and not chars[unicode] then --- -- not in font --- elseif force or (not done[unic] and not characters[unic]) then --- if trace_collecting then --- report_math("remapping math character, vector %a, font %a, character %C%s%s", --- fallbacks,name,unic,check and ", checked",gap and ", gap plugged") --- end --- characters[unic] = copiedglyph(target,characters,chars,unicode,index) --- done[unic] = true --- end --- end --- for unicode = start, stop do --- local unic = unicode + offset - start --- remap(unic,unicode,false) --- end --- if gaps then --- for unic, unicode in next, gaps do --- remap(unic,unicode,true) --- end --- end --- end --- end --- end --- end --- end --- end --- --- sequencers.appendaction("aftercopyingcharacters", "system","mathematics.finishfallbacks") - local stack = { } function mathematics.registerfallbackid(n,id,name) diff --git a/tex/context/base/mkiv/math-vfu.lua b/tex/context/base/mkiv/math-vfu.lua index 221bbff89..f282005fc 100644 --- a/tex/context/base/mkiv/math-vfu.lua +++ b/tex/context/base/mkiv/math-vfu.lua @@ -699,7 +699,7 @@ local function copy_glyph(main,target,original,unicode,slot) vvi.glyph = addprivate(main,formatters["M-V-%H"](oldglyph),newdata) end end - return newdata + return glyphdata end end diff --git a/tex/context/base/mkiv/scrn-ini.lua b/tex/context/base/mkiv/scrn-ini.lua index bf7afccb6..9c9a9f1b4 100644 --- a/tex/context/base/mkiv/scrn-ini.lua +++ b/tex/context/base/mkiv/scrn-ini.lua @@ -41,3 +41,11 @@ interfaces.implement { } } } + +interfaces.implement { + name = "setautoprefix", + actions = function(prefix) + backends.codeinjections.setautoprefix(prefix) + end, + arguments = "string", +} diff --git a/tex/context/base/mkiv/scrn-ini.mkvi b/tex/context/base/mkiv/scrn-ini.mkvi index 39fef740c..4651956a5 100644 --- a/tex/context/base/mkiv/scrn-ini.mkvi +++ b/tex/context/base/mkiv/scrn-ini.mkvi @@ -251,4 +251,8 @@ \c!keyword=, \c!date=] +\appendtoks + \clf_setautoprefix{\interactionparameter\c!prefix}% +\to \everysetupinteraction + \protect \endinput diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex a51e3ea39..66cc6048a 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 8c4219a01..e798b7a58 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/strc-lst.lua b/tex/context/base/mkiv/strc-lst.lua index 4a190132b..41d09f073 100644 --- a/tex/context/base/mkiv/strc-lst.lua +++ b/tex/context/base/mkiv/strc-lst.lua @@ -98,7 +98,10 @@ local v_reference = variables.reference local v_local = variables["local"] local v_default = variables.default --- for the moment not public -- +local cheats = { + [variables.fit] = true, + [variables.tight] = true, +} local function zerostrippedconcat(t,separator) local f = 1 @@ -196,7 +199,7 @@ local function finalizer() local i = r.internal local f = flaginternals[i] local v = usedviews[i] - if cheat and v then + if cheat and v and cheats[v] then -- cheats check added, to be tested by RKB -- this permits runs=2 with interactivity r.view = v end diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index bb6268f4a..2950090ea 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{2022.10.15 10:32} +\newcontextversion{2022.10.21 21:11} %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 c322164c3..c5baad13d 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{2022.10.15 10:32} +\immutable\edef\contextversion{2022.10.21 21:11} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/driv-ini.lmt b/tex/context/base/mkxl/driv-ini.lmt index 8b6c2e5ff..c43bf2a83 100644 --- a/tex/context/base/mkxl/driv-ini.lmt +++ b/tex/context/base/mkxl/driv-ini.lmt @@ -30,6 +30,8 @@ local shipout = tex.shipout local texgetbox = tex.getbox local texgetcount = tex.getcount +local c_realpageno = tex.iscount("realpageno") + function converters.engine(driver,boxnumber,mode,number,specification) return shipout(boxnumber) end @@ -204,7 +206,7 @@ function drivers.convert(boxnumber) if currentinstance then callbacks.functions.start_page_number() starttiming(drivers) - convert(currentinstance,boxnumber,texgetcount("realpageno")) + convert(currentinstance,boxnumber,texgetcount(c_realpageno)) stoptiming(drivers) callbacks.functions.stop_page_number() end diff --git a/tex/context/base/mkxl/font-col.mklx b/tex/context/base/mkxl/font-col.mklx index 0e2f302b2..bd099bbe9 100644 --- a/tex/context/base/mkxl/font-col.mklx +++ b/tex/context/base/mkxl/font-col.mklx @@ -95,18 +95,18 @@ % math (experiment, todo clf_) -\def\font_fallbacks_register_math#1#2#3#4% - {\doifelsenothing{#3}% - {\definedfont[#2 at #4\scaledpoint]}% - {\definedfont[#2*#3\space at #4\scaledpoint]}% - \clf_registerfontfallbackid#1\space\fontid\font\space{#2}} - % \def\font_fallbacks_register_math#1#2#3#4% -% {\definedfont[#2\iftok{#3}\emptytoks\else*#3 \fi at #4\scaledpoint]% +% {\doifelsenothing{#3}% +% {\definedfont[#2 at #4\scaledpoint]}% +% {\definedfont[#2*#3\space at #4\scaledpoint]}% % \clf_registerfontfallbackid#1\space\fontid\font\space{#2}} -% \def\font_fallbacks_finish_math -% {\ctxlua{mathematics.finishfallbacks()}} +% % % \def\font_fallbacks_register_math#1#2#3#4% +% % % {\definedfont[#2\iftok{#3}\emptytoks\else*#3 \fi at #4\scaledpoint]% +% % % \clf_registerfontfallbackid#1\space\fontid\font\space{#2}} +% % % +% % % \def\font_fallbacks_finish_math +% % % {\ctxlua{mathematics.finishfallbacks()}} % check : only replace when present in replacement font (default: no) % force : force replacent even when basefont has glyph (default: yes) diff --git a/tex/context/base/mkxl/font-con.lmt b/tex/context/base/mkxl/font-con.lmt index 319d5fe48..2e32193e9 100644 --- a/tex/context/base/mkxl/font-con.lmt +++ b/tex/context/base/mkxl/font-con.lmt @@ -445,7 +445,7 @@ function constructors.scale(tfmdata,specification) local hasquality = parameters.expansion or parameters.protrusion local hasitalics = properties.hasitalics local autoitalicamount = properties.autoitalicamount - local stackmath = not properties.nostackmath + -- local stackmath = not properties.nostackmath local haskerns = properties.haskerns or properties.mode == "base" -- we can have afm in node mode local hasligatures = properties.hasligatures or properties.mode == "base" -- we can have afm in node mode local realdimensions = properties.realdimensions @@ -720,7 +720,8 @@ function constructors.scale(tfmdata,specification) -- if vo then -- chr.bottomovershoot = vo*hdelta -- end - if stackmath then -- not ok yet + -- + -- if stackmath then -- not ok yet local mk = character.mathkerns if mk then local tr = mk.topright @@ -734,7 +735,8 @@ function constructors.scale(tfmdata,specification) bottomleft = bl and mathkerns(bl,vdelta) or nil, } end - end + -- end + -- if hasitalics then local vi = character.italic if vi and vi ~= 0 then diff --git a/tex/context/base/mkxl/font-ctx.lmt b/tex/context/base/mkxl/font-ctx.lmt index 75572e089..83c0a912b 100644 --- a/tex/context/base/mkxl/font-ctx.lmt +++ b/tex/context/base/mkxl/font-ctx.lmt @@ -90,6 +90,7 @@ local setsubtype = nuts.setsubtype local texgetdimen = tex.getdimen local texsetcount = tex.setcount +local texiscount = tex.iscount local texget = tex.get local texdefinefont = tex.definefont @@ -1119,12 +1120,16 @@ local specifiers = { } do -- else too many locals - local starttiming = statistics.starttiming - local stoptiming = statistics.stoptiming + local starttiming = statistics.starttiming + local stoptiming = statistics.stoptiming - local setmacro = tokens.setters.macro - local ctxcatcodes = tex.ctxcatcodes - local texconditionals = tex.conditionals + local setmacro = tokens.setters.macro + local ctxcatcodes = tex.ctxcatcodes + local texconditionals = tex.conditionals + + local c_scaledfontmode = texiscount("scaledfontmode") + local c_scaledfontsize = texiscount("scaledfontsize") + local c_lastfontid = texiscount("lastfontid") local reported = setmetatableindex(function(t,k) local v = setmetatableindex(function(t,k) @@ -1166,7 +1171,7 @@ do -- else too many locals local mode, fontsize, sx, sy = lpegmatch(sizepattern,size) -- print(size,mode,fontsize,sx,sy) if mode and fontsize and fontsize ~= "" then - texsetcount("scaledfontmode",mode) + texsetcount(c_scaledfontmode,mode) -- ctx_setsomefontsize(fontsize) -- We use a catcodetable, just in case it's 1.2\exheight (a corner case that showed -- up in the lmtx manual: marking that changed size in the mids of some verbatim). @@ -1178,15 +1183,15 @@ do -- else too many locals setmacro("somefontsizey",sy) end else - texsetcount("scaledfontmode",0) + texsetcount(c_scaledfontmode,0) -- ctx_setemptyfontsize() end elseif true then -- so we don't need to check in tex - texsetcount("scaledfontmode",2) + texsetcount(c_scaledfontmode,2) -- ctx_setemptyfontsize() else - texsetcount("scaledfontmode",0) + texsetcount(c_scaledfontmode,0) -- ctx_setemptyfontsize() end specification = definers.makespecification(str,lookup,name,sub,method,detail,size) @@ -1374,99 +1379,36 @@ do -- else too many locals local properties = tfmdata.properties -- we use char0 as signal; cf the spec pdf can handle this (no char in slot) characters[0] = nil - -- characters[0x00A0] = { width = parameters.space } - -- characters[0x2007] = { width = characters[0x0030] and characters[0x0030].width or parameters.space } -- figure - -- characters[0x2008] = { width = characters[0x002E] and characters[0x002E].width or parameters.space } -- period - -- - local fallbacks = specification.fallbacks or "" - local mathsize = (mathsize == 1 or mathsize == 2 or mathsize == 3) and mathsize or nil -- can be unset so we test 1 2 3 - if fallbacks ~= "" and mathsize and not busy then - busy = true - -- We need this ugly hack in order to resolve fontnames (at the \TEX end). Originally - -- math was done in Lua after loading (plugged into aftercopying). - -- - -- After tl 2017 I'll also do text fallbacks this way (although backups there are done - -- in a completely different way.) - if trace_defining then - report_defining("defining %a, id %a, target %a, features %a / %a, fallbacks %a / %a, step %a", - name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,1) - end - mathematics.resolvefallbacks(tfmdata,specification,fallbacks) - context(function() - -- We're doing math fallbacks. - busy = false - mathematics.finishfallbacks(tfmdata,specification,fallbacks) - tfmdata.original = specification.specification - constructors.beforepassingfonttotex(tfmdata) - local id = definefont(tfmdata,properties.id) - csnames[id] = specification.cs - properties.id = id -- already set - definers.register(tfmdata,id) -- to be sure, normally already done - texdefinefont(global,cs,id) - -- texdefinefont(cs,id,global and "global") - constructors.finalize(tfmdata) - if trace_defining then - report_defining("defining %a, id %a, target %a, features %a / %a, fallbacks %a / %a, step %a", - name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,2) - end - -- resolved (when designsize is used): - local size = round(tfmdata.parameters.size or 655360) - setmacro("somefontsize",size.."sp") - -- ctx_setsomefontsize(size .. "sp") - texsetcount("scaledfontsize",size) - lastfontid = id - -- - if trace_defining then - report_defining("memory usage after: %s",statistics.memused()) - report_defining("stop stage two") - end - -- - texsetcount("global","lastfontid",lastfontid) - specifiers[lastfontid] = { str, size } - if not mathsize then - -- forget about it (can't happen here) - elseif mathsize == 0 then - -- can't happen (here) - else - -- maybe only 1 2 3 (we already test for this) - lastmathids[mathsize] = lastfontid - end - stoptiming(fonts) - end) - return - else - tfmdata.original = specification.specification - local id = definefont(tfmdata,properties.id) - csnames[id] = specification.cs - properties.id = id -- already set - definers.register(tfmdata,id) -- to be sure, normally already done - texdefinefont(global,cs,id) - -- texdefinefont(cs,id,global and "global") - constructors.finalize(tfmdata) - if trace_defining then - report_defining("defining %a, id %a, target %a, features %a / %a, fallbacks %a / %a, step %a", - name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,"-") - end - -- resolved (when designsize is used): - local size = round(tfmdata.parameters.size or 655360) - setmacro("somefontsize",size.."sp") - -- ctx_setsomefontsize(size .. "sp") - texsetcount("scaledfontsize",size) - lastfontid = id + tfmdata.original = specification.specification + local id = definefont(tfmdata,properties.id) + csnames[id] = specification.cs + properties.id = id -- already set + definers.register(tfmdata,id) -- to be sure, normally already done + texdefinefont(global,cs,id) + -- texdefinefont(cs,id,global and "global") + constructors.finalize(tfmdata) + if trace_defining then + report_defining("defining %a, id %a, target %a, features %a / %a, fallbacks %a / %a, step %a", + name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,"-") end + -- resolved (when designsize is used): + local size = round(tfmdata.parameters.size or 655360) + setmacro("somefontsize",size.."sp") + texsetcount(c_scaledfontsize,size) + lastfontid = id elseif tfmtype == "number" then if trace_defining then report_defining("reusing %s, id %a, target %a, features %a / %a, fallbacks %a / %a, goodies %a / %a, designsize %a / %a", name,tfmdata,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,classgoodies,goodies,classdesignsize,fontdesignsize) end csnames[tfmdata] = specification.cs +-- \definedfont ends up here texdefinefont(global,cs,tfmdata) -- texdefinefont(cs,tfmdata,global and "global") -- resolved (when designsize is used): local size = round(fontdata[tfmdata].parameters.size or 0) - -- ctx_setsomefontsize(size .. "sp") setmacro("somefontsize",size.."sp") - texsetcount("scaledfontsize",size) + texsetcount(c_scaledfontsize,size) lastfontid = tfmdata else local nice = nice_cs(cs) @@ -1474,7 +1416,7 @@ do -- else too many locals report_defining("unable to define %a as %a",name,nice) end lastfontid = -1 - texsetcount("scaledfontsize",0) + texsetcount(c_scaledfontsize,0) -- ctx_letvaluerelax(cs) -- otherwise the current definition takes the previous one end if trace_defining then @@ -1482,7 +1424,7 @@ do -- else too many locals report_defining("stop stage two") end -- - texsetcount("global","lastfontid",lastfontid) + texsetcount("global",c_lastfontid,lastfontid) specifiers[lastfontid] = { str, size } if not mathsize then -- forget about it @@ -1606,6 +1548,8 @@ do -- else too many locals local n = 0 + local d_bodyfontsize = tex.isdimen("bodyfontsize") + function definers.internal(specification,cs) specification = specification or { } local name = specification.name @@ -1613,7 +1557,7 @@ do -- else too many locals local number = tonumber(specification.number) local id = nil if not size then - size = texgetdimen("bodyfontsize") + size = texgetdimen(d_bodyfontsize) end if number then id = number @@ -1670,6 +1614,8 @@ end -- have delayed definitions and so we never know what style is taken -- as start. +local c_font_scaled_points = texiscount("c_font_scaled_points") + function constructors.calculatescale(tfmdata,scaledpoints,relativeid,specification) local parameters = tfmdata.parameters local units = parameters.units or 1000 @@ -1691,7 +1637,7 @@ function constructors.calculatescale(tfmdata,scaledpoints,relativeid,specificati -- a temp hack till we have upgraded all mechanisms local delta = round(scaledpoints/units) local size = round(scaledpoints) - texsetcount("c_font_scaled_points",size) + texsetcount(c_font_scaled_points,size) -- return size, delta end diff --git a/tex/context/base/mkxl/font-imp-math.lmt b/tex/context/base/mkxl/font-imp-math.lmt index 04fe5c04c..bd445caea 100644 --- a/tex/context/base/mkxl/font-imp-math.lmt +++ b/tex/context/base/mkxl/font-imp-math.lmt @@ -20,56 +20,55 @@ local texconditionals = tex.conditionals -- tfmdata.properties.mathnolimitsmode = tonumber(value) or 0 -local splitter = lpeg.splitat(",",tonumber) -local lpegmatch = lpeg.match - -local function initialize(tfmdata,value) - local mathparameters = tfmdata.mathparameters - if mathparameters then - local sup, sub - if type(value) == "string" then - sup, sub = lpegmatch(splitter,value) -- settings_to_array - if not sup then - sub, sup = 0, 0 - elseif not sub then - sub, sup = sup, 0 - end - elseif type(value) == "number" then - sup, sub = 0, value - end - if sup then - mathparameters.NoLimitSupFactor = sup - end - if sub then - mathparameters.NoLimitSubFactor = sub - end - end -end - -registerotffeature { - name = "mathnolimitsmode", - description = "influence nolimits placement", - initializers = { - base = initialize, - node = initialize, - } -} - - --- this will become a mode in the engine - -local function initialize(tfmdata,value) - tfmdata.properties.nostackmath = value and true -end +-- local splitter = lpeg.splitat(",",tonumber) +-- local lpegmatch = lpeg.match +-- +-- local function initialize(tfmdata,value) +-- local mathparameters = tfmdata.mathparameters +-- if mathparameters then +-- local sup, sub +-- if type(value) == "string" then +-- sup, sub = lpegmatch(splitter,value) -- settings_to_array +-- if not sup then +-- sub, sup = 0, 0 +-- elseif not sub then +-- sub, sup = sup, 0 +-- end +-- elseif type(value) == "number" then +-- sup, sub = 0, value +-- end +-- if sup then +-- mathparameters.NoLimitSupFactor = sup +-- end +-- if sub then +-- mathparameters.NoLimitSubFactor = sub +-- end +-- end +-- end +-- +-- registerotffeature { +-- name = "mathnolimitsmode", +-- description = "influence nolimits placement", +-- initializers = { +-- base = initialize, +-- node = initialize, +-- } +-- } -registerotffeature { - name = "nostackmath", - description = "disable math stacking mechanism", - initializers = { - base = initialize, - node = initialize, - } -} +-- this will become a mode in the engine -- done +-- +-- local function initialize(tfmdata,value) +-- tfmdata.properties.nostackmath = value and true +-- end +-- +-- registerotffeature { +-- name = "nostackmath", +-- description = "disable math stacking mechanism", +-- initializers = { +-- base = initialize, +-- node = initialize, +-- } +-- } -- A quick and dirty and low level implementation but okay for testing: diff --git a/tex/context/base/mkxl/font-ini.mklx b/tex/context/base/mkxl/font-ini.mklx index 67663b7db..1fab52386 100644 --- a/tex/context/base/mkxl/font-ini.mklx +++ b/tex/context/base/mkxl/font-ini.mklx @@ -667,9 +667,10 @@ \mutable\let\somefontsizex\empty \mutable\let\somefontsizey\empty -\newcount\scaledfontmode % also used at the lua end -\newcount\scaledfontsize % also used at the lua end -\newcount\lastfontid % also used at the lua end / tex end +% \newcount\scaledfontmode % font-lib.mklx +% \newcount\scaledfontsize % font-lib.mklx +% \newcount\lastfontid % font-lib.mklx + \newtoks \everydefinefont \aliased\let\c_font_feature_inheritance_fontnone \zerocount % none @@ -692,13 +693,11 @@ \immutable\dimensiondef\d_font_scaled_default 10pt -\newcount\c_font_future_glyph_scale - % todo: move all to lua: use localcall for resolving filename -\newcount\c_font_future_glyph_scale -\newcount\c_font_scaled_font_mode_saved -\newcount\c_font_scaled_points +% \newcount\c_font_future_glyph_scale % font-lib.mklx +% \newcount\c_font_scaled_font_mode_saved % font-lib.mklx +% \newcount\c_font_scaled_points % font-lib.mklx \mutable\let\somefontspec \empty \mutable\let\lastrawfontcall \relax @@ -1218,7 +1217,7 @@ \ifcsname\??fontenvironments \s!default\s!text \endcsname\lastnamedcs\else \csname\??fontenvironments \s!default \endcsname \fi} -\setvalue{\??fontenvironments\s!default}{1} +\defcsname\??fontenvironments\s!default\endcsname{1} %D In the following macros we use \type {\currentxfontsize} to hold the current %D x||size of the font. This enables us to support for instance \type {\sl} inside a @@ -1313,10 +1312,10 @@ % todo: class:size % todo: make assignments global -\letvalue\??fontenvironments\empty % so we default to empty +\letcsname\??fontenvironments\endcsname\empty % so we default to empty \permanent\def\bodyfontvariable#parameter% - {\csname\??fontenvironments + {\begincsname\??fontenvironments \ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname\fontclass\normalizedbodyfontsize#parameter\orelse \ifcsname\??fontenvironments\fontclass #parameter\endcsname\fontclass #parameter\orelse \ifcsname\??fontenvironments \normalizedbodyfontsize#parameter\endcsname \normalizedbodyfontsize#parameter\orelse @@ -1329,13 +1328,20 @@ \ifcsname\??fontenvironments \normalizedbodyfontsize#parameter\endcsname\lastnamedcs\orelse \ifcsname\??fontenvironments\s!default #parameter\endcsname\lastnamedcs\fi} -\permanent\def\bodyfontsizevariable#size#parameter% - {\csname\??fontenvironments - \ifcsname\??fontenvironments\fontclass#size#parameter\endcsname\fontclass#size#parameter\orelse - \ifcsname\??fontenvironments\fontclass #parameter\endcsname\fontclass #parameter\orelse - \ifcsname\??fontenvironments #size#parameter\endcsname #size#parameter\orelse - \ifcsname\??fontenvironments\s!default #parameter\endcsname\s!default #parameter\fi - \endcsname} +% \permanent\def\bodyfontsizevariable#size#parameter% +% {\begincsname\??fontenvironments +% \ifcsname\??fontenvironments\fontclass#size#parameter\endcsname\fontclass#size#parameter\orelse +% \ifcsname\??fontenvironments\fontclass #parameter\endcsname\fontclass #parameter\orelse +% \ifcsname\??fontenvironments #size#parameter\endcsname #size#parameter\orelse +% \ifcsname\??fontenvironments\s!default #parameter\endcsname\s!default #parameter\fi +% \endcsname} + +\def\font_bodyfontvariable#parameter% + {\ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname\lastnamedcs\orelse + \ifcsname\??fontenvironments\fontclass #parameter\endcsname\lastnamedcs\orelse + \ifcsname\??fontenvironments\v!all \normalizedbodyfontsize#parameter\endcsname\lastnamedcs\orelse + \ifcsname\??fontenvironments \normalizedbodyfontsize#parameter\endcsname\lastnamedcs\orelse + \ifcsname\??fontenvironments\s!default #parameter\endcsname\lastnamedcs\fi} \def\font_bodyfontsizevariable#size#parameter% {\ifcsname\??fontenvironments\fontclass#size#parameter\endcsname\lastnamedcs\orelse @@ -2387,6 +2393,28 @@ }% \gletcsname\??fontbodyfaces\fontbody\endcsname\font_basics_set_faces} +% \permanent\def\currentbodyfontdimension#parameter% there can be factors here +% {\the\dimexpr +% \ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname +% \lastnamedcs +% \orelse\ifcsname\??fontenvironments\fontclass\s!default#parameter\endcsname +% \lastnamedcs +% \dimexpr\normalizedbodyfontsize\relax +% \orelse\ifcsname\??fontenvironments\normalizedbodyfontsize#parameter\endcsname +% \lastnamedcs +% \else +% \csname\??fontenvironments\s!default#parameter\endcsname +% \dimexpr\normalizedbodyfontsize\relax +% \fi +% \relax} + +% \setupbodyfontenvironment [all] [12pt] [x=4pt,small=4pt] +% \setupbodyfontenvironment [pagella] [12pt] [x=4pt,small=4pt] +% +% \setupbodyfont[pagella,12pt] +% +% \starttext normal {\tx tx} {\small small} \stoptext + \permanent\def\currentbodyfontdimension#parameter% there can be factors here {\the\dimexpr \ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname @@ -2394,6 +2422,8 @@ \orelse\ifcsname\??fontenvironments\fontclass\s!default#parameter\endcsname \lastnamedcs \dimexpr\normalizedbodyfontsize\relax + \orelse\ifcsname\??fontenvironments\v!all\normalizedbodyfontsize#parameter\endcsname + \lastnamedcs \orelse\ifcsname\??fontenvironments\normalizedbodyfontsize#parameter\endcsname \lastnamedcs \else diff --git a/tex/context/base/mkxl/font-lib.mklx b/tex/context/base/mkxl/font-lib.mklx index f7342c7d4..05367dae8 100644 --- a/tex/context/base/mkxl/font-lib.mklx +++ b/tex/context/base/mkxl/font-lib.mklx @@ -15,6 +15,18 @@ \unprotect +\newcount\scaledfontmode +\newcount\scaledfontsize +\newcount\lastfontid + +\newcount\c_font_future_glyph_scale +\newcount\c_font_scaled_font_mode_saved +\newcount\c_font_scaled_points + +\ifdefined\globalbodyfontsize \else \newdimen\globalbodyfontsize \fi +\ifdefined\localbodyfontsize \else \newdimen\localbodyfontsize \fi +\ifdefined\bodyfontsize \else \newdimen\bodyfontsize \fi + \registerctxluafile{font-ini}{autosuffix} \registerctxluafile{font-log}{} \registerctxluafile{font-con}{autosuffix} % kind of early diff --git a/tex/context/base/mkxl/font-pre.mkxl b/tex/context/base/mkxl/font-pre.mkxl index 8cb0b5b6c..4a7442d10 100644 --- a/tex/context/base/mkxl/font-pre.mkxl +++ b/tex/context/base/mkxl/font-pre.mkxl @@ -412,13 +412,13 @@ [mode=base, % mode=none, % better, maybe do this last kern=yes, -% flac=yes, % handled differently -% liga=yes, % makes no sense -% mode=node, -% mathnolimitsmode={0,800}, % now in lfg files + % flac=yes, % handled differently + % liga=yes, % makes no sense + % mode=node, + % mathnolimitsmode={0,800}, % now in lfg files mathalternates=yes, - mathitalics=yes, % we pass them - mathdimensions=all, + % mathitalics=yes, % we pass them + % mathdimensions=all, % mathkerns=yes, % staircase=yes, compactmath=yes, @@ -467,10 +467,10 @@ \definefontfeature[math-scriptscript-r2l] [mathematics-r2l] [ssty=2,mathsize=yes] % this will go away: could be a mode in the engine - -\definefontfeature[math-nostack-text] [math-text] [nostackmath=yes] -\definefontfeature[math-nostack-script] [math-script] [nostackmath=yes] -\definefontfeature[math-nostack-scriptscript][math-scriptscript][nostackmath=yes] +% +% \definefontfeature[math-nostack-text] [math-text] [nostackmath=yes] +% \definefontfeature[math-nostack-script] [math-script] [nostackmath=yes] +% \definefontfeature[math-nostack-scriptscript][math-scriptscript][nostackmath=yes] % \definefontfeature[mathtext] [math-text] % \definefontfeature[mathscript] [math-script] @@ -987,11 +987,9 @@ \startsetups experiment:fonts:compact \settrue\c_font_compact - % \definefontfeature[virtualmath] [mathematics] [compactmath=yes] % \definefontfeature[virtualmath-l2r] [mathematics-l2r][compactmath=yes] % \definefontfeature[virtualmath-r2l] [mathematics-r2l][compactmath=yes] - % \definefontfeature[math-text] [mathematics] [compactmath=yes] % \definefontfeature[math-script] [mathematics] [compactmath=yes] % \definefontfeature[math-scriptscript] [mathematics] [compactmath=yes] diff --git a/tex/context/base/mkxl/lpdf-ano.lmt b/tex/context/base/mkxl/lpdf-ano.lmt index e3904f16e..ed26b512e 100644 --- a/tex/context/base/mkxl/lpdf-ano.lmt +++ b/tex/context/base/mkxl/lpdf-ano.lmt @@ -112,6 +112,10 @@ local pdf_named = pdfconstant("Named") local autoprefix = "#" local usedautoprefixes = { } +function codeinjections.setautoprefix(prefix) + autoprefix = prefix ~= "" and prefix or autoprefix +end + local function registerautoprefix(name) local internal = autoprefix .. name if usedautoprefixes[internal] == nil then diff --git a/tex/context/base/mkxl/math-act.lmt b/tex/context/base/mkxl/math-act.lmt index 7fb4f9b9f..713635583 100644 --- a/tex/context/base/mkxl/math-act.lmt +++ b/tex/context/base/mkxl/math-act.lmt @@ -13,7 +13,7 @@ local type, next, tonumber = type, next, tonumber local fastcopy, copytable, insert, remove = table.fastcopy, table.copy, table.insert, table.remove local formatters = string.formatters local byte = string.byte -local setmetatableindex, sortedhash = table.setmetatableindex, table.sortedhash +local setmetatableindex, sortedkeys, sortedhash = table.setmetatableindex, table.sortedkeys, table.sortedhash local lpegmatch = lpeg.match local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end) @@ -54,7 +54,8 @@ local fontproperties = fonts.hashes.properties local mathgaps = mathematics.gaps -local use_math_goodies = true directives.register("math.nogoodies", function(v) use_math_goodies = not v end) +local use_math_goodies = true directives.register("math.nogoodies", function(v) use_math_goodies = not v end) +local checkitalics = false trackers .register("math.checkitalics", function(v) checkitalics = v end) local mathfontparameteractions = sequencers.new { name = "mathparameters", @@ -136,40 +137,45 @@ local how = { DelimiterPercent = "unscaled", } -function mathematics.scaleparameters(target,original) - if not target.properties.math_is_scaled then - local mathparameters = target.mathparameters - if mathparameters and next(mathparameters) then - local parameters = target.parameters - local factor = parameters.factor - local hfactor = parameters.hfactor - local vfactor = parameters.vfactor - for name, value in next, mathparameters do - local h = how[name] - if h == "unscaled" then - -- kept - elseif h == "horizontal" then - value = value * hfactor - elseif h == "vertical"then - value = value * vfactor - else - value = value * factor - end - mathparameters[name] = value +local function scaleparameters(mathparameters,parameters) + if mathparameters and next(mathparameters) and parameters then + local factor = parameters.factor + local hfactor = parameters.hfactor + local vfactor = parameters.vfactor + for name, value in next, mathparameters do + local h = how[name] + if h == "unscaled" then + -- kept + elseif h == "horizontal" then + value = value * hfactor + elseif h == "vertical"then + value = value * vfactor + else + value = value * factor end + mathparameters[name] = value end + end +end + +function mathematics.scaleparameters(target,original) + if not target.properties.math_is_scaled then + scaleparameters(target.mathparameters,target.parameters) target.properties.math_is_scaled = true end end -- AccentBaseHeight vs FlattenedAccentBaseHeight -function mathematics.checkaccentbaseheight(target,original) - local mathparameters = target.mathparameters - if mathparameters and mathparameters.AccentBaseHeight == 0 then - mathparameters.AccentBaseHeight = target.parameters.xheight -- needs checking - end -end +-- function mathematics.checkaccentbaseheight(target,original) +-- local mathparameters = target.mathparameters +-- if mathparameters and mathparameters.AccentBaseHeight == 0 then +-- if trace_defining then +-- report_math("zero AccentBaseHeight corrected %a @ %p",target.properties.fullname,target.parameters.size) +-- end +-- mathparameters.AccentBaseHeight = target.parameters.xheight -- needs checking +-- end +-- end function mathematics.overloadparameters(target,original) if use_math_goodies then @@ -183,8 +189,6 @@ function mathematics.overloadparameters(target,original) if mathematics then local parameters = mathematics.parameters local bigslots = mathematics.bigslots or mathematics.bigs --- inspect(parameters) --- print("before",mathparameters.AxisHeight) if parameters then if trace_defining then report_math("overloading math parameters in %a @ %p",target.properties.fullname,target.parameters.size) @@ -207,7 +211,6 @@ function mathematics.overloadparameters(target,original) end mathparameters[name] = newvalue end --- print("after ",mathparameters.AxisHeight) for name, value in next, parameters do local tvalue = type(value) if tvalue == "string" then @@ -250,29 +253,34 @@ local function report_tweak(fmt,target,original,...) local metadata = (original and original.shared.rawdata.metadata) or (target and target .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](...) - ) + if parameters then + 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](...) + ) + else + print("something is wrong") + end else report_mathtweak("") end end mathtweaks.subsets = { - acenorsuvxz = { 0x1D44E, 0x1D450, 0x1D452, 0x1D45B, 0x1D45C, 0x1D45F, 0x1D460, 0x1D462, 0x1D463, 0x1D465, 0x1D467 }, - bhklt = { 0x1D44F, 0x1D455, 0x1D458, 0x1D459, 0x1D461 }, - d = { 0x1D451 }, - f = { 0x1D453 }, - gjqy = { 0x1D454, 0x1D457, 0x1D45E, 0x1D466 }, - i = { 0x1D456 }, - mw = { 0x1D45A, 0x1D464 }, - p = { 0x1D45D }, - dotless = { 0x00049, 0x0004A, 0x00131, 0x00237, 0x1D6A4, 0x1D6A5 }, - integrals = { 0x0222B, 0x0222C, 0x0222D, 0x0222E, 0x0222F, 0x02230, 0x02231, 0x02232, 0x02233, 0x02A0B, 0x02A0C, 0x02A0D, 0x02A0E, 0x02A0F, 0x02A10, 0x02A11, 0x02A12, 0x02A13, 0x02A14, 0x02A15, 0x02A16, 0x02A17, 0x02A18, 0x02A19, 0x02A1A, 0x02A1B, 0x02A1C }, + acenorsuvxz = { 0x1D44E, 0x1D450, 0x1D452, 0x1D45B, 0x1D45C, 0x1D45F, 0x1D460, 0x1D462, 0x1D463, 0x1D465, 0x1D467 }, + bhklt = { 0x1D44F, 0x1D455, 0x1D458, 0x1D459, 0x1D461 }, + d = { 0x1D451 }, + f = { 0x1D453 }, + gjqy = { 0x1D454, 0x1D457, 0x1D45E, 0x1D466 }, + i = { 0x1D456 }, + mw = { 0x1D45A, 0x1D464 }, + p = { 0x1D45D }, + dotless = { 0x00049, 0x0004A, 0x00131, 0x00237, 0x1D6A4, 0x1D6A5 }, + integrals = { 0x0222B, 0x0222C, 0x0222D, 0x0222E, 0x0222F, 0x02230, 0x02231, 0x02232, 0x02233, 0x02A0B, 0x02A0C, 0x02A0D, 0x02A0E, 0x02A0F, 0x02A10, 0x02A11, 0x02A12, 0x02A13, 0x02A14, 0x02A15, 0x02A16, 0x02A17, 0x02A18, 0x02A19, 0x02A1A, 0x02A1B, 0x02A1C, 0x02320, 0x02321 }, + horizontalfences = { 0x023B4, 0x023B5, 0x023DC, 0x023DD, 0x023DE, 0x023DF, 0x023E0, 0x023E1 }, -- not really used } local function getalso(target,original) @@ -519,7 +527,7 @@ do else report_mathtweak("invalid dimension entry %U",k) end --- character.tweaked = true +-- character.tweaked = true if v.all then local nxt = character.next if nxt then @@ -594,10 +602,6 @@ do report_mathtweak(parameters.text or "no message") end -end - -do - function mathtweaks.showinfo(target,original,parameters) local mathparameters = target.mathparameters for k, v in sortedhash(mathparameters) do @@ -650,7 +654,7 @@ do end end if trace_tweaking and count > 0 then - report_mathtweak("%i variants wiped",count) + report_tweak("%i variants wiped",target,original,count) end end end @@ -677,7 +681,7 @@ do end end if trace_tweaking and count > 0 then - report_mathtweak("%i permanent replacements",count) + report_tweak("%i permanent replacements",target,original,count) end end end @@ -698,7 +702,7 @@ do end end if trace_tweaking and count > 0 then - report_mathtweak("%i permanent substitutions",count) + report_tweak("%i permanent substitutions",target,original,count) end end end @@ -741,7 +745,6 @@ do end for k, v in next, list do -- no need for sortedhash(list) unless we report --- for k, v in sortedhash(list) do -- no need for sortedhash(list) unless we report stepper(k,function(n) -- todo: also make stepper accept a table add(v,n) end) @@ -766,7 +769,7 @@ do -- end if trace_tweaking and count > 0 then - report_mathtweak("%i kern pairs",count) + report_tweak("%i kern pairs",target,original,count) end end end @@ -775,16 +778,6 @@ end do - function mathtweaks.variants(target,original,parameters) - report_mathtweak("todo: remove 'variants' tweak from goodie file") - end - - mathtweaks.variant = mathtweaks.variants - -end - -do - -- see changed hack in math-fbk local nps = fonts.helpers.newprivateslot @@ -956,35 +949,35 @@ do unicode = 0x002D, -- hyphen minus }, ["unary plus"] = { - original = 0x002B, - extend = .5, - squeeze = .5, - width = .5, - height = .5, - yoffset = .2, - mode = 2, - wline = .5, - unicode = 0x002B, + original = 0x002B, + extend = .5, + squeeze = .5, + width = .5, + height = .5, + yoffset = .2, + mode = 2, + wline = .5, + unicode = 0x002B, }, ["unary plus minus"] = { - original = 0x00B1, - extend = .5, - squeeze = .5, - width = .5, - height = .5, - yoffset = .2, - mode = 2, - wline = .5, + original = 0x00B1, + extend = .5, + squeeze = .5, + width = .5, + height = .5, + yoffset = .2, + mode = 2, + wline = .5, }, ["unary minus plus"] = { - original = 0x2213, - extend = .5, - squeeze = .5, - width = .5, - height = .5, - yoffset = .2, - mode = 2, - wline = .5, + original = 0x2213, + extend = .5, + squeeze = .5, + width = .5, + height = .5, + yoffset = .2, + mode = 2, + wline = .5, }, } @@ -1015,7 +1008,7 @@ do v = table.combine(p,v) p.preset = nil else - goto NEXT + goto next end end local charslot = v.original @@ -1033,7 +1026,7 @@ do end processedprivates[name] = v end - ::NEXT:: + ::next:: end end mathtweaks.dimensions(target,original,{ @@ -1051,12 +1044,17 @@ do local targetcharacters= target.characters local factor = tonumber(parameters.factor) or 0 if factor ~= 0 then + local count = 0 for k, v in next, targetcharacters do local a = v.topanchor if a and a > 0 then v.topanchor = a * factor + count = count + 1 end end + if trace_tweaking and count > 0 then + report_tweak("%i top anchors fixed",target,original,count) + end end end @@ -1069,20 +1067,26 @@ do -- actually this should be a an engine feature driven by category because we don't -- want this in display mode .. only a test for MS and HH - local issymbol = characters.is_symbol +-- local issymbol = characters.is_symbol +-- +-- function mathtweaks.oldstylemath(target,original,parameters) +-- local chardata = characters.data +-- local characters = target.characters +-- local axis = target.mathparameters.AxisHeight +-- local delta = (parameters.factor or .1) * axis +-- target.mathparameters.AxisHeight = (axis - delta) +-- for k, v in sortedhash(characters) do +-- if issymbol[k] then -- quick hack, engine knows +-- print("old style math",k,chardata[k].description) +-- v.yoffset = -delta +-- v.height = (v.height or 0) - delta +-- v.depth = (v.depth or 0) - delta +-- end +-- end +-- end function mathtweaks.oldstylemath(target,original,parameters) - local characters = target.characters - local axis = target.mathparameters.AxisHeight - local delta = (parameters.factor or .1) * axis - target.mathparameters.AxisHeight = (axis - delta) - for k, v in sortedhash(characters) do - if issymbol[k] then -- quick hack, engine knows - v.yoffset = -delta - v.height = (v.height or 0) - delta - v.depth = (v.depth or 0) - delta - end - end + -- not relevant end end @@ -1170,7 +1174,7 @@ do else local done = false local italic = c.italic - if move then + if move and not c.advance then -- advance check prevents double move local width = c.width or 0 c.advance = width if correct then @@ -1183,23 +1187,14 @@ do if topanchor then c.topanchor = topanchor + llx end --- if c.bottomleft or c.topleft then --- print("BEFORE",c.bottomleft,c.topleft,llx) --- c.bottomleft = (c.bottomleft or 0) - llx --- c.topleft = (c.topleft or 0) - llx --- print("AFTER",c.bottomleft,c.topleft,llx) --- else - c.bottomleft = (c.bottomleft or 0) - llx - c.topleft = (c.topleft or 0) - llx --- end + c.bottomleft = (c.bottomleft or 0) - llx + c.topleft = (c.topleft or 0) - llx done = true end end if italic and italic ~= 0 then c.width = width + italic --- print(">>>",bottomright) c.bottomright = - italic --- c.bottomright = c.bottomright - italic done = true else c.width = width @@ -1223,18 +1218,36 @@ do goto smaller ::smaller:: s = c.smaller + ::variants:: + -- no italics here anyway butr we could check them some day else break end end end local list = parameters.list -- todo: ranges - if type(list) == "string" then + if list == "letters" or parameters.letters then + local chardata = characters.data + for k, v in sortedhash(targetcharacters) do + if v.italic then + local d = chardata[v.unicode] + local c = d and d.category + if c == "ll" or c == "lu" then + step(k) + end + end + end + return + elseif not list or list == "all" or list == true or parameters.all then + list = sortedkeys(targetcharacters) + elseif type(list) == "string" then list = { list } end for i=1,#list do local l = list[i] - if type(l) == "table" then + if not l then + -- can be false + elseif type(l) == "table" then for i=1,#l do step(i,l[i]) end @@ -1258,7 +1271,9 @@ do mathtweaks.wipeaccents = mathtweaks.wipeanchors function mathtweaks.wipeitalics(target,original,parameters) - wipe(target,original,parameters,"italic") + if not checkitalics then + wipe(target,original,parameters,"italic") + end end function mathtweaks.moveitalics(target,original,parameters) @@ -1295,7 +1310,7 @@ do mathtweaks.topaccents = mathtweaks.topanchors - function mathtweaks.limits(target,original,parameters) + function mathtweaks.movelimits(target,original,parameters) local characters = target.characters local list = parameters.list if list then @@ -1310,16 +1325,18 @@ do local c = characters[u] if c then local italic = c.italic - if italic and italic ~= 0 then - local width = c.width or 0 - local half = (italic/2) * factor - c.topanchor = width + half - c.bottomanchor = width - half - c.bottomright = - italic - c.italic = nil - if trace_tweaking then - -- todo + if italic then + if italic ~= 0 then + local width = c.width or 0 + local half = (italic/2) * factor + c.topanchor = width + half + c.bottomanchor = width - half + c.bottomright = - italic + if trace_tweaking then + -- todo + end end + c.italic = nil end local s = c.smaller if s then @@ -1348,6 +1365,9 @@ do relocate(k,tonumber(v) or factor) end end + if not next(done) then + report_tweak("no need to move limits",target,original) + end end end @@ -2028,11 +2048,11 @@ do end data.height = depth data.depth = height -if data.rorrim then - -- the original does the magic -else - data.yoffset = depth - height -end + if data.rorrim then + -- the original does the magic + else + data.yoffset = depth - height + end end local smaller = data.smaller if smaller then @@ -2315,10 +2335,8 @@ do local parameters = target.parameters local linewidth = target.MathConstants.RadicalRuleThickness -- make option local basechar = characters[radical] - local baseheight = basechar.height -/2 - local basedepth = basechar.depth -/2 + local baseheight = basechar.height/2 + local basedepth = basechar.depth/2 local basetotal = baseheight + basedepth local used = baseheight -- @@ -2846,19 +2864,41 @@ end do - function mathtweaks.diagnose(target,original,parameters) - local characters = target.characters - for k, v in sortedhash(characters) do - local italic = v.italic - if italic then - report_tweak("italics: %U %p",target,original,k,italic) + function mathtweaks.parameters(target,original,parameters) + local newparameters = parameters.list + local oldparameters = target.mathparameters + if newparameters and oldparameters then + newparameters = copytable(newparameters) + scaleparameters(newparameters,target.parameters) + for name, newvalue in next, newparameters do + oldparameters[name] = newvalue end end --- inspect(characters[0xF0929]) + end + + function mathtweaks.bigslots(target,original,parameters) + local list = parameters.list + if list then + target.bigslots = list + end end end +-- do +-- +-- function mathtweaks.diagnose(target,original,parameters) +-- local characters = target.characters +-- for k, v in sortedhash(characters) do +-- local italic = v.italic +-- if italic then +-- report_tweak("italics: %C %p",target,original,k,italic) +-- end +-- end +-- end +-- +-- end + do function mathtweaks.setoptions(target,original,parameters) @@ -2944,105 +2984,110 @@ do end) function mathtweaks.replacealphabets(target,original,parameters) - local feature = parameters.feature - local features = target.specification.features.normal - if not feature or features[feature] == true then - local list = parameters.list - if list then - local definedfont = fonts.definers.internal - local copiedglyph = fonts.handlers.vf.math.copy_glyph + local list = parameters.list + if list then + local features = target.specification.features.normal + local definedfont = fonts.definers.internal + local copiedglyph = fonts.handlers.vf.math.copy_glyph -- does a deep copy, including parts and so - local getsubstitution = fonts.handlers.otf.getsubstitution - local fontdata = fonts.hashes.identifiers - -- - local fonts = target.fonts - local size = target.size - local characters = target.characters - -- compact: size = 655360 - if not fonts then - fonts = { } - target.fonts = fonts - end - if #fonts == 0 then - fonts[1] = { id = 0, size = size } -- self, will be resolved later - end - for i=1,#list do - local entry = list[i] - local filename = entry.filename - local feature = entry.feature - local thesource = entry.source - local thetarget = entry.target or thesource - if thesource and thetarget then - local sourcerange = type(thesource) == "table" and thesource or blocks[thesource] -- .gaps - local targetrange = type(thetarget) == "table" and thetarget or blocks[thetarget] -- .gaps - if sourcerange and targetrange then - local firsttarget = targetrange.first - local firstsource = sourcerange.first - local lastsource = sourcerange.last or firstsource - if firstsource and firsttarget then - local offset = firsttarget - firstsource - local topovershoot = entry.topovershoot - if filename then - local rscale = entry.rscale or 1 -- todo - size = size * rscale -- maybe use scale in vf command - -- load font, todo: set language and script, the effect hack is ugly - local fullname = filename - local effect = features.effect - if effect then - fullname = fullname .. "*" .. effects["effect={"..effect.."}"] - end - local id = definedfont { - name = fullname, - size = size, - } - local chars = fontchars[id] - local dropin = fontdata[id] - local index = #fonts + 1 - fonts[index] = { id = id, size = size } - -- copy characters - for s=firstsource,lastsource do - local t = s + offset - local sourceunicode = mathgaps[s] or s + local getsubstitution = fonts.handlers.otf.getsubstitution + local fontdata = fonts.hashes.identifiers + -- + local fonts = target.fonts + local size = target.size + local characters = target.characters +-- local descriptions = target.descriptions + -- compact: size = 655360 + if not fonts then + fonts = { } + target.fonts = fonts + end + if #fonts == 0 then + fonts[1] = { id = 0, size = size } -- self, will be resolved later + end + for i=1,#list do + local entry = list[i] + local filename = entry.filename or parameters.filename + local feature = entry.feature + local thesource = entry.source + local thetarget = entry.target or thesource + if thesource and thetarget then + local sourcerange = type(thesource) == "table" and thesource or blocks[thesource] -- .gaps + local targetrange = type(thetarget) == "table" and thetarget or blocks[thetarget] -- .gaps + if sourcerange and targetrange then + local firsttarget = targetrange.first + local firstsource = sourcerange.first + local lastsource = sourcerange.last or firstsource + if firstsource and firsttarget then + local offset = firsttarget - firstsource + local topovershoot = entry.topovershoot + if filename then + local rscale = entry.rscale or 1 -- todo + size = size * rscale -- maybe use scale in vf command + -- load font, todo: set language and script, the effect hack is ugly + local fullname = filename + local effect = features.effect + if effect then + fullname = fullname .. "*" .. effects["effect={"..effect.."}"] + end + local id = definedfont { + name = fullname, + size = size, + } + local chars = fontchars[id] + local dropin = fontdata[id] + local index = #fonts + 1 + fonts[index] = { id = id, size = size } + -- copy characters + for s=firstsource,lastsource do + local t = s + offset + local sourceunicode = mathgaps[s] or s + if chars[sourceunicode] then local targetunicode = mathgaps[t] or t if feature then sourceunicode = getsubstitution(dropin,sourceunicode,feature,true,"math","dflt") or sourceunicode end if trace_tweaking then - report_mathtweak("copying %s %U from file %a to %s %U",thesource,sourceunicode,filename,thetarget,targetunicode) + report_tweak("copying %s %U from file %a to %s %U",target,original,thesource,sourceunicode,filename,thetarget,targetunicode) end characters[targetunicode] = copiedglyph(target,characters,chars,sourceunicode,index) +-- description end - elseif feature then - for s=firstsource,lastsource do - local t = s + offset - local sourceunicode = mathgaps[s] or s - local targetunicode = mathgaps[t] or t - local variant = getsubstitution(original,sourceunicode,feature,true,"math","dflt") - local data = characters[variant] - if data then - if trace_tweaking then - report_mathtweak("copying %s %U from feature %a to %s %U",thesource,sourceunicode,feature,thetarget,targetunicode) - end - characters[targetunicode] = copytable(data) + end + elseif feature then + for s=firstsource,lastsource do + local t = s + offset + local sourceunicode = mathgaps[s] or s + local targetunicode = mathgaps[t] or t + local variant = getsubstitution(original,sourceunicode,feature,true,"math","dflt") + local data = characters[variant] + if data then + if trace_tweaking then + report_tweak("copying %s %U from feature %a to %s %U",target,original,thesource,sourceunicode,feature,thetarget,targetunicode) end + characters[targetunicode] = copytable(data) +-- description end - else - for s=firstsource,lastsource do - local t = s + offset - local sourceunicode = mathgaps[s] or s - local targetunicode = mathgaps[t] or t + end + else + for s=firstsource,lastsource do + local t = s + offset + local sourceunicode = mathgaps[s] or s + local targetunicode = mathgaps[t] or t + if sourceunicode ~= targetunicode then local data = characters[sourceunicode] if data then if trace_tweaking then - report_mathtweak("copying %s %U to %s %U",thesource,sourceunicode,thetarget,targetunicode) + report_tweak("copying %s %U to %s %U",target,original,thesource,sourceunicode,thetarget,targetunicode) end characters[targetunicode] = copytable(data) +-- description end end end - else - -- error end + else + -- error end end end @@ -3050,13 +3095,38 @@ do end end -end + function mathtweaks.fallbacks(target,original,parameters) + local fallbacks = target.specification.fallbacks + if fallbacks then + local definitions = fonts.collections.definitions[fallbacks] + if definitions then + local list = { } + for i=1,#definitions do + local definition = definitions[i] + -- local check = definition.check + -- local force = definition.force + local first = definition.start + local last = definition.stop + local offset = definition.offset or first + list[#list+1] = { + filename = definition.font, + rscale = definition.rscale or 1, + source = { first = first, last = last }, + target = { first = offset, last = offset + (last - first) }, + } + end + mathtweaks.replacealphabets(target,original,{ + tweak = "replacealphabets", + list = list, + } ) + end + end + end -local apply_tweaks = true +end -directives.register("math.applytweaks", function(v) - apply_tweaks = v; -end) +local apply_tweaks = true directives.register("math.applytweaks", function(v) apply_tweaks = v end) +local applied_tweaks = 0 local function applytweaks(when,target,original) if apply_tweaks then @@ -3073,6 +3143,8 @@ local function applytweaks(when,target,original) local mathematics = goodie.mathematics local tweaks = mathematics and mathematics.tweaks if type(tweaks) == "table" then + statistics.starttiming(mathtweaks) + applied_tweaks = applied_tweaks + 1 tweaks = tweaks[when] if type(tweaks) == "table" then if trace_defining then @@ -3084,19 +3156,24 @@ local function applytweaks(when,target,original) if type(tweak) == "table" then local action = mathtweaks[tweak.tweak or ""] if action then - local version = tweak.version - if version and version ~= target.tweakversion then - report_math("skipping tweak %a version %a",tweak.tweak,version) - elseif original then - action(target,original,tweak) - else - action(target,tweak) + local feature = tweak.feature + local features = target.specification.features.normal + if not feature or features[feature] == true then + local version = tweak.version + if version and version ~= target.tweakversion then + report_math("skipping tweak %a version %a",tweak.tweak,version) + elseif original then + action(target,original,tweak) + else + action(target,tweak) + end end end end end end end + statistics.stoptiming(mathtweaks) end tweaked[when] = true target.tweaked = tweaked @@ -3125,6 +3202,12 @@ function mathematics.tweakaftercopyingfont(target,original) end end +statistics.register("math tweaking time",function() + if applied_tweaks > 0 then + return string.format("%s seconds, %s math goodie tables", statistics.elapsedtime(mathtweaks),applied_tweaks) + end +end) + do local defaults = { @@ -3146,9 +3229,12 @@ do }, } + local reported = table.setmetatableindex("table") + function mathematics.checkaftercopyingfont(target,original) local mathparameters = target.mathparameters -- why not hasmath if mathparameters then + local chardata = characters.data local characters = target.characters -- for i=1,#defaults do @@ -3179,6 +3265,35 @@ do local ca = mathematics.alphabets.ca.tf register(sr.ucletters,ca.ucletters) register(sr.lcletters,ca.lcletters) + -- + if checkitalics then + local italics = 0 + local metadata = original.shared.rawdata.metadata + local fontname = metadata and metadata.fontname or false + for k, v in sortedhash(characters) do + local italic = v.italic + if italic then + local unicode = v.unicode + if unicode and not reported[fontname][unicode] then -- there can be variants + local data = chardata[unicode] + local description = data.description or "" + local category = data.category or "--" + report_tweak("italics: %C %p %s %s",target,original,k,italic,category,description) + reported[fontname][unicode] = true + end + italics = italics + 1 + end + end + if italics > 0 then + report_tweak("still has %i italics",target,original,italics) + goto NEXTSTEP + end + end + + target.properties.mathitalics = false + target.properties.textitalics = false + ::NEXTSTEP:: + -- more to come end end @@ -3195,7 +3310,7 @@ end sequencers.appendaction("mathparameters","system","mathematics.overloadparameters") sequencers.appendaction("mathparameters","system","mathematics.scaleparameters") -sequencers.appendaction("mathparameters","system","mathematics.checkaccentbaseheight") -- should go in lfg instead +----------.appendaction("mathparameters","system","mathematics.checkaccentbaseheight") -- should go in lfg instead ----------.appendaction("mathparameters","system","mathematics.checkprivateparameters") -- after scaling ! sequencers.appendaction("beforecopyingcharacters","system","mathematics.tweakbeforecopyingfont") @@ -3329,111 +3444,3 @@ interfaces.implement { -- can be public with two times "integerargument" context(kind) end } - -local stack = { } - -function mathematics.registerfallbackid(n,id,name) - if trace_collecting then - report_math("resolved fallback font %i, name %a, id %a, used %a", - n,name,id,fontproperties[id].fontname) - end - stack[#stack][n] = id -end - -interfaces.implement { -- will be shared with text - name = "registerfontfallbackid", - arguments = { "integer", "integer", "string" }, - actions = mathematics.registerfallbackid, -} - --- todo: run this directly .. can be done in luametatex - -function mathematics.resolvefallbacks(target,specification,fallbacks) - local definitions = fonts.collections.definitions[fallbacks] - if definitions then - local size = specification.size -- target.size - local list = { } - insert(stack,list) - context.pushcatcodes("prt") -- context.unprotect() - for i=1,#definitions do - local definition = definitions[i] - local name = definition.font - local features = definition.features or "" - local size = size * (definition.rscale or 1) - -- compact: size = 655360 - context.font_fallbacks_register_math(i,name,features,size) - if trace_collecting then - report_math("registering fallback font %i, name %a, size %a, features %a",i,name,size,features) - end - end - context.popcatcodes() - end -end - -function mathematics.finishfallbacks(target,specification,fallbacks) - local list = remove(stack) - if list and #list > 0 then - local definitions = fonts.collections.definitions[fallbacks] - if definitions and #definitions > 0 then - if trace_collecting then - report_math("adding fallback characters to font %a",specification.hash) - end - ----- definedfont = fonts.definers.internal - local copiedglyph = fonts.handlers.vf.math.copy_glyph - local fonts = target.fonts - local size = specification.size -- target.size - local characters = target.characters - -- compact: size = 655360 - if not fonts then - fonts = { } - target.fonts = fonts - end - if #fonts == 0 then - fonts[1] = { id = 0, size = size } -- self, will be resolved later - end - local done = { } - for i=1,#definitions do - local definition = definitions[i] - local name = definition.font - local start = definition.start - local stop = definition.stop - local gaps = definition.gaps - local check = definition.check - local force = definition.force - local rscale = definition.rscale or 1 - local offset = definition.offset or start - local id = list[i] - if id then - local index = #fonts + 1 - fonts[index] = { id = id, size = size } - local chars = fontchars[id] - local function remap(unic,unicode,gap) - if check and not chars[unicode] then - return - end - if force or (not done[unic] and not characters[unic]) then - if trace_collecting then - report_math("replacing math character %C by %C using vector %a and font id %a for %a%s%s", - unic,unicode,fallbacks,id,fontproperties[id].fontname,check and ", checked",gap and ", gap plugged") - end - characters[unic] = copiedglyph(target,characters,chars,unicode,index) - done[unic] = true - end - end - local step = offset - start - for unicode = start, stop do - remap(unicode + step,unicode,false) - end - if gaps then - for unic, unicode in next, gaps do - remap(unic,unicode,true) - remap(unicode,unicode,true) - end - end - end - end - elseif trace_collecting then - report_math("no fallback characters added to font %a",specification.hash) - end - end -end diff --git a/tex/context/base/mkxl/math-ini.mkxl b/tex/context/base/mkxl/math-ini.mkxl index 29af7a659..c1beb071c 100644 --- a/tex/context/base/mkxl/math-ini.mkxl +++ b/tex/context/base/mkxl/math-ini.mkxl @@ -1958,6 +1958,13 @@ %D For previous variants of the function styling you can check the git repository %D end April 2022. +% \startTEXpage[offset=1dk] +% $\sin(x) = 10$ +% \m[functionstyle=sans]{\sin(x) = 10} +% \startformula \sin(x) = 10 \stopformula +% \startformula[functionstyle=sans] \sin(x) = 10 \stopformula +% \stopTEXpage + \protected\def\math_function_handle#1#2#3% {\begingroup \letdummyparameter\c!mathlimits\empty @@ -1989,6 +1996,17 @@ \egroup \endgroup} +\appendtoks + \edef\p_functionstyle{\formulaparameter\c!functionstyle}% + \ifempty\p_functionstyle\else + \letmathematicsparameter\c!functionstyle\p_functionstyle + \fi + \edef\p_functioncolor{\formulaparameter\c!functioncolor}% + \ifempty\p_functioncolor\else + \letmathematicsparameter\c!functioncolor\p_functioncolor + \fi +\to \everybeforedisplayformula + \permanent\tolerant\protected\def\mfunction [#1]{\math_function_handle{#1}\firstofoneargument} \permanent\tolerant\protected\def\mfunctionlabeltext[#1]{\math_function_handle{#1}\mathlabeltext} @@ -3948,7 +3966,7 @@ \installcorenamespace{mathrules} -\permanent\protected\def\enablemathrules{\letgvalue{\??mathrules\fontclass}\plusone} +\permanent\protected\def\enablemathrules{\gletcsname\??mathrules\fontclass\endcsname\plusone} \appendtoks \mathrulesmode\ifcsname\??mathrules\fontclass\endcsname @@ -4378,13 +4396,13 @@ %D \stoptyping \definesystemattribute[mathaxis][public] - \def\math_axis_inject#1% {\mathatom \s!class \mathghostcode \s!unpack { \showmakeup[strut]% todo: shortcut + \scratchdimen.5\Umathfractionrule\mathstyle \srule - \s!height \dimexpr\Umathaxis\mathstyle+.2\points\relax - \s!depth -\dimexpr\Umathaxis\mathstyle-.2\points\relax + \s!height \dimexpr\Umathaxis\mathstyle+\scratchdimen\relax + \s!depth -\dimexpr\Umathaxis\mathstyle-\scratchdimen\relax \s!attr \mathaxisattribute #1% \relax}} diff --git a/tex/context/base/mkxl/math-vfu.lmt b/tex/context/base/mkxl/math-vfu.lmt index 906c9ccf6..86d1fca0d 100644 --- a/tex/context/base/mkxl/math-vfu.lmt +++ b/tex/context/base/mkxl/math-vfu.lmt @@ -651,6 +651,7 @@ local function copy_glyph(main,target,original,unicode,slot) kerns = olddata.kerns, mathkerns = olddata.mathkerns, tounicode = olddata.tounicode, + smaller = olddata.smaller, commands = { { "slot", slot, nextglyph } }, } local newnextglyph = addprivate(main,formatters["M-N-%H"](nextglyph),newnextdata) @@ -703,7 +704,12 @@ local function copy_glyph(main,target,original,unicode,slot) vvi.glyph = addprivate(main,formatters["M-V-%H"](oldglyph),newdata) end end - return newdata + local smaller = olddata.smaller + if smaller then + local smallerdata = copy_glyph(main,target,original,smaller,slot) + glyphdata.smaller = addprivate(main,formatters["M-S-%H"](smaller),smallerdata) + end + return glyphdata end end diff --git a/tex/context/base/mkxl/mlib-int.lmt b/tex/context/base/mkxl/mlib-int.lmt index 9165d5423..686f1985d 100644 --- a/tex/context/base/mkxl/mlib-int.lmt +++ b/tex/context/base/mkxl/mlib-int.lmt @@ -7,8 +7,6 @@ if not modules then modules = { } end modules ['mlib-int'] = { } local factor = number.dimenfactors.bp -local mpstring = mp.string -local injectnumeric = mp.inject.numeric local isdimen = tex.isdimen local iscount = tex.iscount local getdimen = tex.getdimen @@ -53,49 +51,78 @@ end do - local d_paperheight = isdimen("paperheight") registerdirect("PaperHeight", function() return getdimen(d_paperheight) * factor end) - local d_paperwidth = isdimen("paperwidth") registerdirect("PaperWidth", function() return getdimen(d_paperwidth) * factor end) - local d_printpaperheight = isdimen("printpaperheight") registerdirect("PrintPaperHeight", function() return getdimen(d_printpaperheight) * factor end) - local d_printpaperwidth = isdimen("printpaperwidth") registerdirect("PrintPaperWidth", function() return getdimen(d_printpaperwidth) * factor end) - local d_topspace = isdimen("topspace") registerdirect("TopSpace", function() return getdimen(d_topspace) * factor end) - local d_bottomspace = isdimen("bottomspace") registerdirect("BottomSpace", function() return getdimen(d_bottomspace) * factor end) - local d_backspace = isdimen("backspace") registerdirect("BackSpace", function() return getdimen(d_backspace) * factor end) - local d_cutspace = isdimen("cutspace") registerdirect("CutSpace", function() return getdimen(d_cutspace) * factor end) - local d_makeupheight = isdimen("makeupheight") registerdirect("MakeupHeight", function() return getdimen(d_makeupheight) * factor end) - local d_makeupwidth = isdimen("makeupwidth") registerdirect("MakeupWidth", function() return getdimen(d_makeupwidth) * factor end) - local d_topheight = isdimen("topheight") registerdirect("TopHeight", function() return getdimen(d_topheight) * factor end) - local d_topdistance = isdimen("topdistance") registerdirect("TopDistance", function() return getdimen(d_topdistance) * factor end) - local d_headerheight = isdimen("headerheight") registerdirect("HeaderHeight", function() return getdimen(d_headerheight) * factor end) - local d_headerdistance = isdimen("headerdistance") registerdirect("HeaderDistance", function() return getdimen(d_headerdistance) * factor end) - local d_textheight = isdimen("textheight") registerdirect("TextHeight", function() return getdimen(d_textheight) * factor end) - local d_footerdistance = isdimen("footerdistance") registerdirect("FooterDistance", function() return getdimen(d_footerdistance) * factor end) - local d_footerheight = isdimen("footerheight") registerdirect("FooterHeight", function() return getdimen(d_footerheight) * factor end) - local d_bottomdistance = isdimen("bottomdistance") registerdirect("BottomDistance", function() return getdimen(d_bottomdistance) * factor end) - local d_bottomheight = isdimen("bottomheight") registerdirect("BottomHeight", function() return getdimen(d_bottomheight) * factor end) - local d_leftedgewidth = isdimen("leftedgewidth") registerdirect("LeftEdgeWidth", function() return getdimen(d_leftedgewidth) * factor end) - local d_leftedgedistance = isdimen("leftedgedistance") registerdirect("LeftEdgeDistance", function() return getdimen(d_leftedgedistance) * factor end) - local d_leftmarginwidth = isdimen("leftmarginwidth") registerdirect("LeftMarginWidth", function() return getdimen(d_leftmarginwidth) * factor end) - local d_leftmargindistance = isdimen("leftmargindistance") registerdirect("LeftMarginDistance", function() return getdimen(d_leftmargindistance) * factor end) - local d_textwidth = isdimen("textwidth") registerdirect("TextWidth", function() return getdimen(d_textwidth) * factor end) - local d_rightmargindistance = isdimen("rightmargindistance") registerdirect("RightMarginDistance", function() return getdimen(d_rightmargindistance) * factor end) - local d_rightmarginwidth = isdimen("rightmarginwidth") registerdirect("RightMarginWidth", function() return getdimen(d_rightmarginwidth) * factor end) - local d_rightedgedistance = isdimen("rightedgedistance") registerdirect("RightEdgeDistance", function() return getdimen(d_rightedgedistance) * factor end) - local d_rightedgewidth = isdimen("rightedgewidth") registerdirect("RightEdgeWidth", function() return getdimen(d_rightedgewidth) * factor end) - -end - -do - - local onrightpage = structures.pages.on_right - - registerdirect("InnerMarginDistance", function() return getdimen(onrightpage() and d_leftmargindistance or d_rightmargindistance) * factor end) - registerdirect("InnerMarginWidth", function() return getdimen(onrightpage() and d_leftmarginwidth or d_rightmarginwidth ) * factor end) - registerdirect("OuterMarginDistance", function() return getdimen(onrightpage() and d_rightmargindistance or d_leftmargindistance ) * factor end) - registerdirect("OuterMarginWidth", function() return getdimen(onrightpage() and d_rightmarginwidth or d_leftmarginwidth ) * factor end) - registerdirect("InnerEdgeDistance", function() return getdimen(onrightpage() and d_leftmargindistance or d_rightmargindistance) * factor end) - registerdirect("InnerEdgeWidth", function() return getdimen(onrightpage() and d_leftmarginwidth or d_rightmarginwidth ) * factor end) - registerdirect("OuterEdgeDistance", function() return getdimen(onrightpage() and d_rightedgedistance or d_leftedgedistance ) * factor end) - registerdirect("OuterEdgeWidth", function() return getdimen(onrightpage() and d_rightedgewidth or d_leftedgewidth ) * factor end) + -- These get swapped so the d_ numbers change. + + registerdirect("PaperHeight", function() return getdimen("paperheight") * factor end) + registerdirect("PaperWidth", function() return getdimen("paperwidth") * factor end) + registerdirect("PrintPaperHeight", function() return getdimen("printpaperheight") * factor end) + registerdirect("PrintPaperWidth", function() return getdimen("printpaperwidth") * factor end) + registerdirect("BackSpace", function() return getdimen("backspace") * factor end) + registerdirect("CutSpace", function() return getdimen("cutspace") * factor end) + + registerdirect("LeftEdgeWidth", function() return getdimen("leftedgewidth") * factor end) + registerdirect("LeftEdgeDistance", function() return getdimen("leftedgedistance") * factor end) + registerdirect("LeftMarginWidth", function() return getdimen("leftmarginwidth") * factor end) + registerdirect("LeftMarginDistance", function() return getdimen("leftmargindistance") * factor end) + registerdirect("RightMarginDistance", function() return getdimen("rightmargindistance") * factor end) + registerdirect("RightMarginWidth", function() return getdimen("rightmarginwidth") * factor end) + registerdirect("RightEdgeDistance", function() return getdimen("rightedgedistance") * factor end) + registerdirect("RightEdgeWidth", function() return getdimen("rightedgewidth") * factor end) + + -- leftmargintotal rightmargintotal -- not yet + -- leftedgetotal rightedgetotal + -- leftsidetotal rightsidetotal + -- leftcombitotal rightcombitotal + -- innermargintotal outermargintotal + -- inneredgetotal outeredgetotal + -- innercombitotal outercombitotal + -- innersidetotal outersidetotal + + local d_leftedgewidth = isdimen("leftedgewidth") + local d_leftedgedistance = isdimen("leftedgedistance") + local d_leftmarginwidth = isdimen("leftmarginwidth") + local d_leftmargindistance = isdimen("leftmargindistance") + local d_rightmargindistance = isdimen("rightmargindistance") + local d_rightmarginwidth = isdimen("rightmarginwidth") + local d_rightedgedistance = isdimen("rightedgedistance") + local d_rightedgewidth = isdimen("rightedgewidth") + + registerdirect("InnerMarginDistance", function() return getdimen(d_leftmargindistance ) * factor end) + registerdirect("InnerMarginWidth", function() return getdimen(d_leftmarginwidth ) * factor end) + registerdirect("OuterMarginDistance", function() return getdimen(d_rightmargindistance) * factor end) + registerdirect("OuterMarginWidth", function() return getdimen(d_rightmarginwidth ) * factor end) + registerdirect("InnerEdgeDistance", function() return getdimen(d_leftmargindistance ) * factor end) + registerdirect("InnerEdgeWidth", function() return getdimen(d_leftmarginwidth ) * factor end) + registerdirect("OuterEdgeDistance", function() return getdimen(d_rightedgedistance ) * factor end) + registerdirect("OuterEdgeWidth", function() return getdimen(d_rightedgewidth ) * factor end) + + -- local onrightpage = structures.pages.on_right + + -- registerdirect("InnerMarginDistance", function() return getdimen(onrightpage() and "leftmargindistance" or "rightmargindistance") * factor end) + -- registerdirect("InnerMarginWidth", function() return getdimen(onrightpage() and "leftmarginwidth" or "rightmarginwidth" ) * factor end) + -- registerdirect("OuterMarginDistance", function() return getdimen(onrightpage() and "rightmargindistance" or "leftmargindistance" ) * factor end) + -- registerdirect("OuterMarginWidth", function() return getdimen(onrightpage() and "rightmarginwidth" or "leftmarginwidth" ) * factor end) + -- registerdirect("InnerEdgeDistance", function() return getdimen(onrightpage() and "leftmargindistance" or "rightmargindistance") * factor end) + -- registerdirect("InnerEdgeWidth", function() return getdimen(onrightpage() and "leftmarginwidth" or "rightmarginwidth" ) * factor end) + -- registerdirect("OuterEdgeDistance", function() return getdimen(onrightpage() and "rightedgedistance" or "leftedgedistance" ) * factor end) + -- registerdirect("OuterEdgeWidth", function() return getdimen(onrightpage() and "rightedgewidth" or "leftedgewidth" ) * factor end) + + -- These have stable d_ numbers. + + local d_topspace = isdimen("topspace") registerdirect("TopSpace", function() return getdimen(d_topspace) * factor end) + local d_bottomspace = isdimen("bottomspace") registerdirect("BottomSpace", function() return getdimen(d_bottomspace) * factor end) + local d_makeupheight = isdimen("makeupheight") registerdirect("MakeupHeight", function() return getdimen(d_makeupheight) * factor end) + local d_makeupwidth = isdimen("makeupwidth") registerdirect("MakeupWidth", function() return getdimen(d_makeupwidth) * factor end) + local d_topheight = isdimen("topheight") registerdirect("TopHeight", function() return getdimen(d_topheight) * factor end) + local d_topdistance = isdimen("topdistance") registerdirect("TopDistance", function() return getdimen(d_topdistance) * factor end) + local d_headerheight = isdimen("headerheight") registerdirect("HeaderHeight", function() return getdimen(d_headerheight) * factor end) + local d_headerdistance = isdimen("headerdistance") registerdirect("HeaderDistance", function() return getdimen(d_headerdistance) * factor end) + local d_textheight = isdimen("textheight") registerdirect("TextHeight", function() return getdimen(d_textheight) * factor end) + local d_footerdistance = isdimen("footerdistance") registerdirect("FooterDistance", function() return getdimen(d_footerdistance) * factor end) + local d_footerheight = isdimen("footerheight") registerdirect("FooterHeight", function() return getdimen(d_footerheight) * factor end) + local d_bottomdistance = isdimen("bottomdistance") registerdirect("BottomDistance", function() return getdimen(d_bottomdistance) * factor end) + local d_bottomheight = isdimen("bottomheight") registerdirect("BottomHeight", function() return getdimen(d_bottomheight) * factor end) + local d_textwidth = isdimen("textwidth") registerdirect("TextWidth", function() return getdimen(d_textwidth) * factor end) end diff --git a/tex/context/base/mkxl/node-ali.lmt b/tex/context/base/mkxl/node-ali.lmt index 4b52f2d4b..69b1e7aa0 100644 --- a/tex/context/base/mkxl/node-ali.lmt +++ b/tex/context/base/mkxl/node-ali.lmt @@ -314,7 +314,7 @@ interfaces.implement { end, } --- Let's put it here (for now) (some locals above) .. will be cleaned up! +-- This will go to math-ali.lmt do @@ -538,7 +538,7 @@ deltas = { } for count=1,#records do if count == lindex then if centered and overflow then - lwidth = lwidth - tex.getdimen("d_math_eqalign_number_distance") + lwidth = lwidth - texgetdimen("d_math_eqalign_number_distance") end setwidth(records[count],lwidth) elseif count == rindex then diff --git a/tex/context/base/mkxl/scrn-ini.lmt b/tex/context/base/mkxl/scrn-ini.lmt index 82b9bd02e..2d01a1a28 100644 --- a/tex/context/base/mkxl/scrn-ini.lmt +++ b/tex/context/base/mkxl/scrn-ini.lmt @@ -52,3 +52,11 @@ interfaces.implement { actions = setidentityvariable, arguments = "2 strings", } + +interfaces.implement { + name = "setautoprefix", + actions = function(prefix) + backends.codeinjections.setautoprefix(prefix) + end, + arguments = "string", +} diff --git a/tex/context/base/mkxl/scrn-ini.mklx b/tex/context/base/mkxl/scrn-ini.mklx index 8a7f89c42..1308ff6ec 100644 --- a/tex/context/base/mkxl/scrn-ini.mklx +++ b/tex/context/base/mkxl/scrn-ini.mklx @@ -206,4 +206,8 @@ \scrn_identity_document {date}\c!date \to \everystartdocument % or stop +\appendtoks + \clf_setautoprefix{\interactionparameter\c!prefix}% +\to \everysetupinteraction + \protect \endinput diff --git a/tex/context/base/mkxl/tabl-ntb.mkxl b/tex/context/base/mkxl/tabl-ntb.mkxl index d36d113e1..a0e85e839 100644 --- a/tex/context/base/mkxl/tabl-ntb.mkxl +++ b/tex/context/base/mkxl/tabl-ntb.mkxl @@ -1219,7 +1219,8 @@ \ifcsname\tabl_ntb_row_pattern\c_tabl_ntb_current_row\c_tabl_ntb_current_col\endcsname \scratchcounter\numexpr\c_tabl_ntb_maximum_row-\c_tabl_ntb_current_row+\plusone\relax \ifnum\tabl_ntb_get_row\c_tabl_ntb_current_row\c_tabl_ntb_current_col>\scratchcounter - \tabl_ntb_set_row\c_tabl_ntb_current_row\c_tabl_ntb_current_col{\the\scratchcounter}% +% \tabl_ntb_set_row\c_tabl_ntb_current_row\c_tabl_ntb_current_col{\the\scratchcounter}% + \tabl_ntb_set_row\c_tabl_ntb_current_row\c_tabl_ntb_current_col\scratchcounter \fi \fi \tabl_ntb_let_ht\c_tabl_ntb_current_row\c_tabl_ntb_current_col\zeropoint diff --git a/tex/context/base/mkxl/trac-vis.lmt b/tex/context/base/mkxl/trac-vis.lmt index e00944413..e2c79022a 100644 --- a/tex/context/base/mkxl/trac-vis.lmt +++ b/tex/context/base/mkxl/trac-vis.lmt @@ -48,6 +48,7 @@ local getattr = nuts.getattr local getsubtype = nuts.getsubtype local getbox = nuts.getbox local getlist = nuts.getlist +local getprev = nuts.getprev local getnext = nuts.getnext local getboth = nuts.getboth local getwhd = nuts.getwhd @@ -1313,7 +1314,9 @@ local ruledstrut do if getsubtype(current) == strut_code then local w = strut_size local a = getattr(current,a_mathaxis) + setattr(current,a_layer,l_strut) if a then + local p = getprev(current) local b, e for n in traverseid(math_code,current) do e = n @@ -1336,17 +1339,17 @@ local ruledstrut do head, current, rule = nuts.remove(head,current) local kern = new_kern(-w) if a == 2 then - insertnodebefore(head,e,kern) - insertnodebefore(head,e,rule) + head = insertnodebefore(head,e,kern) + head = insertnodebefore(head,e,rule) else insertnodeafter(head,b,kern) insertnodeafter(head,b,rule) end + current = p else setwidth(current,w) - head, current = insertnodeafter(head,current,new_kern(w)) + head, current = insertnodeafter(head,current,new_kern(-w)) end - setattr(current,a_layer,l_strut) end end return head, current diff --git a/tex/context/base/mkxl/type-imp-euler.mkxl b/tex/context/base/mkxl/type-imp-euler.mkxl new file mode 100644 index 000000000..c0a3f73f6 --- /dev/null +++ b/tex/context/base/mkxl/type-imp-euler.mkxl @@ -0,0 +1,67 @@ +%D \module +%D [ file=type-otf, +%D version=2007.07.30, +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=Euler, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\loadtypescriptfile[texgyre] +\loadtypescriptfile[dejavu] + +\definefontfeature[pagellaovereuler][pagellaovereuler=yes] +\definefontfeature[euleroverpagella][euleroverpagella=yes] + +\starttypescriptcollection[pagella-eulernova] + + \starttypescript [\s!serif] [eulernova] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Serif] [\s!file:euler.otf] [\s!features=\s!default] + \stoptypescript + + \starttypescript [\s!math] [eulernova] [\s!name] + \definefontsynonym [\s!MathRoman] [\s!file:euler.otf] [\s!features={\s!math\mathsizesuffix,mathextra},\s!goodies=euler-math] + \stoptypescript + + \starttypescript [pagella-eulernova] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [pagella] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] [\s!rscale=0.9] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [eulernova] [\s!default] + \quittypescriptscanning + \stoptypescript + + \starttypescript [eulernova] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [eulernova] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] [\s!rscale=0.9] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [eulernova] [\s!default] + \quittypescriptscanning + \stoptypescript + + \starttypescript [\s!math] [euleroverpagella] [\s!name] + \definefontsynonym [\s!MathRoman] [texgyrepagella-math] [\s!features={\s!math\mathsizesuffix,euleroverpagella,mathextra},\s!fallbacks=euleroverpagella,\s!goodies=pagella-math] + \stoptypescript + + \starttypescript [\s!math] [pagellaovereuler] [\s!name] + \definefontsynonym [\s!MathRoman] [\s!file:euler.otf] [\s!features={\s!math\mathsizesuffix,pagellaovereuler,mathextra},\s!fallbacks=pagellaovereuler,\s!goodies=euler-math] + \stoptypescript + + \starttypescript [pagella-with-euler,euleroverpagella] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [pagella] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] [\s!rscale=0.9] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [euleroverpagella] [\s!default] + \quittypescriptscanning + \stoptypescript + + \starttypescript [euler-with-pagella,pagellaovereuler] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [eulernova] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] [\s!rscale=0.9] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [pagellaovereuler] [\s!default] + \quittypescriptscanning + \stoptypescript + +\stoptypescriptcollection diff --git a/tex/context/base/mkxl/typo-itc.lmt b/tex/context/base/mkxl/typo-itc.lmt index f2f6c428e..f0b6980f4 100644 --- a/tex/context/base/mkxl/typo-itc.lmt +++ b/tex/context/base/mkxl/typo-itc.lmt @@ -82,7 +82,7 @@ function typesetters.italics.forcevariant(variant) forcedvariant = variant end --- We use the same key as the tex font handler. So, if a valua has already be set, we +-- We use the same key as the tex font handler. So, if a value has already be set, we -- use that one. local function setitalicinfont(font,char) @@ -108,6 +108,7 @@ local function setitalicinfont(font,char) end end end + -- we don't want to do this each time so we also set zero here if trace_italics then report_italics("setting italic correction of %C of font %a to %p",char,font,italic) end |