diff options
Diffstat (limited to 'tex')
35 files changed, 1558 insertions, 986 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index c52d4b787..ca7fb128c 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{2021.11.11 19:18} +\newcontextversion{2021.11.13 20:33} %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 ea17f2dc5..1bf322dc6 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{2021.11.11 19:18} +\edef\contextversion{2021.11.13 20:33} %D For those who want to use this: diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index ce96e7c81..3925a3fce 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{2021.11.11 19:18} +\newcontextversion{2021.11.13 20:33} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index c2178e2b1..cd2f873c5 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{2021.11.11 19:18} +\edef\contextversion{2021.11.13 20:33} %D Kind of special: diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index 307cf3c68..b2a3f9b3c 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -105,7 +105,7 @@ return { "accentskewhalfmathcontrolcode", "accentskewapplymathcontrolcode", "accentitalickernmathcontrolcode", "delimiteritalickernmathcontrolcode", "noorditalickernmathcontrolcode", "charitalicwidthmathcontrolcode", "charitalicnoreboxmathcontrolcode", "boxednoitalickernmathcontrolcode", "nostaircasekernmathcontrolcode", - "textitalickernmathcontrolcode", "noscriptitalickernmathcontrolcode", + "textitalickernmathcontrolcode", "noscriptitalickernmathcontrolcode", "italicshapekernmathcontrolcode", -- "noligaturingglyphoptioncode", "nokerningglyphoptioncode", "noexpansionglyphoptioncode", "noprotrusionglyphoptioncode", "noleftkerningglyphoptioncode", "noleftligaturingglyphoptioncode", "norightkerningglyphoptioncode", "norightligaturingglyphoptioncode", diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 28cb886a3..5124f23cf 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 19c31285c..896b8856a 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-syn.lua b/tex/context/base/mkiv/strc-syn.lua index f8b78b940..8933baea1 100644 --- a/tex/context/base/mkiv/strc-syn.lua +++ b/tex/context/base/mkiv/strc-syn.lua @@ -29,6 +29,12 @@ local splitter = sorters.splitters.utf synonyms.collected = collected synonyms.tobesaved = tobesaved +local progressions = { } -- false=not_yet_shown true=shown + +local variables = interfaces.variables +local v_all = variables.all +local v_current = variables.current + local function initializer() collected = synonyms.collected tobesaved = synonyms.tobesaved @@ -86,12 +92,6 @@ function synonyms.register(class,kind,spec) local tag = definition.tag or "" data.metadata.kind = kind -- runtime, not saved in format (yet) if not hash[tag] then --- if definition.used == nil then --- definition.used = false --- end --- if definition.shown == nil then --- definition.shown = false --- end local entries = data.entries entries[#entries+1] = spec hash[tag] = spec @@ -130,20 +130,52 @@ function synonyms.isshown(class,tag) return okay and okay.definition.shown or false end -function synonyms.resetused(class) +local function resetused(class) for tag, data in next, tobesaved[class].hash do --- data.definition.used = false data.definition.used = nil end end -function synonyms.resetshown(class) +local function resetshown(class) for tag, data in next, tobesaved[class].hash do --- data.definition.shown = false data.definition.shown = nil end end +local function resetlist(class) + for tag, data in next, tobesaved[class].hash do + data.definition.list = nil + end +end + +local function resetall(class) + for tag, data in next, tobesaved[class].hash do + local definition = data.definition + definition.used = nil + definition.shown = nil + definition.list = nil + end +end + +synonyms.resetused = resetused +synonyms.resetshown = resetshown +synonyms.resetlist = resetlist +synonyms.resetall = resetall + +function synonyms.reset(class,what) + if what == "progress" then + progressions = { } + elseif what == "used" then + resetused(class) + elseif what == "shown" then + resetshown(class) + elseif what == "list" then + resetlist(class) + else + resetall(class) + end +end + function synonyms.synonym(class,tag) local data = tobesaved[class] local okay = data.hash[tag] @@ -153,6 +185,9 @@ function synonyms.synonym(class,tag) definition.list = true context(definition.synonym) end + if progressions[tag] == nil then + progressions[tag] = false -- not yet shown + end end function synonyms.meaning(class,tag) @@ -169,10 +204,10 @@ end synonyms.compare = sorters.comparers.basic -- (a,b) function synonyms.filter(data,options) - local result = { } - local entries = data.entries - local all = options and options.criterium == interfaces.variables.all - if all then + local result = { } + local entries = data.entries + local criterium = options and options.criterium + if criterium == v_all then for i=1,#entries do result[i] = entries[i] end @@ -181,9 +216,17 @@ function synonyms.filter(data,options) local entry = entries[i] local definition = entry.definition if definition.list then - result[#result+1] = entry + local tag = definition.tag + local done = progressions[tag] + if done == false then + result[#result+1] = entry + progressions[tag] = true + end end end + if criterium == v_current then + progressions = { } + end end data.result = result end @@ -282,8 +325,10 @@ implement { name = "registerusedsynonym", actions = synonyms.registerused, arg implement { name = "registershownsynonym", actions = synonyms.registershown, arguments = "2 strings" } implement { name = "synonymmeaning", actions = synonyms.meaning, arguments = "2 strings" } implement { name = "synonymname", actions = synonyms.synonym, arguments = "2 strings" } -implement { name = "resetusedsynonyms", actions = synonyms.resetused, arguments = "string" } -implement { name = "resetshownsynonyms", actions = synonyms.resetshown, arguments = "string" } +-- { name = "resetusedsynonyms", actions = resetused, arguments = "string" } +-- { name = "resetshownsynonyms", actions = resetshown, arguments = "string" } +-- { name = "resetlistsynonyms", actions = resetlist, arguments = "string" } +implement { name = "resetsynonyms", actions = synonyms.reset, arguments = "2 strings" } implement { name = "doifelsesynonymused", diff --git a/tex/context/base/mkiv/strc-syn.mkiv b/tex/context/base/mkiv/strc-syn.mkiv index cdede1d0d..e93141bde 100644 --- a/tex/context/base/mkiv/strc-syn.mkiv +++ b/tex/context/base/mkiv/strc-syn.mkiv @@ -101,6 +101,31 @@ %D %D The lists are constructions (like descriptions are) and can be set up %D likewise. +%D +%D You can show the currently accessed entries as follows: +%D +%D \starttyping +%D \startchapter[title=One] +%D test \FIRST\ test test \THIRD\ test \blank +%D \placelistofsynonyms[myabbreviation] +%D \resetsynonymsprogress[myabbreviation] % reset state +%D \stopchapter +%D +%D \startchapter[title=Two] +%D test \FIRST\ test test \SECOND\ test \blank +%D \placelistofsynonyms[myabbreviation][criterium=current] +%D \resetsynonymsprogress[myabbreviation] % reset state +%D \stopchapter +%D +%D \startchapter[title=Three] +%D test test test test test test \blank +%D \placelistofsynonyms[myabbreviation][criterium=current] % also reset state +%D \stopchapter +%D +%D \startchapter[title=All] +%D \placelistofsynonyms[myabbreviation][criterium=all] +%D \stopchapter +%D \stoptyping % todo: add 'define only' option to descriptions, then add sorting (also based on key) % and call to definition -> replaces this module @@ -319,8 +344,11 @@ \unexpanded\def\currentsynonymmeaning {\clf_synonymmeaning {\currentsimplelist}{\currentsynonymtag}} \unexpanded\def\doifelsecurrentsynonymused {\clf_doifelsesynonymused {\currentsimplelist}{\currentsynonymtag}} \unexpanded\def\doifelsecurrentsynonymshown{\clf_doifelsesynonymshown{\currentsimplelist}{\currentsynonymtag}} -\unexpanded\def\resetusedsynonyms [#1]{\clf_resetusedsynonyms {#1}} -\unexpanded\def\resetshownsynonyms [#1]{\clf_resetshownsynonyms {#1}} +\unexpanded\def\resetusedsynonyms [#1]{\clf_resetsynonyms{#1}{used}} +\unexpanded\def\resetshownsynonyms [#1]{\clf_resetsynonyms{#1}{shown}} +\unexpanded\def\resetlistsynonyms [#1]{\clf_resetsynonyms{#1}{list}} +\unexpanded\def\resetsynonyms [#1]{\clf_resetsynonyms{#1}{all}} +\unexpanded\def\resetsynonymsprogress [#1]{\clf_resetsynonyms{#1}{progress}} \let\rawsynonymname \clf_synonymname \let\rawsynonymmeaning\clf_synonymmeaning diff --git a/tex/context/base/mkiv/util-prs.lua b/tex/context/base/mkiv/util-prs.lua index f74bc3b12..438fa78bd 100644 --- a/tex/context/base/mkiv/util-prs.lua +++ b/tex/context/base/mkiv/util-prs.lua @@ -643,7 +643,7 @@ local function ranger(first,last,n,action) end end -local cardinal = lpegpatterns.cardinal / tonumber +local cardinal = (lpegpatterns.hexadecimal + lpegpatterns.cardinal) / tonumber local spacers = lpegpatterns.spacer^0 local endofstring = lpegpatterns.endofstring diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index 722ac0f09..a3b960aa0 100644 --- a/tex/context/base/mkxl/cont-new.mkxl +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.11.11 19:18} +\newcontextversion{2021.11.13 20:33} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl index 8d42981fc..b52808856 100644 --- a/tex/context/base/mkxl/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \immutable\edef\contextformat {\jobname} -\immutable\edef\contextversion{2021.11.11 19:18} +\immutable\edef\contextversion{2021.11.13 20:33} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/driv-shp.lmt b/tex/context/base/mkxl/driv-shp.lmt index ace259954..5e3bfd703 100644 --- a/tex/context/base/mkxl/driv-shp.lmt +++ b/tex/context/base/mkxl/driv-shp.lmt @@ -165,10 +165,13 @@ local flush_character do local saved_r = pos_r pos_r = lefttoright_code - local data = fontdata[font] -- hm, so why pass data - local fnt = font - local fonts = data.fonts - local siz = (data.parameters.factor or 1)/65536 + local xoffset = data.xoffset + local yoffset = data.yoffset + + local data = fontdata[font] -- offsets etc + local fnt = font + local fonts = data.fonts + local siz = (data.parameters.factor or 1)/65536 -- An alternative where we (here) locally define handlers like this: -- @@ -182,6 +185,16 @@ local flush_character do -- work as expected (so we end up in a nesting loop). I remember hitting this somewhat -- unexpected feature before. +if xoffset and xoffset ~= 0 then + if factor ~= 0 then + xoffset = xoffset + xoffset * factor / refactored -- expansion + end + pos_h = pos_h + xoffset * sx +end +if yoffset and yoffset ~= 0 then + pos_v = pos_v + yoffset * sy +end + -- we assume resolved fonts: id mandate but maybe also size local function flushchar(fnt,chr,f,e) -- can't be moved out of the function due to binding locals @@ -528,14 +541,6 @@ local flush_character do else -- kind of messy that we do orientation here and offsets elsewhere .. this might change local orientation = data.orientation -- 0 (none), 1, 2, 3 or 4 (none) --- local x = data.xoffset --- local y = data.yoffset --- if x then --- pos_h = pos_h + x * sx --- end --- if y then --- pos_v = pos_v + y * sy --- end if orientation and (orientation == 1 or orientation == 3) then -- we can get weird charactersbox tracing here pushorientation(orientation,pos_h,pos_v) diff --git a/tex/context/base/mkxl/good-mth.lmt b/tex/context/base/mkxl/good-mth.lmt index 033b2cb88..0c8311efe 100644 --- a/tex/context/base/mkxl/good-mth.lmt +++ b/tex/context/base/mkxl/good-mth.lmt @@ -26,11 +26,9 @@ local trace_defining = false trackers.register("math.defining", function( local report_math = logs.reporter("mathematics","initializing") local nuts = nodes.nuts - local setlink = nuts.setlink local nodepool = nuts.pool - local new_kern = nodepool.kern local new_glyph = nodepool.glyph local new_hlist = nodepool.hlist @@ -38,174 +36,6 @@ local new_vlist = nodepool.vlist local insertnodeafter = nuts.insertafter -local helpers = fonts.helpers -local upcommand = helpers.commands.up -local rightcommand = helpers.commands.right -local charcommand = helpers.commands.char -local prependcommands = helpers.prependcommands - --- experiment, we have to load the definitions immediately as they precede --- the definition so they need to be initialized in the typescript - -local function withscriptcode(tfmdata,unicode,data,action) - if type(unicode) == "string" then - local p, u = match(unicode,"^(.-):(.-)$") - if u then - u = tonumber(u) - if u then - local slots = fonts.helpers.mathscriptslots(tfmdata,u) - if slots then - if p == "*" then - action(u,data) - if type(slots) == "number" then - action(slots,data) - else - for i=1,#slots do - action(slots[i],data) - end - end - else - p = tonumber(p) - if p then - if type(slots) == "number" then - action(slots,data) - else - action(slots[p],data) - end - end - end - end - end - end - else - action(unicode,data) - end -end - -local function finalize(tfmdata,feature,value,...) --- if tfmdata.mathparameters then -- funny, cambria text has this - local goodies = tfmdata.goodies - if goodies then - local virtualized = mathematics.virtualized - for i=1,#goodies do - local goodie = goodies[i] - local mathematics = goodie.mathematics - local dimensions = mathematics and mathematics.dimensions - if dimensions then - if trace_defining then - report_math("overloading dimensions in %a @ %p",tfmdata.properties.fullname,tfmdata.parameters.size) - end - local characters = tfmdata.characters - local descriptions = tfmdata.descriptions - local parameters = tfmdata.parameters - local factor = parameters.factor - local hfactor = parameters.hfactor - local vfactor = parameters.vfactor - -- - tfmdata.type = "virtual" - tfmdata.properties.virtualized = true - -- - local function overloadone(unicode,data) - local character = characters[unicode] - if not character then - local c = virtualized[unicode] - if c then - character = characters[c] - end - end - if character then - local width = data.width - local height = data.height - local depth = data.depth - if trace_defining and (width or height or depth) then - report_math("overloading dimensions of %C, width %p, height %p, depth %p", - unicode,width or 0,height or 0,depth or 0) - end - if width then character.width = width * hfactor end - if height then character.height = height * vfactor end - if depth then character.depth = depth * vfactor end - -- - local xoffset = data.xoffset - local yoffset = data.yoffset - if xoffset == "llx" then - local d = descriptions[unicode] - if d then - xoffset = - d.boundingbox[1] - character.width = character.width + xoffset * hfactor - xoffset = rightcommand[xoffset] - else - xoffset = nil - end - elseif xoffset and xoffset ~= 0 then - xoffset = rightcommand[xoffset * hfactor] - else - xoffset = nil - end - if yoffset and yoffset ~= 0 then - yoffset = upcommand[yoffset * vfactor] - else - yoffset = nil - end - if xoffset or yoffset then - local commands = character.commands - if commands then - prependcommands(commands,yoffset,xoffset) - else --- character.commands = { { "offset", xoffset or 0, yoffset or 0, unicode } } - local slot = charcommand[unicode] - if xoffset and yoffset then - character.commands = { xoffset, yoffset, slot } - elseif xoffset then - character.commands = { xoffset, slot } - else - character.commands = { yoffset, slot } - end - end - end - elseif trace_defining then - report_math("no overloading dimensions of %C, not in font",unicode) - end - end - local function overload(dimensions) - for unicode, data in next, dimensions do - withscriptcode(tfmdata,unicode,data,overloadone) - end - end - if value == nil then - value = { "default" } - end - if value == "all" or value == true then - for name, value in next, dimensions do - overload(value) - end - else - if type(value) == "string" then - value = utilities.parsers.settings_to_array(value) - end - if type(value) == "table" then - for i=1,#value do - local d = dimensions[value[i]] - if d then - overload(d) - end - end - end - end - end - end - end -end - -registerotffeature { - name = "mathdimensions", - description = "manipulate math dimensions", - -- default = true, - manipulators = { - base = finalize, - node = finalize, - } -} - local function initialize(goodies) local mathgoodies = goodies.mathematics if mathgoodies then @@ -233,122 +63,6 @@ end fontgoodies.register("mathematics", initialize) --- local enabled = false directives.register("fontgoodies.mathkerning",function(v) enabled = v end) - -local function initialize(tfmdata) --- if enabled and tfmdata.mathparameters then -- funny, cambria text has this - if tfmdata.mathparameters then -- funny, cambria text has this - local goodies = tfmdata.goodies - if goodies then - local characters = tfmdata.characters - if characters[0x1D44E] then -- 119886 - -- we have at least an italic a - for i=1,#goodies do - local mathgoodies = goodies[i].mathematics - if mathgoodies then - local kerns = mathgoodies.kerns - if kerns then - local function kernone(unicode,data) - local chardata = characters[unicode] - if chardata and (not chardata.mathkerns or data.force) then - chardata.mathkerns = data - end - end - for unicode, data in next, kerns do - withscriptcode(tfmdata,unicode,data,kernone) - end - return - end - end - end - else - return -- no proper math font anyway - end - end - end -end - -registerotffeature { - name = "mathkerns", - description = "math kerns", - -- default = true, - initializers = { - base = initialize, - node = initialize, - } -} - --- math italics (not really needed) --- --- it would be nice to have a \noitalics\font option - -local function initialize(tfmdata) - local goodies = tfmdata.goodies - if goodies then - local shared = tfmdata.shared - for i=1,#goodies do - local mathgoodies = goodies[i].mathematics - if mathgoodies then - local mathitalics = mathgoodies.italics - if mathitalics then - local properties = tfmdata.properties - if properties.setitalics then - mathitalics = mathitalics[file.nameonly(properties.name)] or mathitalics - if mathitalics then - if trace_goodies then - report_goodies("loading mathitalics for font %a",properties.name) - end - local corrections = mathitalics.corrections - local defaultfactor = mathitalics.defaultfactor - -- properties.mathitalic_defaultfactor = defaultfactor -- we inherit outer one anyway (name will change) - if corrections then - fontgoodies.registerpostprocessor(tfmdata, function(tfmdata) -- this is another tfmdata (a copy) - -- better make a helper so that we have less code being defined - local properties = tfmdata.properties - local parameters = tfmdata.parameters - local characters = tfmdata.characters - properties.mathitalic_defaultfactor = defaultfactor - properties.mathitalic_defaultvalue = defaultfactor * parameters.quad - if trace_goodies then - report_goodies("assigning mathitalics for font %a",properties.name) - end - local quad = parameters.quad - local hfactor = parameters.hfactor - for k, v in next, corrections do - local c = characters[k] - if c then - if v > -1 and v < 1 then - c.italic = v * quad - else - c.italic = v * hfactor - end - else - report_goodies("invalid mathitalics entry %U for font %a",k,properties.name) - end - end - end) - end - return -- maybe not as these can accumulate - end - end - end - end - end - end -end - -registerotffeature { - name = "mathitalics", - description = "additional math italic corrections", - -- default = true, - initializers = { - base = initialize, - node = initialize, - } -} - --- fontgoodies.register("mathitalics", initialize) - local function mathradicalaction(n,h,v,font,mchar,echar) local characters = fontcharacters[font] local mchardata = characters[mchar] @@ -471,3 +185,284 @@ registerotffeature { node = initialize, } } + +-- local helpers = fonts.helpers +-- local upcommand = helpers.commands.up +-- local rightcommand = helpers.commands.right +-- local charcommand = helpers.commands.char +-- local prependcommands = helpers.prependcommands +-- +-- -- experiment, we have to load the definitions immediately as they precede +-- -- the definition so they need to be initialized in the typescript +-- +-- local function withscriptcode(tfmdata,unicode,data,action) +-- if type(unicode) == "string" then +-- local p, u = match(unicode,"^(.-):(.-)$") +-- if u then +-- u = tonumber(u) +-- if u then +-- local slots = helpers.mathscriptslots(tfmdata,u) +-- if slots then +-- if p == "*" then +-- action(u,data) +-- if type(slots) == "number" then +-- action(slots,data) +-- else +-- for i=1,#slots do +-- action(slots[i],data) +-- end +-- end +-- else +-- p = tonumber(p) +-- if p then +-- if type(slots) == "number" then +-- action(slots,data) +-- else +-- action(slots[p],data) +-- end +-- end +-- end +-- end +-- end +-- end +-- else +-- action(unicode,data) +-- end +-- end +-- +-- local function finalize(tfmdata,feature,value,...) +-- -- if tfmdata.mathparameters then -- funny, cambria text has this +-- local goodies = tfmdata.goodies +-- if goodies then +-- local virtualized = mathematics.virtualized +-- for i=1,#goodies do +-- local goodie = goodies[i] +-- local mathematics = goodie.mathematics +-- local dimensions = mathematics and mathematics.dimensions +-- if dimensions then +-- if trace_defining then +-- report_math("overloading dimensions in %a @ %p",tfmdata.properties.fullname,tfmdata.parameters.size) +-- end +-- local characters = tfmdata.characters +-- local descriptions = tfmdata.descriptions +-- local parameters = tfmdata.parameters +-- local factor = parameters.factor +-- local hfactor = parameters.hfactor +-- local vfactor = parameters.vfactor +-- -- +-- tfmdata.type = "virtual" +-- tfmdata.properties.virtualized = true +-- -- +-- local function overloadone(unicode,data) +-- local character = characters[unicode] +-- if not character then +-- local c = virtualized[unicode] +-- if c then +-- character = characters[c] +-- end +-- end +-- if character then +-- local width = data.width +-- local height = data.height +-- local depth = data.depth +-- if trace_defining and (width or height or depth) then +-- report_math("overloading dimensions of %C, width %p, height %p, depth %p", +-- unicode,width or 0,height or 0,depth or 0) +-- end +-- if width then character.width = width * hfactor end +-- if height then character.height = height * vfactor end +-- if depth then character.depth = depth * vfactor end +-- -- +-- local xoffset = data.xoffset +-- local yoffset = data.yoffset +-- if xoffset == "llx" then +-- local d = descriptions[unicode] +-- if d then +-- xoffset = - d.boundingbox[1] +-- character.width = character.width + xoffset * hfactor +-- xoffset = rightcommand[xoffset] +-- else +-- xoffset = nil +-- end +-- elseif xoffset and xoffset ~= 0 then +-- xoffset = rightcommand[xoffset * hfactor] +-- else +-- xoffset = nil +-- end +-- if yoffset and yoffset ~= 0 then +-- yoffset = upcommand[yoffset * vfactor] +-- else +-- yoffset = nil +-- end +-- if xoffset or yoffset then +-- local commands = character.commands +-- if commands then +-- prependcommands(commands,yoffset,xoffset) +-- else +-- -- character.commands = { { "offset", xoffset or 0, yoffset or 0, unicode } } +-- local slot = charcommand[unicode] +-- if xoffset and yoffset then +-- character.commands = { xoffset, yoffset, slot } +-- elseif xoffset then +-- character.commands = { xoffset, slot } +-- else +-- character.commands = { yoffset, slot } +-- end +-- end +-- end +-- elseif trace_defining then +-- report_math("no overloading dimensions of %C, not in font",unicode) +-- end +-- end +-- local function overload(dimensions) +-- for unicode, data in next, dimensions do +-- withscriptcode(tfmdata,unicode,data,overloadone) +-- end +-- end +-- if value == nil then +-- value = { "default" } +-- end +-- if value == "all" or value == true then +-- for name, value in next, dimensions do +-- overload(value) +-- end +-- else +-- if type(value) == "string" then +-- value = utilities.parsers.settings_to_array(value) +-- end +-- if type(value) == "table" then +-- for i=1,#value do +-- local d = dimensions[value[i]] +-- if d then +-- overload(d) +-- end +-- end +-- end +-- end +-- end +-- end +-- end +-- end +-- +-- registerotffeature { +-- name = "mathdimensions", +-- description = "manipulate math dimensions", +-- -- default = true, +-- manipulators = { +-- base = finalize, +-- node = finalize, +-- } +-- } + +-- local enabled = false directives.register("fontgoodies.mathkerning",function(v) enabled = v end) +-- +-- local function initialize(tfmdata) +-- if tfmdata.mathparameters then -- funny, cambria text has this +-- local goodies = tfmdata.goodies +-- if goodies then +-- local characters = tfmdata.characters +-- if characters[0x1D44E] then -- 119886 +-- -- we have at least an italic a +-- for i=1,#goodies do +-- local mathgoodies = goodies[i].mathematics +-- if mathgoodies then +-- local kerns = mathgoodies.kerns +-- if kerns then +-- local function kernone(unicode,data) +-- local chardata = characters[unicode] +-- if chardata and (not chardata.mathkerns or data.force) then +-- chardata.mathkerns = data +-- end +-- end +-- for unicode, data in next, kerns do +-- withscriptcode(tfmdata,unicode,data,kernone) +-- end +-- return +-- end +-- end +-- end +-- else +-- return -- no proper math font anyway +-- end +-- end +-- end +-- end +-- +-- registerotffeature { +-- name = "mathkerns", +-- description = "math kerns", +-- -- default = true, +-- initializers = { +-- base = initialize, +-- node = initialize, +-- } +-- } + +-- -- math italics (not really needed) +-- +-- local function initialize(tfmdata) +-- local goodies = tfmdata.goodies +-- if goodies then +-- local shared = tfmdata.shared +-- for i=1,#goodies do +-- local mathgoodies = goodies[i].mathematics +-- if mathgoodies then +-- local mathitalics = mathgoodies.italics +-- if mathitalics then +-- local properties = tfmdata.properties +-- if properties.setitalics then +-- mathitalics = mathitalics[file.nameonly(properties.name)] or mathitalics +-- if mathitalics then +-- if trace_goodies then +-- report_goodies("loading mathitalics for font %a",properties.name) +-- end +-- local corrections = mathitalics.corrections +-- local defaultfactor = mathitalics.defaultfactor +-- -- properties.mathitalic_defaultfactor = defaultfactor -- we inherit outer one anyway (name will change) +-- if corrections then +-- fontgoodies.registerpostprocessor(tfmdata, function(tfmdata) -- this is another tfmdata (a copy) +-- -- better make a helper so that we have less code being defined +-- local properties = tfmdata.properties +-- local parameters = tfmdata.parameters +-- local characters = tfmdata.characters +-- properties.mathitalic_defaultfactor = defaultfactor +-- properties.mathitalic_defaultvalue = defaultfactor * parameters.quad +-- if trace_goodies then +-- report_goodies("assigning mathitalics for font %a",properties.name) +-- end +-- local quad = parameters.quad +-- local hfactor = parameters.hfactor +-- for k, v in next, corrections do +-- local c = characters[k] +-- if c then +-- if v > -1 and v < 1 then +-- c.italic = v * quad +-- else +-- c.italic = v * hfactor +-- end +-- else +-- report_goodies("invalid mathitalics entry %U for font %a",k,properties.name) +-- end +-- end +-- end) +-- end +-- return -- maybe not as these can accumulate +-- end +-- end +-- end +-- end +-- end +-- end +-- end +-- +-- registerotffeature { +-- name = "mathitalics", +-- description = "additional math italic corrections", +-- -- default = true, +-- initializers = { +-- base = initialize, +-- node = initialize, +-- } +-- } +-- +-- -- fontgoodies.register("mathitalics", initialize) diff --git a/tex/context/base/mkxl/lpdf-lmt.lmt b/tex/context/base/mkxl/lpdf-lmt.lmt index 463cc8352..6e6812d81 100644 --- a/tex/context/base/mkxl/lpdf-lmt.lmt +++ b/tex/context/base/mkxl/lpdf-lmt.lmt @@ -260,7 +260,7 @@ function flushers.updatefontstate(font) end end --- helpers +-- helpers (maybe in collapse mode we have to go %.9N) local f_cm = formatters["%.6N %.6N %.6N %.6N %.6N %.6N cm"] local f_tm = formatters["%.6N %.6N %.6N %.6N %.6N %.6N Tm"] @@ -570,11 +570,15 @@ do tj_delta = 0 cw = 0 -- + -- print("setup font",where) + -- fs = fontparameters.size * bpfactor if collapse then local sc = fs / 10 if f then - sc = sc * f +-- sc = sc * f +sx = sx * f +sy = sy * f end -- kind of special: if format == "opentype" or format == "type1" then @@ -587,7 +591,9 @@ do tmry = tmry * sc else if f then - fs = fs * f +-- fs = fs * f +sx = sx * f +sy = sy * f end -- kind of special: if format == "opentype" or format == "type1" then @@ -697,22 +703,18 @@ do flushers.character = function(current,pos_h,pos_v,pos_r,font,char,data,f,e,factor,sx,sy) -- ,naturalwidth,width) if sx ~= f_x_scale or sy ~= f_y_scale or need_tf or font ~= f_cur or f_pdf ~= f_pdf_cur or fs ~= fs_cur or mode == "page" then -- if sx ~= f_x_scale or sy ~= f_y_scale or need_tf or font ~= f_cur or f_pdf ~= f_pdf_cur or fs ~= fs_cur then --- print("f",1) pdf_goto_textmode() setup_fontparameters(1,font,factor,f,e,sx,sy) -- too often due to page set_font() -- elseif mode == "page" then --- print("f",4) -- pdf_goto_textmode() set_font() elseif cur_f ~= f then -- when ok move up (maybe no longer needed) --- print("f",2) pdf_goto_textmode() setup_fontparameters(2,font,factor,f,e,sx,sy) set_font() -- elseif cur_tmrx ~= tmrx or cur_factor ~= factor or cur_f ~= f or cur_e ~= e then elseif cur_tmrx ~= tmrx or cur_factor ~= factor or cur_e ~= e then --- print("f",3) setup_fontparameters(3,font,factor,f,e,sx,sy) need_tm = true end diff --git a/tex/context/base/mkxl/math-act.lmt b/tex/context/base/mkxl/math-act.lmt index 56730f2eb..afaf79593 100644 --- a/tex/context/base/mkxl/math-act.lmt +++ b/tex/context/base/mkxl/math-act.lmt @@ -12,11 +12,14 @@ if not modules then modules = { } end modules ['math-act'] = { local type, next = type, next local fastcopy, insert, remove = table.fastcopy, table.insert, table.remove local formatters = string.formatters +local byte = string.byte local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end) local trace_collecting = false trackers.register("math.collecting", function(v) trace_collecting = v end) +local trace_tweaking = false trackers.register("math.tweaks", function(v) trace_tweaking = v end) local report_math = logs.reporter("mathematics","initializing") +local report_mathtweak = logs.reporter("mathematics","tweak") local context = context local commands = commands @@ -46,7 +49,7 @@ appendgroup("mathparameters","before") -- user appendgroup("mathparameters","system") -- private appendgroup("mathparameters","after" ) -- user -function fonts.constructors.assignmathparameters(original,target) +function fonts.constructors.assignmathparameters(original,target) -- wrong way around local runner = mathfontparameteractions.runner if runner then runner(original,target) @@ -186,62 +189,320 @@ end local mathtweaks = { } mathematics.tweaks = mathtweaks -local function adapt(targetcharacters,originalcharacters,k,v,compact,n) - local character = targetcharacters[k] - if character then - local width = character.width - local italic = character.italic - local offsetfactor = v[1] or 1 - local widthfactor = v[2] or 1 - local italicfactor = v[3] or 1 - if width then - character.advance = width -- so advance is oldwidth - character.xoffset = offsetfactor * width - character.width = widthfactor * width - end - if italic then - character.italic = italicfactor * italic +local function report_tweak(fmt,target,original,...) + local metadata = original.shared.rawdata.metadata + local parameters = target.parameters + report_mathtweak( + "%a, size %p, math size %i, %s", + metadata and metadata.fontname or "unknown", + parameters.size or 655360, + parameters.mathsize or 1, + string.formatters[fmt](...) + ) +end + +do + + local stepper = utilities.parsers.stepper + + local function adapt(target,original,targetcharacters,originalcharacters,k,v,compact,n) + local character = targetcharacters[k] + if character then + local width = character.width + local italic = character.italic + local offsetfactor = v[1] or 1 + local widthfactor = v[2] or 1 + local italicfactor = v[3] or 1 + if width then + character.advance = width -- so advance is oldwidth + character.xoffset = offsetfactor * width + character.width = widthfactor * width + end + if italic then + character.italic = italicfactor * italic + elseif width and italicfactor ~= 1 then + character.italic = italicfactor * width + end + if trace_tweaking then + report_tweak("adapting dimensions of %U ",target,original,k) + end + local smaller = originalcharacters[k].smaller + if compact and smaller and smaller ~= k then + adapt(target,original,targetcharacters,originalcharacters,smaller,v,compact,n+1) + end + else + report_math("no character %U",k) end - local smaller = originalcharacters[k].smaller - if compact and smaller and smaller ~= k then - adapt(targetcharacters,originalcharacters,smaller,v,compact,n+1) + end + + function mathtweaks.dimensions(target,original,parameters) + local list = parameters.list + if list then + local targetcharacters = target.characters + local originalcharacters = original.characters + local compact = target.parameters.textscale and true or false + for k, v in next, list do + local t = type(k) + if t == "number" then + adapt(target,original,targetcharacters,originalcharacters,k,v,compact,1) + elseif t == "string" then + stepper(k,function(n) adapt(target,original,targetcharacters,originalcharacters,n,v,compact,1) end) + end + end end - else - report_math("no character %U",k) end + end -function mathtweaks.dimensions(target,original,list) - local targetcharacters = target.characters - local originalcharacters = original.characters - local compact = target.parameters.textscale and true or false - for k, v in next, list do - adapt(targetcharacters,originalcharacters,k,v,compact,1) +do + + local list = { + { 0x2032, true, }, + { 0x2033, true, 0x2032, 2 }, + { 0x2034, true, 0x2032, 3 }, + { 0x2057, true, 0x2032, 4 }, + { 0x2035, false, }, + { 0x2036, false, 0x2035, 2 }, + { 0x2037, false, 0x2035, 3 }, + } + + local function fix(target,original,characters,factor,scale,newheight,code,mandate) + local char = characters[code] + if char then + local oldheight = scale * char.height + char.yoffset = newheight - oldheight + char.height = newheight + if scale ~= 1 then + char.width = scale * char.width + char.commands = { + { "slot", 0, code, scale } + } + end + if trace_tweaking then + report_tweak("fixing prime %U ",target,original,code) + end + local small = char.smaller + if small then + fix(target,original,characters,factor,scale,newheight,small,false) + end + elseif mandate then + report_math("missing %U prime in font %a",code,original.properties.fullname) + end + end + + function mathtweaks.fixprimes(target,original,parameters) + local characters = target.characters + local factor = parameters.factor or 0.85 + local scale = parameters.scale or 1 + local newheight = factor * target.mathparameters.AccentBaseHeight + for i=1,#list do + local entry = list[i] + fix(target,original,characters,factor,scale,newheight,entry[1],entry[2]) + end + end + + local function fake(target,original,characters,factor,n,single,multiple) + local csingle = characters[single] + local cmultiple = characters[multiple] + local width = csingle.width + local hoffset = factor * width + cmultiple.width = width + (n - 1) * hoffset + cmultiple.commands = { + { "offset", 0, 0, single }, + { "offset", hoffset, 0, single }, + n > 2 and { "offset", 2 * hoffset, 0, single } or nil, + n > 3 and { "offset", 3 * hoffset, 0, single } or nil, + } + if trace_tweaking then + report_tweak("faking %U with %i primes",target,original,multiple,n) + end + local ssingle = csingle.smaller + local smultiple = cmultiple.smaller + if ssingle and smultiple then + fake(target,original,characters,factor,n,ssingle,smultiple) + else + --weird font + end + end + + function mathtweaks.fakeprimes(target,original,parameters) + local characters = target.characters + local factor = parameters.factor or .75 + for i=1,#list do + local entry = list[i] + local n = entry[4] + if n then + fake(target,original,characters,factor,n,entry[3],entry[1]) + end + end end + end -function mathtweaks.action(target,original,action,...) +function mathtweaks.action(target,original,parameters) + local action = parameters.action if type(action) == "function" then - action(target,original,...) + action(target,original,parameters) + end +end + +do + + local list = { + { 0x00A0, "s", 1 }, -- nbsp + { 0x2000, "q", 1/2 }, -- enquad + { 0x2001, "q", 1 }, -- emquad + { 0x2002, "q", 1/2 }, -- enspace + { 0x2003, "q", 1 }, -- emspace + { 0x2004, "q", 1/3 }, -- threeperemspace + { 0x2005, "q", 1/4 }, -- fourperemspace + { 0x2006, "q", 1/6 }, -- sixperemspace + { 0x2007, "c", byte('0') }, -- figurespace + { 0x2008, "c", byte('.') }, -- punctuationspace + { 0x2009, "q", 1/8 }, -- breakablethinspace + { 0x200A, "q", 1/8 }, -- hairspace + { 0x200B, "q", 0 }, -- zerowidthspace + { 0x202F, "q", 1/8 }, -- narrownobreakspace + { 0x205F, "s", 1/2 }, -- math thinspace + } + + function mathtweaks.checkspacing(target,original,parameters) + local characters = target.characters + local parameters = target.parameters + for i=1,#list do + local entry = list[i] + local unicode = entry[1] + local data = characters[unicode] + if not data then + local method = entry[2] + local fraction = entry[3] + local width = 0 + if how == "c" then + width = characters[fraction].width -- char + elseif how == "s" then + width = fraction * parameters.space -- space + else + width = fraction * parameters.quad -- quad + end + if trace_tweaking then + report_tweak("setting width of %U to %p",target,original,unicode,width) + end + characters[unicode] = { width = width } + end + end end + end +do -local reported = { } + local list = { + 0x221A, + } -function mathtweaks.version(target,original,expected) - local metadata = original.shared.rawdata.metadata - if metadata then - local version = metadata.version - if version then - local fontname = metadata.fontname - -- version = tonumber(string.match(version,"%d+.%d+")) - if not reported[fontname] and version ~= expected then - report_math("tweaking %a, version %a found, version %a expected",fontname,version,expected) - reported[fontname] = true + local function fix(target,original,characters,unicode) + local data = characters[unicode] + if data then + local height = data.height or 0 + local depth = data.depth or 0 + if depth > height then + if trace_tweaking then + report_tweak("swapping height and depth of radical %U",target,original,unicode) + end + data.height = depth + data.depth = height + data.yoffset = depth - height end + local small = data.smaller + if small then + fix(target,original,characters,small) + end + end + end + + function mathtweaks.fixradicals(target,original,parameters) + local characters = target.characters + for i=1,#list do + local unicode = list[i] + fix(target,original,characters,unicode) end end + +end + +do + + -- For Ton, who needs the high minus and plus for calculator signs in Dutch + -- school math books. + + local list = { + { 0x207A, 0x002B, true }, + { 0x207B, 0x2212, true }, + { 0x208A, 0x002B, false }, + { 0x208B, 0x2212, false }, + } + + local function add(target,original,characters,unicode,template,super,baseheight,scale) + if not characters[unicode] then + local origdata = characters[template] + if origdata then + local width = scale * (origdata.width or 0) + local height = scale * (origdata.height or 0) + local depth = scale * (origdata.depth or 0) + local half = - (height + depth) / 2 + local offset = super and baseheight/2 or -baseheight/4 + characters[unicode] = { + width = width, + height = height + offset, + depth = depth - offset, + yoffset = offset, + unicode = unicode, + -- index = origdata.index, + -- scale = scale, + commands = { + -- { "up", yoffset }, + { "slot", 0, template, scale } + }, + } + if trace_tweaking then + report_tweak("adding script %U scaled %0.3f",target,original,unicode,scale) + end + -- no need for smaller + end + end + end + + function mathtweaks.addscripts(target,original,parameters) + local characters = target.characters + local baseheight = target.mathparameters.AccentBaseHeight + local scaledown = parameters.scale or target.mathparameters.ScriptScriptPercentScaleDown / 100 + for i=1,#list do + local entry = list[i] + if entry then + add(target,original,characters,entry[1],entry[2],entry[3],baseheight,scaledown) + end + end + end + +end + +do + + function mathtweaks.version(target,original,parameters) + local metadata = original.shared.rawdata.metadata + if metadata then + local version = metadata.version + if version then + local expected = parameters.expected + -- version = tonumber(string.match(version,"%d+.%d+")) + if version ~= expected then + report_tweak("version %a found, version %a expected",target,original,version,expected) + reported[fontname] = true + end + end + end + end + end local function applytweaks(when,target,original) @@ -260,16 +521,10 @@ local function applytweaks(when,target,original) for i=1,#tweaks do local tweak = tweaks[i] local tvalue = type(tweak) - if tvalue == "function" then - -- old - tweak(target,original) - elseif tvalue == "table" then - local command = tweak[1] - if type(command) == "string" then - local action = mathtweaks[command] - if action then - action(target,original,table.unpack(tweak,2)) - end + if type(tweak) == "table" then + local action = mathtweaks[tweak.tweak or ""] + if action then + action(target,original,tweak) end end end diff --git a/tex/context/base/mkxl/math-fbk.lmt b/tex/context/base/mkxl/math-fbk.lmt index 4c58a2bb6..32ad909f7 100644 --- a/tex/context/base/mkxl/math-fbk.lmt +++ b/tex/context/base/mkxl/math-fbk.lmt @@ -7,7 +7,8 @@ if not modules then modules = { } end modules ['math-fbk'] = { } -- This will partly be redone and go via definitions in goodies where we can share --- some across fonts. +-- some across fonts. That makes most sense for those patches that might need some +-- finetuning depending on the font. local next, type = next, type @@ -169,71 +170,6 @@ end -- a few examples: -local function reference(index,char) - if index then - return { "slot", index, char } - else - return charcommand[char] - end -end - -local function raised(data,replacement,down) - local character = data.scriptdata.characters[replacement] - if character then - local size = data.size - return { - width = character.width, - height = character.height, - depth = character.depth, - commands = { - down and downcommand[size/4] or upcommand[size/2], - reference(data.scriptindex,replacement) - } - } - end -end - --- virtualcharacters[0x207A] = 0x2212 --- virtualcharacters[0x207B] = 0x002B --- virtualcharacters[0x208A] = 0x2212 --- virtualcharacters[0x208B] = 0x002B - -virtualcharacters[0x207A] = function(data) return raised(data,0x002B) end -virtualcharacters[0x207B] = function(data) return raised(data,0x2212) end -virtualcharacters[0x208A] = function(data) return raised(data,0x002B,true) end -virtualcharacters[0x208B] = function(data) return raised(data,0x2212,true) end - --- local function repeated(data,char,n,fraction) --- local character = data.characters[char] --- if character then --- local width = character.width --- local delta = width - character.italic -- width * fraction --- local c = charcommand[char] --- local r = rightcommand[right] --- local commands = { } --- for i=1,n-1 do --- width = width + delta --- commands[#commands+1] = c --- commands[#commands+1] = -delta --- end --- commands[#commands+1] = c --- return { --- width = width, --- height = character.height, --- depth = character.depth, --- commands = commands, --- } --- end --- end - --- virtualcharacters[0x222C] = function(data) --- return repeated(data,0x222B,2,1/8) --- end - --- virtualcharacters[0x222D] = function(data) --- return repeated(data,0x222B,3,1/8) --- end - local addextra = mathematics.extras.add addextra(0xFE350) -- MATHEMATICAL DOUBLE ARROW LEFT END @@ -310,8 +246,6 @@ virtualcharacters[0xFE352] = function(data) end end --- we could move the defs from math-act here - local function accent_to_extensible(target,newchr,original,oldchr,height,depth,swap,offset,unicode) local characters = target.characters local olddata = characters[oldchr] @@ -422,53 +356,6 @@ virtualcharacters[0xFE33F] = function(data) return accent_to_extensible(target,0xFE33F,data.original,0x0305,height,depth,nil,nil,0x203E) end --- spacing (no need for a cache of widths) - -local c_zero = byte('0') -local c_period = byte('.') - -local function spacefraction(data,fraction) - local width = fraction * data.target.parameters.space - return { - width = width, - commands = { rightcommand[width] } - } -end - -local function charfraction(data,char) - local width = data.target.characters[char].width - return { - width = width, - commands = { rightcommand[width] } - } -end - -local function quadfraction(data,fraction) - local width = fraction * data.target.parameters.quad - return { - width = width, - commands = { rightcommand[width] } - } -end - -virtualcharacters[0x00A0] = function(data) return spacefraction(data,1) end -- nbsp -virtualcharacters[0x2000] = function(data) return quadfraction (data,1/2) end -- enquad -virtualcharacters[0x2001] = function(data) return quadfraction (data,1) end -- emquad -virtualcharacters[0x2002] = function(data) return quadfraction (data,1/2) end -- enspace -virtualcharacters[0x2003] = function(data) return quadfraction (data,1) end -- emspace -virtualcharacters[0x2004] = function(data) return quadfraction (data,1/3) end -- threeperemspace -virtualcharacters[0x2005] = function(data) return quadfraction (data,1/4) end -- fourperemspace -virtualcharacters[0x2006] = function(data) return quadfraction (data,1/6) end -- sixperemspace -virtualcharacters[0x2007] = function(data) return charfraction (data,c_zero) end -- figurespace -virtualcharacters[0x2008] = function(data) return charfraction (data,c_period) end -- punctuationspace -virtualcharacters[0x2009] = function(data) return quadfraction (data,1/8) end -- breakablethinspace -virtualcharacters[0x200A] = function(data) return quadfraction (data,1/8) end -- hairspace -virtualcharacters[0x200B] = function(data) return quadfraction (data,0) end -- zerowidthspace -virtualcharacters[0x202F] = function(data) return quadfraction (data,1/8) end -- narrownobreakspace -virtualcharacters[0x205F] = function(data) return spacefraction(data,1/2) end -- math thinspace - --- - local function smashed(data,unicode,swap,private) local target = data.target local original = data.original @@ -514,73 +401,250 @@ end virtualcharacters[0xFE302] = function(data) return smashed(data,0x0302,0xFE302) end virtualcharacters[0xFE303] = function(data) return smashed(data,0x0303,0xFE303) end --- another crazy hack .. doesn't work as we define scrscr first .. we now have smaller --- primes so we have smaller primes for the moment, big ones will become an option .. --- these primes in fonts are a real mess .. kind of a dead end, so don't wonder about --- the values below - -local function smashed(data,unicode,optional) - local oldchar = data.characters[unicode] - if oldchar then - local height = 0.85 * data.target.mathparameters.AccentBaseHeight - local newchar = table.copy(oldchar) - newchar.yoffset = height - oldchar.height - newchar.height = height - return newchar - elseif not optional then - report_fallbacks("missing %U prime in font %a",unicode,data.target.properties.fullname) - end -end +--------------------------------------------------------------------------------- +-- these are moved to math-act.lmt +--------------------------------------------------------------------------------- -addextra(0xFE932) -- SMASHED PRIME 0x02032 -addextra(0xFE933) -- SMASHED PRIME 0x02033 -addextra(0xFE934) -- SMASHED PRIME 0x02034 -addextra(0xFE957) -- SMASHED PRIME 0x02057 - -addextra(0xFE935) -- SMASHED BACKWARD PRIME 0x02035 -addextra(0xFE936) -- SMASHED BACKWARD PRIME 0x02036 -addextra(0xFE937) -- SMASHED BACKWARD PRIME 0x02037 - -virtualcharacters[0xFE932] = function(data) return smashed(data,0x02032) end -virtualcharacters[0xFE933] = function(data) return smashed(data,0x02033) end -virtualcharacters[0xFE934] = function(data) return smashed(data,0x02034) end -virtualcharacters[0xFE957] = function(data) return smashed(data,0x02057) end - -virtualcharacters[0xFE935] = function(data) return smashed(data,0x02035,true) end -virtualcharacters[0xFE936] = function(data) return smashed(data,0x02036,true) end -virtualcharacters[0xFE937] = function(data) return smashed(data,0x02037,true) end - -local hack = nil - -function mathematics.getridofprime(target,original) --- local mathsize = specification.mathsize --- if mathsize == 1 or mathsize == 2 or mathsize == 3) then - local mathparameters = original.mathparameters - if mathparameters and next(mathparameters) then - local changed = original.changed - if changed then - hack = changed[0x02032] - changed[0x02032] = nil - changed[0x02033] = nil - changed[0x02034] = nil - changed[0x02057] = nil - changed[0x02035] = nil - changed[0x02036] = nil - changed[0x02037] = nil - end - end -end +-- local function reference(index,char) +-- if index then +-- return { "slot", index, char } +-- else +-- return charcommand[char] +-- end +-- end +-- +-- local function raised(data,replacement,down) +-- local character = data.scriptdata.characters[replacement] +-- if character then +-- local size = data.size +-- return { +-- width = character.width, +-- height = character.height, +-- depth = character.depth, +-- commands = { +-- down and downcommand[size/4] or upcommand[size/2], +-- reference(data.scriptindex,replacement) +-- } +-- } +-- end +-- end +-- +-- virtualcharacters[0x207A] = function(data) return raised(data,0x002B) end +-- virtualcharacters[0x207B] = function(data) return raised(data,0x2212) end +-- virtualcharacters[0x208A] = function(data) return raised(data,0x002B,true) end +-- virtualcharacters[0x208B] = function(data) return raised(data,0x2212,true) end -function mathematics.setridofprime(target,original) - local mathparameters = original.mathparameters - if mathparameters and next(mathparameters) and original.changed then - target.characters[0xFE931] = target.characters[hack or 0x2032] - hack = nil - end -end +--------------------------------------------------------------------------------- +-- these are moved to math-act.lmt +--------------------------------------------------------------------------------- -utilities.sequencers.appendaction("beforecopyingcharacters","system","mathematics.getridofprime") -utilities.sequencers.appendaction("aftercopyingcharacters", "system","mathematics.setridofprime") +-- local function repeated(data,char,n,fraction) +-- local character = data.characters[char] +-- if character then +-- local width = character.width +-- local delta = width - character.italic -- width * fraction +-- local c = charcommand[char] +-- local r = rightcommand[right] +-- local commands = { } +-- for i=1,n-1 do +-- width = width + delta +-- commands[#commands+1] = c +-- commands[#commands+1] = -delta +-- end +-- commands[#commands+1] = c +-- return { +-- width = width, +-- height = character.height, +-- depth = character.depth, +-- commands = commands, +-- } +-- end +-- end +-- +-- virtualcharacters[0x222C] = function(data) +-- return repeated(data,0x222B,2,1/8) +-- end +-- +-- virtualcharacters[0x222D] = function(data) +-- return repeated(data,0x222B,3,1/8) +-- end + +--------------------------------------------------------------------------------- +-- these are moved to math-act.lmt +--------------------------------------------------------------------------------- + +-- -- spacing (no need for a cache of widths) +-- +-- local c_zero = byte('0') +-- local c_period = byte('.') +-- +-- local function spacefraction(data,fraction) +-- local width = fraction * data.target.parameters.space +-- return { +-- width = width, +-- -- commands = { rightcommand[width] } +-- } +-- end +-- +-- local function charfraction(data,char) +-- local width = data.target.characters[char].width +-- return { +-- width = width, +-- -- commands = { rightcommand[width] } +-- } +-- end +-- +-- local function quadfraction(data,fraction) +-- local width = fraction * data.target.parameters.quad +-- return { +-- width = width, +-- -- commands = { rightcommand[width] } +-- } +-- end +-- +-- virtualcharacters[0x00A0] = function(data) return spacefraction(data,1) end -- nbsp +-- virtualcharacters[0x2000] = function(data) return quadfraction (data,1/2) end -- enquad +-- virtualcharacters[0x2001] = function(data) return quadfraction (data,1) end -- emquad +-- virtualcharacters[0x2002] = function(data) return quadfraction (data,1/2) end -- enspace +-- virtualcharacters[0x2003] = function(data) return quadfraction (data,1) end -- emspace +-- virtualcharacters[0x2004] = function(data) return quadfraction (data,1/3) end -- threeperemspace +-- virtualcharacters[0x2005] = function(data) return quadfraction (data,1/4) end -- fourperemspace +-- virtualcharacters[0x2006] = function(data) return quadfraction (data,1/6) end -- sixperemspace +-- virtualcharacters[0x2007] = function(data) return charfraction (data,c_zero) end -- figurespace +-- virtualcharacters[0x2008] = function(data) return charfraction (data,c_period) end -- punctuationspace +-- virtualcharacters[0x2009] = function(data) return quadfraction (data,1/8) end -- breakablethinspace +-- virtualcharacters[0x200A] = function(data) return quadfraction (data,1/8) end -- hairspace +-- virtualcharacters[0x200B] = function(data) return quadfraction (data,0) end -- zerowidthspace +-- virtualcharacters[0x202F] = function(data) return quadfraction (data,1/8) end -- narrownobreakspace +-- virtualcharacters[0x205F] = function(data) return spacefraction(data,1/2) end -- math thinspace + +-- -- another crazy hack .. doesn't work as we define scrscr first .. we now have smaller +-- -- primes so we have smaller primes for the moment, big ones will become an option .. +-- -- these primes in fonts are a real mess .. kind of a dead end, so don't wonder about +-- -- the values below +-- +-- local function smashed(data,unicode,optional) +-- local oldchar = data.characters[unicode] +-- if oldchar then +-- local height = 0.85 * data.target.mathparameters.AccentBaseHeight +-- local newchar = table.copy(oldchar) +-- newchar.yoffset = height - oldchar.height +-- newchar.height = height +-- return newchar +-- elseif not optional then +-- report_fallbacks("missing %U prime in font %a",unicode,data.target.properties.fullname) +-- end +-- end +-- +-- addextra(0xFE932) -- SMASHED PRIME 0x02032 +-- addextra(0xFE933) -- SMASHED PRIME 0x02033 +-- addextra(0xFE934) -- SMASHED PRIME 0x02034 +-- addextra(0xFE957) -- SMASHED PRIME 0x02057 +-- +-- addextra(0xFE935) -- SMASHED BACKWARD PRIME 0x02035 +-- addextra(0xFE936) -- SMASHED BACKWARD PRIME 0x02036 +-- addextra(0xFE937) -- SMASHED BACKWARD PRIME 0x02037 +-- +-- virtualcharacters[0xFE932] = function(data) return smashed(data,0x02032) end +-- virtualcharacters[0xFE933] = function(data) return smashed(data,0x02033) end +-- virtualcharacters[0xFE934] = function(data) return smashed(data,0x02034) end +-- virtualcharacters[0xFE957] = function(data) return smashed(data,0x02057) end +-- +-- virtualcharacters[0xFE935] = function(data) return smashed(data,0x02035,true) end +-- virtualcharacters[0xFE936] = function(data) return smashed(data,0x02036,true) end +-- virtualcharacters[0xFE937] = function(data) return smashed(data,0x02037,true) end +-- +-- local hack = nil +-- +-- function mathematics.getridofprime(target,original) +-- local mathparameters = original.mathparameters +-- if mathparameters and next(mathparameters) then +-- local changed = original.changed +-- if changed then +-- hack = changed[0x02032] +-- changed[0x02032] = nil +-- changed[0x02033] = nil +-- changed[0x02034] = nil +-- changed[0x02057] = nil +-- changed[0x02035] = nil +-- changed[0x02036] = nil +-- changed[0x02037] = nil +-- end +-- end +-- end +-- +-- function mathematics.setridofprime(target,original) +-- local mathparameters = original.mathparameters +-- if mathparameters and next(mathparameters) and original.changed then +-- target.characters[0xFE931] = target.characters[hack or 0x2032] +-- hack = nil +-- end +-- end +-- +-- utilities.sequencers.appendaction("beforecopyingcharacters","system","mathematics.getridofprime") +-- utilities.sequencers.appendaction("aftercopyingcharacters", "system","mathematics.setridofprime") + +-- local list = { +-- { 0x02032, true }, +-- { 0x02033, true }, +-- { 0x02034, true }, +-- { 0x02057, true }, +-- { 0x02035, false }, +-- { 0x02036, false }, +-- { 0x02037, false }, +-- } +-- +-- function mathematics.fixprimes(target,original) +-- local mathparameters = original.mathparameters +-- if mathparameters and next(mathparameters) then +-- for i=1,#list do +-- local entry = list[i] +-- local char = original.characters[entry[1]] +-- if char then +-- local height = 0.85 * orginal.mathparameters.AccentBaseHeight +-- char.yoffset = height - char.height +-- char.height = height +-- return char +-- elseif entry[1] then +-- report_fallbacks("missing %U prime in font %a",unicode,original.properties.fullname) +-- end +-- end +-- end +-- end +-- +-- utilities.sequencers.appendaction("beforecopyingcharacters","system","mathematics.fixprimes") + +--------------------------------------------------------------------------------- +-- this one is not used +--------------------------------------------------------------------------------- + +-- addextra(0xFE941) -- EXTREMELY IDENTICAL TO +-- +-- virtualcharacters[0xFE941] = function(data) -- this character is only needed for mathpairs +-- local characters = data.target.characters +-- local parameters = data.target.parameters +-- local basechar = characters[0x003D] +-- local width = basechar.width or 0 +-- local height = basechar.height or 0 +-- local depth = basechar.depth or 0 +-- return { +-- unicode = 0xFE941, +-- width = width, +-- height = height, -- we cheat (no time now) +-- depth = depth, -- we cheat (no time now) +-- commands = { +-- upcommand[height/2], -- sort of works +-- charcommand[0x003D], +-- leftcommand[width], +-- downcommand[height], -- sort of works +-- charcommand[0x003D], +-- }, +-- } +-- end + +--------------------------------------------------------------------------------- +-- these might move to math-act.lmt +--------------------------------------------------------------------------------- -- actuarian (beware: xits has an ugly one) @@ -638,31 +702,9 @@ virtualcharacters[0x2A75] = function(data) return equals(data,0x2A75,0x003D, 1/5 virtualcharacters[0x2A76] = function(data) return equals(data,0x2A76,0x003D, 1/5,3) end -- === virtualcharacters[0x2980] = function(data) return equals(data,0x2980,0x007C,-1/8,3) end -- ||| --- addextra(0xFE941) -- EXTREMELY IDENTICAL TO --- --- virtualcharacters[0xFE941] = function(data) -- this character is only needed for mathpairs --- local characters = data.target.characters --- local parameters = data.target.parameters --- local basechar = characters[0x003D] --- local width = basechar.width or 0 --- local height = basechar.height or 0 --- local depth = basechar.depth or 0 --- return { --- unicode = 0xFE941, --- width = width, --- height = height, -- we cheat (no time now) --- depth = depth, -- we cheat (no time now) --- commands = { --- upcommand[height/2], -- sort of works --- charcommand[0x003D], --- leftcommand[width], --- downcommand[height], -- sort of works --- charcommand[0x003D], --- }, --- } --- end - --- lucida needs this +--------------------------------------------------------------------------------- +-- these might move to math-act.lmt -- lucida needs this +--------------------------------------------------------------------------------- virtualcharacters[0x305] = function(data) local target = data.target @@ -693,6 +735,10 @@ virtualcharacters[0x305] = function(data) } end +--------------------------------------------------------------------------------- +-- these might move to math-act.lmt +--------------------------------------------------------------------------------- + local function threedots(data,shift) local characters = data.target.characters local parameters = data.target.parameters diff --git a/tex/context/base/mkxl/math-noa.lmt b/tex/context/base/mkxl/math-noa.lmt index 5ac095fd3..025333699 100644 --- a/tex/context/base/mkxl/math-noa.lmt +++ b/tex/context/base/mkxl/math-noa.lmt @@ -1927,20 +1927,32 @@ do -- inner under over vcenter local fixscripts = { } +-- local movesub = { +-- -- primes +-- [0x2032] = 0xFE932, +-- [0x2033] = 0xFE933, +-- [0x2034] = 0xFE934, +-- [0x2057] = 0xFE957, +-- -- reverse primes +-- [0x2035] = 0xFE935, +-- [0x2036] = 0xFE936, +-- [0x2037] = 0xFE937, +-- } +-- +-- mathematics.virtualize(movesub) + local movesub = { -- primes - [0x2032] = 0xFE932, - [0x2033] = 0xFE933, - [0x2034] = 0xFE934, - [0x2057] = 0xFE957, + [0x2032] = 0x2032, + [0x2033] = 0x2033, + [0x2034] = 0x2034, + [0x2057] = 0x2057, -- reverse primes - [0x2035] = 0xFE935, - [0x2036] = 0xFE936, - [0x2037] = 0xFE937, + [0x2035] = 0x2035, + [0x2036] = 0x2036, + [0x2037] = 0x2037, } - mathematics.virtualize(movesub) - local nosuperscript_code = tex.mathoptioncodes.nosuperscript local function fixsupscript(parent,current,current_char,new_char) diff --git a/tex/context/base/mkxl/strc-syn.mkxl b/tex/context/base/mkxl/strc-syn.mkxl index c6a62e607..e6081d0d9 100644 --- a/tex/context/base/mkxl/strc-syn.mkxl +++ b/tex/context/base/mkxl/strc-syn.mkxl @@ -101,6 +101,31 @@ %D %D The lists are constructions (like descriptions are) and can be set up %D likewise. +%D +%D You can show the currently accessed entries as follows: +%D +%D \starttyping +%D \startchapter[title=One] +%D test \FIRST\ test test \THIRD\ test \blank +%D \placelistofsynonyms[myabbreviation] +%D \resetsynonymsprogress[myabbreviation] % reset state +%D \stopchapter +%D +%D \startchapter[title=Two] +%D test \FIRST\ test test \SECOND\ test \blank +%D \placelistofsynonyms[myabbreviation][criterium=current] +%D \resetsynonymsprogress[myabbreviation] % reset state +%D \stopchapter +%D +%D \startchapter[title=Three] +%D test test test test test test \blank +%D \placelistofsynonyms[myabbreviation][criterium=current] % also reset state +%D \stopchapter +%D +%D \startchapter[title=All] +%D \placelistofsynonyms[myabbreviation][criterium=all] +%D \stopchapter +%D \stoptyping % todo: add 'define only' option to descriptions, then add sorting (also based on key) % and call to definition -> replaces this module @@ -339,8 +364,11 @@ \permanent \protected\def\currentsynonymmeaning {\clf_synonymmeaning{\currentsimplelist}{\currentsynonymtag}} \permanent \protected\def\doifelsecurrentsynonymused {\clf_doifelsesynonymused{\currentsimplelist}{\currentsynonymtag}} \permanent \protected\def\doifelsecurrentsynonymshown{\clf_doifelsesynonymshown{\currentsimplelist}{\currentsynonymtag}} -\permanent \protected\def\resetusedsynonyms [#1]{\clf_resetusedsynonyms{#1}} -\permanent \protected\def\resetshownsynonyms [#1]{\clf_resetshownsynonyms{#1}} +\permanent \protected\def\resetusedsynonyms [#1]{\clf_resetsynonyms{#1}{used}} +\permanent \protected\def\resetshownsynonyms [#1]{\clf_resetsynonyms{#1}{shown}} +\permanent \protected\def\resetlistsynonyms [#1]{\clf_resetsynonyms{#1}{list}} +\permanent \protected\def\resetsynonyms [#1]{\clf_resetsynonyms{#1}{all}} +\permanent \protected\def\resetsynonymsprogress [#1]{\clf_resetsynonyms{#1}{progress}} \aliased\let\rawsynonymname \clf_synonymname \aliased\let\rawsynonymmeaning\clf_synonymmeaning diff --git a/tex/context/base/mkxl/trac-vis.lmt b/tex/context/base/mkxl/trac-vis.lmt index aa599485c..d08f3c282 100644 --- a/tex/context/base/mkxl/trac-vis.lmt +++ b/tex/context/base/mkxl/trac-vis.lmt @@ -147,7 +147,7 @@ local modes = { visualizers.modes = modes local usedfont, exheight, emwidth -local l_penalty, l_glue, l_kern, l_fontkern, l_hbox, l_vbox, l_vtop, l_strut, l_whatsit, l_glyph, l_user, l_math, l_marginkern, l_mathkern, l_italic, l_origin, l_discretionary, l_expansion, l_line, l_space, l_depth, +local l_penalty, l_glue, l_kern, l_fontkern, l_hbox, l_vbox, l_vtop, l_strut, l_whatsit, l_glyph, l_user, l_math, l_marginkern, l_mathkern, l_mathshape, l_italic, l_origin, l_discretionary, l_expansion, l_line, l_space, l_depth, l_dir, l_whatsit, l_mark, l_insert local enabled = false @@ -207,6 +207,7 @@ local function initialize() l_italic = layers.italic l_marginkern = layers.marginkern l_mathkern = layers.mathkern + l_mathshapekern = layers.mathshapekern l_origin = layers.origin l_discretionary = layers.discretionary l_expansion = layers.expansion @@ -432,6 +433,7 @@ local fontkern, italickern, marginkern, mathkern do local f_cache = caches["fontkern"] local i_cache = caches["italickern"] + local s_cache = caches["shapekern"] local m_cache = caches["marginkern"] local l_cache = caches["mathkern"] @@ -471,6 +473,10 @@ local fontkern, italickern, marginkern, mathkern do return somekern(head,current,i_cache,"trace:do",l_italic) end + mathshapekern = function(head,current) + return somekern(head,current,s_cache,"trace:do",l_mathshapekern) + end + marginkern = function(head,current) return somekern(head,current,m_cache,"trace:do",l_marginkern) end @@ -1214,11 +1220,10 @@ local ruledmathkern do local h_cache = caches["horizontalmathkern"] local v_cache = caches["verticalmathkern"] - ruledmathkern = function(head,current,subtype) - local kern = getkern(current) - local vertical = subtype == verticalmathkern_code - local cache = vertical and v_cache or h_cache - local info = cache[kern] + ruledmathkern = function(head,current,vertical) + local kern = getkern(current) + local cache = vertical and v_cache or h_cache + local info = cache[kern] if not info then local amount = formatters["%s:%0.3f"](vertical and "MV" or "MH",kern*pt_factor) if kern > 0 then @@ -1321,6 +1326,7 @@ do local italickern_code = kerncodes.italiccorrection local leftmarginkern_code = kerncodes.leftmarginkern local rightmarginkern_code = kerncodes.rightmarginkern + local mathshapekern_code = kerncodes.mathshapekern local horizontalmathkern_code = kerncodes.horizontalmathkern local verticalmathkern_code = kerncodes.verticalmathkern ----- userkern_code = kerncodes.userkern @@ -1560,13 +1566,19 @@ do end elseif subtype == verticalmathkern_code then if trace_mathkern or trace_kern then - head, current = ruledmathkern(head,current,subtype) + head, current = ruledmathkern(head,current,true) end elseif subtype == horizontalmathkern_code then if trace_mathkern then head, current = mathkern(head,current) elseif trace_kern then - head, current = ruledmathkern(head,current,subtype) + head, current = ruledmathkern(head,current,false) + end + elseif subtype == mathshapekern_code then + if trace_mathkern or trace_italic then + head, current = mathshapekern(head,current) + elseif trace_kern then + head, current = ruledmathkern(head,current,false) end else if trace_kern then diff --git a/tex/context/fonts/mkiv/asana-math.lfg b/tex/context/fonts/mkiv/asana-math.lfg index 5b47b3ff8..fc83887a0 100644 --- a/tex/context/fonts/mkiv/asana-math.lfg +++ b/tex/context/fonts/mkiv/asana-math.lfg @@ -30,7 +30,6 @@ local function more(value,target,original) end end - return { name = "asana-math", version = "1.00", @@ -38,6 +37,27 @@ return { author = "Hans Hagen", copyright = "ConTeXt development team", mathematics = { + tweaks = { + aftercopying = { + { + tweak = "dimensions", + list = { + -- nothing yet + } + }, + { + tweak = "fixprimes", + factor = 1.05, + scale = 0.65, + }, + { + tweak = "checkspacing", + }, + { + tweak = "addscripts", + }, + }, + }, parameters = { -- DisplayOperatorMinHeight = 0, -- more -- StackBottomDisplayStyleShiftDown = 0, diff --git a/tex/context/fonts/mkiv/bonum-math.lfg b/tex/context/fonts/mkiv/bonum-math.lfg index 51ca2d7f1..8daa047fb 100644 --- a/tex/context/fonts/mkiv/bonum-math.lfg +++ b/tex/context/fonts/mkiv/bonum-math.lfg @@ -1,8 +1,21 @@ -local kern_V = { bottomright = { { kern = -200 } } } -local kern_W = { bottomright = { { kern = -100 } } } -local offset_f = { xoffset = "llx" } +local dimensions, kerns if CONTEXTLMTXMODE == 0 then --- Beware of updates in ssty slots! + local kern_V = { bottomright = { { kern = -200 } } } + local kern_W = { bottomright = { { kern = -100 } } } + local offset_f = { xoffset = "llx" } + + dimensions = { + default = { + [0x1D453] = offset_f, -- 𝑓 + }, + } + + kerns = { + [0x1D449] = kern_V, -- 𝑉 + [0x1D44A] = kern_W, -- 𝑊 + } + +end return { name = "bonum-math", @@ -11,26 +24,30 @@ return { author = "Hans Hagen", copyright = "ConTeXt development team", mathematics = { - dimensions = { - default = { - -- [0x1D453] = offset_f, -- 𝑓 - -- ["1:0x1D453"] = offset_f, -- needed for compact - -- ["2:0x1D453"] = offset_f, -- needed for compact - ["*:0x1D453"] = offset_f, -- 𝑓 + tweaks = { + aftercopying = { + { + tweak = "dimensions", + list = { + [0x1D453] = { .40, 1.60, .5 }, -- offset width italic + }, + }, + { + tweak = "fixprimes", + factor = 0.85, + }, + { + tweak = "addscripts", + }, }, }, - kerns = { - -- [0x1D449] = kern_V, -- 𝑉 - -- ["1:0x1D449"] = kern_V, -- needed for compact - -- ["2:0x1D449"] = kern_V, -- needed for compact - -- [0x1D44A] = kern_W, -- 𝑊 - -- ["1:0x1D44A"] = kern_W, -- needed for compact - -- ["2:0x1D44A"] = kern_W, -- needed for compact - ["*:0x1D449"] = kern_V, -- 𝑉 - ["*:0x1D44A"] = kern_W, -- 𝑊 - }, alternates = { dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" }, }, + -- + -- experimental fixes for mkiv: + -- + dimensions = dimensions, + kerns = kerns, }, } diff --git a/tex/context/fonts/mkiv/cambria-math.lfg b/tex/context/fonts/mkiv/cambria-math.lfg index c18854d18..6db382c45 100644 --- a/tex/context/fonts/mkiv/cambria-math.lfg +++ b/tex/context/fonts/mkiv/cambria-math.lfg @@ -6,6 +6,32 @@ -- added to the patch list. No goodies setting is needed with -- the filename. +local dimensions, kerns, kernpairs if CONTEXTLMTXMODE == 0 then + + kernpairs = { -- \setupmathematics[kernpairs=yes] + [0x1D44E] = { + [0x1D44F] = 1000, -- 𝑎𝑏 demo + } + } + + kerns = { + [0x1D453] = { + force = true, + topright = { + { + kern = 1000, + }, + }, + bottomright = { + { + kern = 1000, + }, + }, + }, + } + +end + local patches = fonts.handlers.otf.enhancers.patches local function patch(data,filename,threshold) @@ -42,28 +68,34 @@ return { author = "Hans Hagen", copyright = "ConTeXt development team", mathematics = { + tweaks = { + aftercopying = { + { + tweak = "dimensions", + list = { + -- nothing yet + }, + }, + { + tweak = "fixprimes", + factor = 0.85, + }, + { + tweak = "checkspacing", + }, + { + tweak = "addscripts", + }, + }, + }, parameters = { DisplayOperatorMinHeight = FixDisplayOperatorMinHeight, }, - -- kernpairs = { -- \setupmathematics[kernpairs=yes] - -- [0x1D44E] = { - -- [0x1D44F] = 1000, -- 𝑎𝑏 demo - -- } - -- }, - -- kerns = { - -- [0x1D453] = { - -- force = true, - -- topright = { - -- { - -- kern = 1000, - -- }, - -- }, - -- bottomright = { - -- { - -- kern = 1000, - -- }, - -- }, - -- }, - -- }, + -- + -- experimental fixes for mkiv: + -- + dimensions = dimensions, + kerns = kerns, + kernpairs = kernpairs, }, } diff --git a/tex/context/fonts/mkiv/dejavu-math.lfg b/tex/context/fonts/mkiv/dejavu-math.lfg index 608b396f8..44b5327de 100644 --- a/tex/context/fonts/mkiv/dejavu-math.lfg +++ b/tex/context/fonts/mkiv/dejavu-math.lfg @@ -1,7 +1,14 @@ -local kern_V = { bottomright = { { kern = -250 } } } -local kern_W = kern_W +local dimensions, kerns if CONTEXTLMTXMODE == 0 then --- Beware of updates in ssty slots! + local kern_V = { bottomright = { { kern = -250 } } } + local kern_W = kern_W + + kerns = { + [0x1D449] = kern_V, -- 𝑉 + [0x1D44A] = kern_W, -- 𝑊 + } + +end return { name = "dejavu-math", @@ -10,18 +17,35 @@ return { author = "Hans Hagen", copyright = "ConTeXt development team", mathematics = { - kerns = { - -- [0x1D449] = kern_V, -- 𝑉 - -- ["1:0x1D449"] = kern_V, -- needed for compact - -- ["2:0x1D449"] = kern_V, -- needed for compact - -- [0x1D44A] = kern_W, -- 𝑊 - -- ["1:0x1D44A"] = kern_W, -- needed for compact - -- ["2:0x1D44A"] = kern_W, -- needed for compact - ["*:0x1D449"] = kern_V, -- 𝑉 - ["*:0x1D44A"] = kern_W, -- 𝑊 + tweaks = { + aftercopying = { + { + tweak = "dimensions", + list = { + -- [0x1D449] = { 0, .8, .2 }, + -- [0x1D44A] = { 0, .8, .2 }, + ["0x1D449:0x1D44A"] = { 0, .8, .2 }, + } + }, + { + tweak = "fixprimes", + factor = 0.85, + }, + { + tweak = "checkspacing", + }, + { + tweak = "addscripts", + }, + }, }, alternates = { dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" }, }, + -- + -- experimental fixes for mkiv: + -- + dimensions = dimensions, + kerns = kerns, }, } diff --git a/tex/context/fonts/mkiv/ebgaramond.lfg b/tex/context/fonts/mkiv/ebgaramond.lfg index 862e4e85d..7a509893d 100644 --- a/tex/context/fonts/mkiv/ebgaramond.lfg +++ b/tex/context/fonts/mkiv/ebgaramond.lfg @@ -5,32 +5,26 @@ return { author = "Hans Hagen", copyright = "ConTeXt development team", mathematics = { --- tweaks = { --- aftercopying = { --- function(target,original,...) --- local crap = { --- [0x1D453] = { .20, 1.20 }, --- [0x1D454] = { .15, 1.15 }, --- } --- local characters = target.characters --- local function adapt(k,v) --- local character = characters[k] --- local width = character.width --- character.width = v[2]*width --- -- character.commands = { { "offset", v[1]*width, 0, k } } --- character.xoffset = v[1]*width --- local smaller = original.characters[k].smaller --- if smaller and smaller ~= k then --- adapt(smaller,v) --- end --- end --- for k, v in next, crap do --- adapt(k,v) --- end --- end, --- }, --- }, - + tweaks = { + aftercopying = { + { + tweak = "dimensions", + list = { + [0x1D453] = { 0, 1, .2 }, -- offset width italic + }, + }, + { + tweak = "fixprimes", + factor = 0.85, + }, + { + tweak = "checkspacing", + }, + { + tweak = "addscripts", + }, + }, + }, alternates = { partial = { feature = 'ss02', value = 1, comment = "Curved partial" }, semibold = { feature = 'ss04', value = 1, comment = "Semibold" }, diff --git a/tex/context/fonts/mkiv/libertinus-math.lfg b/tex/context/fonts/mkiv/libertinus-math.lfg index c02f0506a..a0e9b5c23 100644 --- a/tex/context/fonts/mkiv/libertinus-math.lfg +++ b/tex/context/fonts/mkiv/libertinus-math.lfg @@ -13,89 +13,22 @@ return { mathematics = { tweaks = { aftercopying = { - -- function(target,original) - -- local okay = 983068 - -- local crap = { - -- ["minute"] = "minute.ssty1", - -- ["second"] = "second.ssty1", - -- -- [8242] = 983068, - -- -- [8243] = 983069, - -- [8244] = 983070, - -- [8245] = 983071, - -- [8246] = 983072, - -- [8247] = 983073, - -- } - -- local characters = target.characters - -- local unicodes = original.resources.unicodes - -- if unicodes["minute.ssty1"] == okay then - -- for old, new in next, crap do - -- if type(old) == "string" then - -- old = unicodes[old] - -- end - -- if type(new) == "string" then - -- new = unicodes[new] - -- end - -- if old and new and characters[old] then - -- local c = characters[new] - -- if c then - -- characters[old] = c - -- c.commands = { { "up", .06 * c.height }, { "slot", 0, new, .7 } } - -- end - -- end - -- end - -- local four = characters[0x2057] - -- if four then - -- local one = characters[okay] - -- local owd = .75*one.width - -- local off = .6*one.height - -- four.width = 4*owd - -- four.commands = { - -- { "offset", 0, off, okay }, - -- { "offset", owd, off, okay }, - -- { "offset", 2*owd, off, okay }, - -- { "offset", 3*owd, off, okay }, - -- } - -- else - -- -- we don't add (but we could), just patch, and there's no - -- -- reverse quad either - -- end - -- else - -- logs.report("fonts","the libertinus tweaks need to be checked") - -- end - -- end, - function(target,original) - local crap = { 0x2032, 0x2033, 0x2034, 0x2036, 0x2037, 0x2038 } -- 0x2057 - local characters = target.characters - local originals = original.characters - local unicodes = original.resources.unicodes - for i=1,#crap do - local old = crap[i] - local chr = characters[slot] - if chr then - local new = chr.smaller - if new then - local c = characters[new] - if c then - characters[old] = c - c.commands = { { "up", .06 * c.height }, { "slot", 0, new, .7 } } - end - end - end - end - local four = characters[0x2057] - if four then - local one = characters[0x2032] - local owd = .75*one.width - local off = .6*one.height - four.width = 4*owd - four.commands = { - { "offset", 0, off, okay }, - { "offset", owd, off, okay }, - { "offset", 2*owd, off, okay }, - { "offset", 3*owd, off, okay }, - } - end - end, + { + tweak = "dimensions", + list = { + -- nothing yet + }, + }, + { + tweak = "fixprimes", + factor = 0.85, + }, + { + tweak = "checkspacing", + }, + { + tweak = "addscripts", + }, }, }, }, diff --git a/tex/context/fonts/mkiv/lm.lfg b/tex/context/fonts/mkiv/lm.lfg index ec37a2975..6039471e3 100644 --- a/tex/context/fonts/mkiv/lm.lfg +++ b/tex/context/fonts/mkiv/lm.lfg @@ -1,8 +1,52 @@ -- In order to be able to use beta math fonts, we use our own file name and -- always remap. -local kern_150 = { bottomright = { { kern = -150 } } } -local kern_200 = { bottomright = { { kern = -200 } } } +local dimensions, kerns if CONTEXTLMTXMODE == 0 then + + local kern_150 = { bottomright = { { kern = -150 } } } + local kern_200 = { bottomright = { { kern = -200 } } } + + kerns = { + [0x1D449] = kern_150, -- + [0x1D44A] = kern_200, -- 𝑊 + } + + dimensions = { + -- always applied + -- default = { + -- }, + -- driven by 'mathdimensions' feature + default = { + -- the root is quite displaced + [0x221A] = { + -- 73, -960, 853, 40 + yoffset = 960 - 40, + height = 960, + depth = 40, + }, + -- [0xFE932] = { xoffset = 50, width = 290 }, -- used prime + -- [0x2032] = { xoffset = 50, width = 290 }, -- prime + }, + -- -- seems ok now -- + -- signs = { + -- -- [0x00B1] = { -- ± + -- -- height = 500, depth = 0, + -- -- }, + -- -- [0x2213] = { -- ∓ + -- -- height = 500, depth = 0, + -- -- }, + -- -- move in boundingbox + -- [0x00B1] = { -- ± + -- yoffset = 100, + -- }, + -- [0x2213] = { -- ∓ + -- yoffset = -100, + -- }, + -- }, + } + +end + return { name = "latin modern", @@ -13,58 +57,43 @@ return { mathematics = { tweaks = { aftercopying = { - mathematics.tweaks.fixbadprime, -- prime is too low - -- mathematics.tweaks.fixoverline, - }, - }, - kerns = { - [0x1D449] = kern_150, -- - [0x1D44A] = kern_200, -- 𝑊 - }, - dimensions = { - -- always applied - -- default = { - -- }, - -- driven by 'mathdimensions' feature - default = { - -- the root is quite displaced - [0x221A] = { - -- 73, -960, 853, 40 - yoffset = 960 - 40, - height = 960, - depth = 40, + { + tweak = "dimensions", + list = { + -- nothing yet + }, }, - -- [0xFE932] = { xoffset = 50, width = 290 }, -- used prime - -- [0x2032] = { xoffset = 50, width = 290 }, -- prime - }, - signs = { - -- set dimensions - -- [0x00B1] = { -- ± - -- height = 500, depth = 0, - -- }, - -- [0x2213] = { -- ∓ - -- height = 500, depth = 0, - -- }, - -- move in boundingbox - [0x00B1] = { -- ± - yoffset = 100, + { + tweak = "fixprimes", + factor = 0.85, + }, + { + tweak = "checkspacing", + }, + { + tweak = "fixradicals", }, - [0x2213] = { -- ∓ - yoffset = -100, + { + tweak = "addscripts", }, }, }, --- parameters = { --- FractionNumeratorDisplayStyleShiftUp = function(value,target,original) --- local o = original.mathparameters.FractionNumeratorDisplayStyleShiftUp --- if o > 675 then --- o = 600 --- else --- -- probably tuned --- end --- return o * target.parameters.factor --- end, --- } + parameters = { + FractionNumeratorDisplayStyleShiftUp = function(value,target,original) + local o = original.mathparameters.FractionNumeratorDisplayStyleShiftUp + if o > 675 then + o = 600 + else + -- probably tuned + end + return o * target.parameters.factor + end, + }, + -- + -- experimental fixes for mkiv: + -- + dimensions = dimensions, + kerns = kerns, }, filenames = { ["latinmodern-math-regular.otf"] = { diff --git a/tex/context/fonts/mkiv/lucida-opentype-math.lfg b/tex/context/fonts/mkiv/lucida-opentype-math.lfg index 7596f139a..024284bd2 100644 --- a/tex/context/fonts/mkiv/lucida-opentype-math.lfg +++ b/tex/context/fonts/mkiv/lucida-opentype-math.lfg @@ -1,4 +1,29 @@ ------ kern_250 = { bottomright = { { kern = -250 } }, force = true } +local dimensions, kerns if CONTEXTLMTXMODE == 0 then + + -- local kern_250 = { bottomright = { { kern = -250 } }, force = true } + + + -- kerns = { + -- [0x1D449] = kern_250, -- + -- [0x1D44A] = kern_250, -- 𝑊 + -- } + + dimensions = { + default = { -- experimental values + [0x02044] = { xoffset = 275, width = 600 }, + -- primes + [0xFE932] = { width = 200 }, + [0xFE933] = { width = 500 }, + [0xFE934] = { width = 800 }, + [0xFE935] = { width = 1100 }, + -- reverse primes + [0xFE935] = { width = 200 }, + [0xFE936] = { width = 500 }, + [0xFE937] = { width = 800 }, + }, + } + +end -- RadicalVerticalGap = 50 -- RadicalDisplayStyleVerticalGap = 175 @@ -18,6 +43,30 @@ return { author = "Hans Hagen", copyright = "ConTeXt development team", mathematics = { + tweaks = { + aftercopying = { + { + tweak = "dimensions", + list = { + -- nothing yet + }, + }, + { + tweak = "fixprimes", + factor = 0.85, + }, + { + tweak = "fakeprimes", + factor = 0.75, + }, + { + tweak = "checkspacing", + }, + { + tweak = "addscripts", + }, + }, + }, parameters = { RadicalDisplayStyleVerticalGap = FixRadicalDisplayStyleVerticalGap, }, @@ -29,23 +78,10 @@ return { zero = { feature = 'ss05', value = 1, comment = "Mathematical Alternative Zero" }, partial = { feature = 'ss20', value = 1, comment = "Mathematical Alternative Upright Partial Differential" }, }, - -- kerns = { - -- [0x1D449] = kern_250, -- - -- [0x1D44A] = kern_250, -- 𝑊 - -- }, - dimensions = { - default = { -- experimental values - [0x02044] = { xoffset = 275, width = 600 }, - -- primes - [0xFE932] = { width = 200 }, - [0xFE933] = { width = 500 }, - [0xFE934] = { width = 800 }, - [0xFE935] = { width = 1100 }, - -- reverse primes - [0xFE935] = { width = 200 }, - [0xFE936] = { width = 500 }, - [0xFE937] = { width = 800 }, - }, - }, + -- + -- experimental fixes for mkiv: + -- + dimensions = dimensions, + kerns = kerns, }, } diff --git a/tex/context/fonts/mkiv/minion-math.lfg b/tex/context/fonts/mkiv/minion-math.lfg index 863836c1c..13d11edc6 100644 --- a/tex/context/fonts/mkiv/minion-math.lfg +++ b/tex/context/fonts/mkiv/minion-math.lfg @@ -1,5 +1,14 @@ -local kern_W = { bottomright = { { kern = -150 } } } -local kern_V = { bottomright = { { kern = -200 } } } +local dimensions, kerns if CONTEXTLMTXMODE == 0 then + + local kern_W = { bottomright = { { kern = -150 } } } + local kern_V = { bottomright = { { kern = -200 } } } + + kerns = { + [0x1D449] = kern_V, -- 𝑉 + [0x1D44A] = kern_W, -- 𝑊 + } + +end return { name = "minion-math", @@ -21,10 +30,28 @@ return { }, }, mathematics = { - kerns = { - [0x1D449] = kern_V, -- 𝑉 - [0x1D44A] = kern_W, -- 𝑊 - -- todo: ssty 1/2 + tweaks = { + aftercopying = { + { + tweak = "dimensions", + list = dimensions, + }, + { + tweak = "fixprimes", + factor = 0.85, + }, + { + tweak = "checkspacing", + }, + { + tweak = "addscripts", + }, + }, }, + -- + -- experimental fixes for mkiv: + -- + dimensions = dimensions, + kerns = kerns, }, } diff --git a/tex/context/fonts/mkiv/pagella-math.lfg b/tex/context/fonts/mkiv/pagella-math.lfg index e2ed0eb43..3926ae95b 100644 --- a/tex/context/fonts/mkiv/pagella-math.lfg +++ b/tex/context/fonts/mkiv/pagella-math.lfg @@ -1,7 +1,31 @@ -local dimensions = { - [0x1D453] = { .40, 1.60, .5 }, -- offset width italic --- [0x1D453] = { .0, 2, 0 }, -- offset width italic -} +local dimensions, kerns if CONTEXTLMTXMODE == 0 then + + local kern_V = { bottomright = { { kern = -200 } } } + local kern_W = { bottomright = { { kern = -100 } } } + + dimensions = { + default = { + -- [0x1D453] = { xoffset = 162, width = 278 + 162 },-- 𝑓 + -- [0x1D453] = offset_f, -- 𝑓 + -- ["1:0x1D453"] = offset_f, -- needed for compact + -- ["2:0x1D453"] = offset_f, -- needed for compact +-- ["*:0x1D453"] = offset_f, -- 𝑓 + }, + } + + kerns = { + -- [0x1D449] = kern_V, -- 𝑉 + -- ["1:0x1D449"] = kern_V, -- needed for compact + -- ["2:0x1D449"] = kern_V, -- needed for compact + -- [0x1D44A] = kern_W, -- 𝑊 + -- ["1:0x1D44A"] = kern_W, -- needed for compact + -- ["2:0x1D44A"] = kern_W, -- needed for compact + -- ["*:0x1D453"] = kern_f, + ["*:0x1D449"] = kern_V, -- 𝑉 + ["*:0x1D44A"] = kern_W, -- 𝑊 + } + +end return { name = "pagella-math", @@ -12,54 +36,47 @@ return { mathematics = { tweaks = { aftercopying = { - { "version", "Version 1.632" }, - -- { "action", function(target,original) mathematics.tweaks.fixdimensions(target, original, fixes) }, - -- { "action", mathematics.tweaks.fixdimensions, fixes }, - { "dimensions", dimensions }, + -- { + -- tweak = "version", + -- expected = "Version 1.632", + -- }, + -- { + -- comment = "example" + -- tweak = "action", + -- action = function(target,original,parameters) mathematics.tweaks.fixdimensions(target, original, parameters) + -- list = fixes, -- one of the parameters + -- }, + -- { + -- comment = "example" + -- tweak = "action", + -- action = mathematics.tweaks.fixdimensions, + -- list = fixes, -- one of the parameters + -- }, + { + tweak = "dimensions", + list = { + [0x1D453] = { .40, 1.60, .5 }, -- offset width italic + }, + }, + { + tweak = "fixprimes", + factor = 0.85, + }, + { + tweak = "checkspacing", + }, + { + tweak = "addscripts", + }, }, }, alternates = { dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" }, }, + -- + -- experimental fixes for mkiv: + -- + dimensions = dimensions, + kerns = kerns, }, } - --- local kern_V = { bottomright = { { kern = -200 } } } --- local kern_W = { bottomright = { { kern = -100 } } } --- ----- kern_f = { bottomright = { { kern = -100 } } } --- -- local offset_f = { xoffset = "llx" } --- --- -- Beware of updates in ssty slots! --- --- return { --- name = "pagella-math", --- version = "1.00", --- comment = "Goodies that complement pagella.", --- author = "Hans Hagen", --- copyright = "ConTeXt development team", --- mathematics = { --- dimensions = { --- default = { --- -- [0x1D453] = { xoffset = 162, width = 278 + 162 },-- 𝑓 --- -- [0x1D453] = offset_f, -- 𝑓 --- -- ["1:0x1D453"] = offset_f, -- needed for compact --- -- ["2:0x1D453"] = offset_f, -- needed for compact --- -- ["*:0x1D453"] = offset_f, -- 𝑓 --- }, --- }, --- kerns = { --- -- [0x1D449] = kern_V, -- 𝑉 --- -- ["1:0x1D449"] = kern_V, -- needed for compact --- -- ["2:0x1D449"] = kern_V, -- needed for compact --- -- [0x1D44A] = kern_W, -- 𝑊 --- -- ["1:0x1D44A"] = kern_W, -- needed for compact --- -- ["2:0x1D44A"] = kern_W, -- needed for compact --- -- ["*:0x1D453"] = kern_f, --- ["*:0x1D449"] = kern_V, -- 𝑉 --- ["*:0x1D44A"] = kern_W, -- 𝑊 --- }, --- alternates = { --- dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" }, --- }, --- }, --- } diff --git a/tex/context/fonts/mkiv/schola-math.lfg b/tex/context/fonts/mkiv/schola-math.lfg index b60bc6d99..0a4d66892 100644 --- a/tex/context/fonts/mkiv/schola-math.lfg +++ b/tex/context/fonts/mkiv/schola-math.lfg @@ -1,7 +1,14 @@ -local kern_V = { bottomright = { { kern = -200 } }, topright = { { kern = 50 } } } -local kern_W = { bottomright = { { kern = -100 } }, topright = { { kern = 50 } } } +local dimensions, kerns if CONTEXTLMTXMODE == 0 then --- Beware of updates in ssty slots! + local kern_V = { bottomright = { { kern = -200 } }, topright = { { kern = 50 } } } + local kern_W = { bottomright = { { kern = -100 } }, topright = { { kern = 50 } } } + + kerns = { + [0x1D449] = kern_V, -- 𝑉 + [0x1D44A] = kern_W, -- 𝑊 + } + +end return { name = "schola-math", @@ -10,18 +17,33 @@ return { author = "Hans Hagen", copyright = "ConTeXt development team", mathematics = { - kerns = { - -- [0x1D449] = kern_V, -- 𝑉 - -- ["1:0x1D449"] = kern_V, -- needed for compact - -- ["2:0x1D449"] = kern_V, -- needed for compact - -- [0x1D44A] = kern_W, -- 𝑊 - -- ["1:0x1D44A"] = kern_W, -- needed for compact - -- ["2:0x1D44A"] = kern_W, -- needed for compact - ["*:0x1D449"] = kern_V, -- 𝑉 - ["*:0x1D44A"] = kern_W, -- 𝑊 + tweaks = { + aftercopying = { + { + tweak = "dimensions", + list = { + -- nothing yet + } + }, + { + tweak = "fixprimes", + factor = 0.85, + }, + { + tweak = "checkspacing", + }, + { + tweak = "addscripts", + }, + }, }, alternates = { dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" }, }, + -- + -- experimental fixes for mkiv: + -- + dimensions = dimensions, + kerns = kerns, }, } diff --git a/tex/context/fonts/mkiv/stix-two-math.lfg b/tex/context/fonts/mkiv/stix-two-math.lfg index 8d9c9c71a..cc09da04b 100644 --- a/tex/context/fonts/mkiv/stix-two-math.lfg +++ b/tex/context/fonts/mkiv/stix-two-math.lfg @@ -1,34 +1,3 @@ --- Bah, I really hate these patches especially because one needs to make --- sure that they are still valid when the font gets updated. So, let's --- do it runtime (not in the cached copy) and issue a warning every run. --- As we cannot rely on version numbers (if we have more patches) we --- check for values instead. --- --- This font also has inconsistent italics in smaller sizes which we can --- fix in a more general way but I'm not sure if we want that. - -local function fix_italic(target,original,name,value,factor) - local m = target.parameters.mathsize - if m then - local u = type(name) == "number" and name or original.resources.unicodes[name] - if u then - local c = target.characters[u] - if c then - local i = c.italic - if i then - local d = original.descriptions[u] - if d and d.math.italic == value then - if m then - logs.report("patching font","fixing italic correction of %U at math size %i by %0.3f",u,m,factor) - c.italic = factor * i - end - end - end - end - end - end -end - return { name = "stix-two-math", version = "1.00", @@ -36,7 +5,6 @@ return { author = "Hans Hagen", copyright = "ConTeXt development team", mathematics = { - -- these tags are suggestions and can still change alternates = { calligraphic = { feature = 'ss01', value = 1, comment = "Mathematical Alternative Calligraphic Characters" }, italic = { feature = 'ss02', value = 1, comment = "Mathematical Alternative Lowercase Italic" }, @@ -54,10 +22,22 @@ return { }, tweaks = { aftercopying = { - function(target,original) - fix_italic(target,original,"uni222B.updsp",80,3.5) - fix_italic(target,original,"uni222B.up", 80,2.5) - end, + { + tweak = "dimensions", + list = { + -- nothing yet + }, + }, + { + tweak = "fixprimes", + factor = 0.85, + }, + { + tweak = "checkspacing", + }, + { + tweak = "addscripts", + }, }, }, }, diff --git a/tex/context/fonts/mkiv/termes-math.lfg b/tex/context/fonts/mkiv/termes-math.lfg index da5a13d77..8752f0a3b 100644 --- a/tex/context/fonts/mkiv/termes-math.lfg +++ b/tex/context/fonts/mkiv/termes-math.lfg @@ -1,8 +1,22 @@ -local kern_V = { bottomright = { { kern = -200 } } } -local kern_W = { bottomright = { { kern = -100 } } } --- local offset_f = { xoffset = "llx" } +local dimensions, kerns if CONTEXTLMTXMODE == 0 then + + -- local kern_V = { bottomright = { { kern = -200 } } } + -- local kern_W = { bottomright = { { kern = -100 } } } + -- local offset_f = { xoffset = "llx" } + -- + -- dimensions = { + -- default = { + -- [0x1D453] = offset_f, -- 𝑓 + -- }, + -- } + -- + -- kerns = { + -- [0x1D449] = kern_V, -- 𝑉 + -- [0x1D44A] = kern_W, -- 𝑊 + -- } + +end --- Beware of updates in ssty slots! return { name = "termes-math", @@ -11,26 +25,33 @@ return { author = "Hans Hagen", copyright = "ConTeXt development team", mathematics = { - dimensions = { - default = { - -- [0x1D453] = offset_f, -- 𝑓 - -- ["1:0x1D453"] = offset_f, -- needed for compact - -- ["2:0x1D453"] = offset_f, -- needed for compact --- ["*:0x1D453"] = offset_f, -- 𝑓 + tweaks = { + aftercopying = { + { + tweak = "dimensions", + list = { + -- nothing yet + }, + }, + { + tweak = "fixprimes", + factor = 0.85, + }, + { + tweak = "checkspacing", + }, + { + tweak = "addscripts", + }, }, }, - kerns = { - -- [0x1D449] = kern_V, -- 𝑉 - -- ["1:0x1D449"] = kern_V, -- needed for compact - -- ["2:0x1D449"] = kern_V, -- needed for compact - -- [0x1D44A] = kern_W, -- 𝑊 - -- ["1:0x1D44A"] = kern_W, -- needed for compact - -- ["2:0x1D44A"] = kern_W, -- needed for compact - ["*:0x1D449"] = kern_V, -- 𝑉 - ["*:0x1D44A"] = kern_W, -- 𝑊 - }, alternates = { dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" }, }, + -- + -- experimental fixes for mkiv: + -- + dimensions = dimensions, + kerns = kerns, }, } diff --git a/tex/context/fonts/mkiv/xits-math.lfg b/tex/context/fonts/mkiv/xits-math.lfg index 88d3a8d45..f166afc80 100644 --- a/tex/context/fonts/mkiv/xits-math.lfg +++ b/tex/context/fonts/mkiv/xits-math.lfg @@ -1,23 +1,3 @@ --- \setupbodyfont[xits] --- --- $ABC$ $\cal ABC$ $\mathalternate{cal}\cal ABC$ --- --- \setupmathematics[italics=1] test $a;b;a; b; f;$ test\par % fontitalics --- \setupmathematics[italics=2] test $a;b;a; b; f;$ test\par % fontdata --- \setupmathematics[italics=3] test $a;b;a; b; f;$ test\par % quad based --- \setupmathematics[italics=4] test $a;b;a; b; f;$ test\par % combination of 1 and 3 - -local italics = { - defaultfactor = 0.025, - disableengine = true, - corrections = { - -- [0x1D44E] = 0.99, -- a (fraction of quad) - -- [0x1D44F] = 100, -- b (font points) - [0x1D453] = -0.0375, -- f - -- todo: ssty 1/2 - } -} - return { name = "xits-math", version = "1.00", @@ -35,14 +15,26 @@ return { }, }, mathematics = { - -- italics = { - -- ["xits-math"] = italics, - -- }, - -- kernpairs = { - -- [0x1D44A] = { -- 𝑊 - -- [0x1D434] = -200, -- 𝐴 - -- }, - -- }, + tweaks = { + aftercopying = { + { + tweak = "dimensions", + list = { + -- nothing yet + }, + }, + { + tweak = "fixprimes", + factor = 0.85, + }, + { + tweak = "checkspacing", + }, + { + tweak = "addscripts", + }, + }, + }, alternates = { calligraphic = { feature = 'ss01', value = 1, comment = "Mathematical Calligraphic Alphabet" }, greekssup = { feature = 'ss02', value = 1, comment = "Mathematical Greek Sans Serif Alphabet" }, diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 2a8f5349f..77d72f75b 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 2021-11-11 19:18 +-- merge date : 2021-11-13 20:33 do -- begin closure to overcome local limits and interference |