From 558dac3230c8a47d17fd4ad80201b0ccabb1fb55 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Sun, 27 Mar 2011 14:17:00 +0200 Subject: beta 2011.03.27 14:17 --- tex/context/base/cont-log.mkiv | 6 +- tex/context/base/font-afm.lua | 2 +- tex/context/base/font-chk.lua | 2 +- tex/context/base/font-col.lua | 6 +- tex/context/base/font-con.lua | 153 ++++++++--------------- tex/context/base/font-ctx.lua | 97 ++++++++++----- tex/context/base/font-enh.lua | 36 +++++- tex/context/base/font-fbk.lua | 4 +- tex/context/base/font-ini.mkiv | 35 ++++-- tex/context/base/font-log.lua | 2 +- tex/context/base/font-map.lua | 4 +- tex/context/base/font-ota.lua | 2 +- tex/context/base/font-otb.lua | 8 +- tex/context/base/font-otf.lua | 12 +- tex/context/base/math-act.lua | 142 +++++++++++++++++++++ tex/context/base/math-dim.lua | 30 +++-- tex/context/base/math-ext.lua | 4 +- tex/context/base/math-ini.lua | 134 -------------------- tex/context/base/math-ini.mkiv | 1 + tex/context/base/math-noa.lua | 2 +- tex/context/base/math-vfu.lua | 25 ++-- tex/context/base/node-inj.lua | 2 +- tex/context/base/status-files.pdf | Bin 23563 -> 23537 bytes tex/generic/context/luatex-fonts-def.lua | 2 +- tex/generic/context/luatex-fonts-merged.lua | 185 ++++++++++------------------ 25 files changed, 449 insertions(+), 447 deletions(-) create mode 100644 tex/context/base/math-act.lua diff --git a/tex/context/base/cont-log.mkiv b/tex/context/base/cont-log.mkiv index 158aee85c..171949ba0 100644 --- a/tex/context/base/cont-log.mkiv +++ b/tex/context/base/cont-log.mkiv @@ -219,7 +219,7 @@ % \ifx\fontalternative\c!bi -\else % \ifx\fontalternative\c!bs -\fi\fi\fi\fi -\def\LuaTeX +\unexpanded\def\LuaTeX {\dontleavehmode \begingroup Lua% @@ -246,4 +246,8 @@ \let\luaTeX \LuaTeX \let\LUATEX \LuaTeX +\unexpanded\def\MKII{MkII} +\unexpanded\def\MKIV{MkIV} +\unexpanded\def\MKVI{MkVI} + \protect \endinput diff --git a/tex/context/base/font-afm.lua b/tex/context/base/font-afm.lua index 8d35be9d6..09cd64491 100644 --- a/tex/context/base/font-afm.lua +++ b/tex/context/base/font-afm.lua @@ -380,7 +380,7 @@ unify = function(data, filename) if not code then code = private private = private + 1 - report_afm("assigning private slot U+%04X for unknown glyph name %s", code, name) + report_afm("assigning private slot U+%05X for unknown glyph name %s", code, name) end end local index = blob.index diff --git a/tex/context/base/font-chk.lua b/tex/context/base/font-chk.lua index 819586532..e3679f06d 100644 --- a/tex/context/base/font-chk.lua +++ b/tex/context/base/font-chk.lua @@ -47,7 +47,7 @@ local function onetimemessage(font,char,message) messages[message] = category end if not category[char] then - report_fonts("char U+%04X in font '%s' with id %s: %s",char,tfmdata.properties.fullname,font,message) + report_fonts("char U+%05X in font '%s' with id %s: %s",char,tfmdata.properties.fullname,font,message) category[char] = true end end diff --git a/tex/context/base/font-col.lua b/tex/context/base/font-col.lua index bf24737ba..945d35d43 100644 --- a/tex/context/base/font-col.lua +++ b/tex/context/base/font-col.lua @@ -72,12 +72,12 @@ function collections.define(name,font,ranges,details) if start and stop then if trace_collecting then if description then - report_fonts("def: using range %s (U+%04x-U+%04X, %s)",s,start,stop,description) + report_fonts("def: using range %s (U+%05x-U+%05X, %s)",s,start,stop,description) end for i=1,#d do local di = d[i] if (start >= di.start and start <= di.stop) or (stop >= di.start and stop <= di.stop) then - report_fonts("def: overlapping ranges U+%04x-U+%04X and U+%04x-U+%04X",start,stop,di.start,di.stop) + report_fonts("def: overlapping ranges U+%05x-U+%05X and U+%05x-U+%05X",start,stop,di.start,di.stop) end end end @@ -107,7 +107,7 @@ function collections.stage_2(name) local id = list[i] local start, stop = f.start, f.stop if trace_collecting then - report_fonts("def: remapping font %s to %s for range U+%04X - U+%04X",current,id,start,stop) + report_fonts("def: remapping font %s to %s for range U+%05X - U+%05X",current,id,start,stop) end local check = toboolean(f.check or "false",true) local force = toboolean(f.force or "true",true) diff --git a/tex/context/base/font-con.lua b/tex/context/base/font-con.lua index 434f64215..7e823c6e2 100644 --- a/tex/context/base/font-con.lua +++ b/tex/context/base/font-con.lua @@ -39,7 +39,6 @@ local contextnumbers = specifiers.contextnumbers -- will be directives -constructors.sharebasekerns = false -- true (.5 sec slower on mk but brings down mem from 410M to 310M, beware: then script/lang share too) constructors.dontembed = allocate() constructors.mathactions = { } constructors.autocleanup = true @@ -97,47 +96,6 @@ in the process; numbers are of course copies. Here 65536 equals 1pt. (Due to excessive memory usage in CJK fonts, we no longer pass the boundingbox.)

--ldx]]-- --- the following hack costs a bit of runtime but safes memory --- --- basekerns are scaled and will be hashed by table id --- sharedkerns are unscaled and are be hashed by concatenated indexes - ---~ function constructors.check_base_kerns(tfmdata) ---~ if constructors.sharebasekerns then ---~ local sharedkerns = tfmdata.sharedkerns ---~ if sharedkerns then ---~ local basekerns = { } ---~ tfmdata.basekerns = basekerns ---~ return sharedkerns, basekerns ---~ end ---~ end ---~ return nil, nil ---~ end - ---~ function constructors.prepare_base_kerns(tfmdata) ---~ if constructors.sharebasekerns and not tfmdata.sharedkerns then ---~ local sharedkerns = { } ---~ tfmdata.sharedkerns = sharedkerns ---~ for u, chr in next, tfmdata.characters do ---~ local kerns = chr.kerns ---~ if kerns then ---~ local hash = concat(sortedkeys(kerns), " ") ---~ local base = sharedkerns[hash] ---~ if not base then ---~ sharedkerns[hash] = kerns ---~ else ---~ chr.kerns = base ---~ end ---~ end ---~ end ---~ end ---~ end - --- we can cache scaled characters when we are in node mode and don't have --- protruding and expansion: hash == fullname @ size @ protruding @ expansion --- but in practice (except from mk) the otf hash will be enough already so it --- makes no sense to mess up the code now - -- The scaler is only used for otf and afm and virtual fonts. If -- a virtual font has italic correction make sure to set the -- italic_correction flag. Some more flags will be added in @@ -186,6 +144,34 @@ function constructors.calculatescale(tfmdata,scaledpoints) return scaledpoints, scaledpoints / (parameters.units or 1000) -- delta end +function constructors.assignmathparameters(target,tfmdata) + -- when a tfm file is loaded, it has already been scaled + -- and it never enters the scaled so this is otf only + local mathparameters = original.mathparameters + if mathparameters and next(mathparameters) then + local targetparameters = target.parameters + local targetmathparameters = { } + local factor = targetparameters.factor + for name, value in next, mathparameters do + if name == "RadicalDegreeBottomRaisePercent" then + targetmathparameters[name] = value + else + targetmathparameters[name] = value * factor + end + end + if not targetmathparameters.AccentBaseHeight then + targetmathparameters.AccentBaseHeight = nil -- safeguard, still needed? + end + if not targetmathparameters.FractionDelimiterSize then + targetmathparameters.FractionDelimiterSize = 0 + end + if not mathparameters.FractionDelimiterDisplayStyleSize then + targetmathparameters.FractionDelimiterDisplayStyleSize = 0 + end + target.mathparameters = targetmathparameters + end +end + function constructors.scale(tfmdata,specification) local target = { } -- the new table -- @@ -205,23 +191,22 @@ function constructors.scale(tfmdata,specification) local shared = tfmdata.shared or { } local parameters = tfmdata.parameters or { } local mathparameters = tfmdata.mathparameters or { } - local MathConstants = tfmdata.mathconstants or { } -- local targetcharacters = { } local targetdescriptions = table.derive(descriptions) local targetparameters = table.derive(parameters) - local targetmathparameters = table.derive(mathparameters) + -- local targetmathparameters = table.fastcopy(mathparameters) -- happens elsewhere local targetproperties = table.derive(properties) - local targetgoodies = table.derive(goodies) + local targetgoodies = goodies -- we need to loop so no metatable target.characters = targetcharacters target.descriptions = targetdescriptions target.parameters = targetparameters - target.mathparameters = targetmathparameters + -- target.mathparameters = targetmathparameters -- happens elsewhere target.properties = targetproperties target.goodies = targetgoodies target.shared = shared target.resources = resources - target.unscaled = tfmdata -- the original unscaled one (temp) + target.unscaled = tfmdata -- the original unscaled one -- -- specification.mathsize : 1=text 2=script 3=scriptscript -- specification.textsize : natural (text)size @@ -331,9 +316,9 @@ function constructors.scale(tfmdata,specification) target.slant = 0 end -- + targetparameters.factor = delta targetparameters.hfactor = hdelta targetparameters.vfactor = vdelta - targetparameters.factor = delta targetparameters.size = scaledpoints targetparameters.units = units targetparameters.scaledpoints = askedscaledpoints @@ -350,18 +335,6 @@ function constructors.scale(tfmdata,specification) end -- target.type = isvirtual and "virtual" or "real" - -- more extensive test - local hasmath = (properties.math or next(mathparameters) or next(MathConstants)) and true - if hasmath then - properties.has_math = true - target.nomath = false - target.MathConstants = MathConstants - target.mathconstants = MathConstants - else - properties.has_math = false - target.nomath = true - target.mathparameters = nil -- nop - end -- this will move to some subtable so that it is copied at once target.postprocessors = tfmdata.postprocessors -- @@ -389,45 +362,37 @@ function constructors.scale(tfmdata,specification) if descender then targetparameters.descender = delta * descender end + -- copies, might disappear + targetparameters.xheight = targetparameters.xheight or parameters.x_height + targetparameters.extraspace = targetparameters.extraspace or parameters.extra_space + targetparameters.spacestretch = targetparameters.spacestretch or parameters.space_stretch + targetparameters.spaceshrink = targetparameters.spaceshrink or parameters.space_shrink + -- + local protrusionfactor = (targetquad ~= 0 and 1000/targetquad) or 0 + local scaledwidth = defaultwidth * hdelta + local scaledheight = defaultheight * vdelta + local scaleddepth = defaultdepth * vdelta -- + local hasmath = (properties.has_math or next(mathparameters)) and true if hasmath then - local ma = constructors.mathactions - local ta = type(ma) - if ta == "function" then -- context - ma(target,tfmdata) - elseif ta == "table" then -- generic (we keep the deltas) - for i=1,#ma do - ma[i](target,tfmdata,delta,hdelta,vdelta) - end - end - if not targetparameters[13] then targetparameters[13] = .86*targetx_height end -- mathsupdisplay - if not targetparameters[14] then targetparameters[14] = .86*targetx_height end -- mathsupnormal - if not targetparameters[15] then targetparameters[15] = .86*targetx_height end -- mathsupcramped - if not targetparameters[16] then targetparameters[16] = .48*targetx_height end -- mathsubnormal - if not targetparameters[17] then targetparameters[17] = .48*targetx_height end -- mathsubcombined - if not targetparameters[22] then targetparameters[22] = 0 end -- mathaxisheight - if target.MathConstants then target.MathConstants.AccentBaseHeight = nil end -- safeguard if trace_defining then report_defining("math enabled for: name '%s', fullname: '%s', filename: '%s'", name or "noname",fullname or "nofullname",filename or "nofilename") end + constructors.assignmathparameters(target,tfmdata) -- does scaling and whatever is needed + properties.has_math = true + target.nomath = false + target.MathConstants = target.mathparameters else if trace_defining then report_defining("math disabled for: name '%s', fullname: '%s', filename: '%s'", name or "noname",fullname or "nofullname",filename or "nofilename") end + properties.has_math = false + target.nomath = true + target.mathparameters = nil -- nop end -- - targetparameters.xheight = targetparameters.xheight or parameters.x_height - targetparameters.extraspace = targetparameters.extraspace or parameters.extra_space - targetparameters.spacestretch = targetparameters.spacestretch or parameters.space_stretch - targetparameters.spaceshrink = targetparameters.spaceshrink or parameters.space_shrink - -- - local protrusionfactor = (targetquad ~= 0 and 1000/targetquad) or 0 - local scaledwidth = defaultwidth * hdelta - local scaledheight = defaultheight * vdelta - local scaleddepth = defaultdepth * vdelta - -- local sharedkerns = { } -- for unicode, character in next, characters do @@ -526,7 +491,7 @@ function constructors.scale(tfmdata,specification) if vn then chr.next = vn -- if character.vert_variants or character.horiz_variants then - -- report_defining("glyph 0x%05X has combination of next, vert_variants and horiz_variants",index) + -- report_defining("glyph U+%05X has combination of next, vert_variants and horiz_variants",index) -- end else local vv = character.vert_variants @@ -588,19 +553,6 @@ function constructors.scale(tfmdata,specification) if not nodemode then local vk = character.kerns if vk then - -- if sharedkerns then - -- local base = basekerns[vk] -- hashed by table id, not content - -- if not base then - -- base = {} - -- for k,v in next, vk do base[k] = v*hdelta end - -- basekerns[vk] = base - -- end - -- chr.kerns = base - -- else - -- local tt = {} - -- for k,v in next, vk do tt[k] = v*hdelta end - -- chr.kerns = tt - -- end local s = sharedkerns[vk] if not s then s = { } @@ -757,7 +709,6 @@ function constructors.finalize(tfmdata) -- -- tfmdata.fonts -- tfmdata.unscaled - -- tfmdata.mathconstants -- if not properties.has_math then properties.has_math = not tfmdata.nomath diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index d3886eee8..e68874a4a 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -600,8 +600,9 @@ end local n = 0 -- we can also move rscale to here (more consistent) +-- the argument list will become a table -function definers.stage_two(global,cs,str,size,classfeatures,fontfeatures,classfallbacks,fontfallbacks, +function definers.stage_two(global,cs,str,size,inheritancemode,classfeatures,fontfeatures,classfallbacks,fontfallbacks, mathsize,textsize,relativeid,classgoodies,goodies) if trace_defining then report_defining("memory usage before: %s",statistics.memused()) @@ -616,27 +617,67 @@ function definers.stage_two(global,cs,str,size,classfeatures,fontfeatures,classf local id = tonumber(relativeid) or 0 specification.relativeid = id > 0 and id end - specification.name = name - specification.size = size - specification.sub = (sub and sub ~= "" and sub) or specification.sub + specification.name = name + specification.size = size + specification.sub = (sub and sub ~= "" and sub) or specification.sub specification.mathsize = mathsize specification.textsize = textsize - specification.goodies = goodies - specification.cs = cs - specification.global = global + specification.goodies = goodies + specification.cs = cs + specification.global = global if detail and detail ~= "" then - specification.method, specification.detail = method or "*", detail + specification.method = method or "*" + specification.detail = detail elseif specification.detail and specification.detail ~= "" then -- already set - elseif fontfeatures and fontfeatures ~= "" then - specification.method, specification.detail = "*", fontfeatures - elseif classfeatures and classfeatures ~= "" then - specification.method, specification.detail = "*", classfeatures - end - if fontfallbacks and fontfallbacks ~= "" then - specification.fallbacks = fontfallbacks - elseif classfallbacks and classfallbacks ~= "" then - specification.fallbacks = classfallbacks + elseif inheritancemode == 0 then + -- nothing + elseif inheritancemode == 1 then + -- fontonly + if fontfeatures and fontfeatures ~= "" then + specification.method = "*" + specification.detail = fontfeatures + end + if fontfallbacks and fontfallbacks ~= "" then + specification.fallbacks = fontfallbacks + end + elseif inheritancemode == 2 then + -- classonly + if classfeatures and classfeatures ~= "" then + specification.method = "*" + specification.detail = classfeatures + end + if classfallbacks and classfallbacks ~= "" then + specification.fallbacks = classfallbacks + end + elseif inheritancemode == 3 then + -- fontfirst + if fontfeatures and fontfeatures ~= "" then + specification.method = "*" + specification.detail = fontfeatures + elseif classfeatures and classfeatures ~= "" then + specification.method = "*" + specification.detail = classfeatures + end + if fontfallbacks and fontfallbacks ~= "" then + specification.fallbacks = fontfallbacks + elseif classfallbacks and classfallbacks ~= "" then + specification.fallbacks = classfallbacks + end + elseif inheritancemode == 4 then + -- classfirst + if classfeatures and classfeatures ~= "" then + specification.method = "*" + specification.detail = classfeatures + elseif fontfeatures and fontfeatures ~= "" then + specification.method = "*" + specification.detail = fontfeatures + end + if classfallbacks and classfallbacks ~= "" then + specification.fallbacks = classfallbacks + elseif fontfallbacks and fontfallbacks ~= "" then + specification.fallbacks = fontfallbacks + end end local tfmdata = definers.read(specification,size) -- id not yet known local cs = specification.cs @@ -1025,7 +1066,7 @@ function commands.showchardata(n) end local chr = tfmdata.characters[n] if chr then - report_status("%s @ %s => U%04X => %s => %s",tfmdata.properties.fullname,tfmdata.parameters.size,n,utfchar(n),serialize(chr,false)) + report_status("%s @ %s => U%05X => %s => %s",tfmdata.properties.fullname,tfmdata.parameters.size,n,utfchar(n),serialize(chr,false)) end end end @@ -1033,19 +1074,19 @@ end function commands.showfontparameters() local tfmdata = fontdata[currentfont()] if tfmdata then - local parameters = tfmdata.parameters - local mathconstants = tfmdata.MathConstants - local properties = tfmdata.properties - local hasparameters = parameters and next(parameters) - local hasmathconstants = mathconstants and next(mathconstants) + local parameters = tfmdata.parameters + local mathparameters = tfmdata.mathparameters + local properties = tfmdata.properties + local hasparameters = parameters and next(parameters) + local hasmathparameters = mathparameters and next(mathparameters) if hasparameters then - report_status("%s @ %s => parameters => %s",properties.fullname,parameters.size,serialize(parameters,false)) + report_status("%s @ %s => text parameters => %s",properties.fullname,parameters.size,serialize(parameters,false)) end - if hasmathconstants then - report_status("%s @ %s => math constants => %s",properties.fullname,parameters.size,serialize(mathconstants,false)) + if hasmathparameters then + report_status("%s @ %s => math parameters => %s",properties.fullname,parameters.size,serialize(mathparameters,false)) end - if not hasparameters and not hasmathconstants then - report_status("%s @ %s => no parameters and/or mathconstants",properties.fullname,parameters.size) + if not hasparameters and not hasmathparameters then + report_status("%s @ %s => no text parameters and/or math parameters",properties.fullname,parameters.size) end end end diff --git a/tex/context/base/font-enh.lua b/tex/context/base/font-enh.lua index 54e5e242a..d19424384 100644 --- a/tex/context/base/font-enh.lua +++ b/tex/context/base/font-enh.lua @@ -20,6 +20,9 @@ local registertfmfeature = tfmfeatures.register local afmfeatures = fonts.constructors.newfeatures("afm") local registerafmfeature = afmfeatures.register +local otffeatures = fonts.constructors.newfeatures("otf") +local registerotffeature = otffeatures.register + -- -- these will become goodies (when needed at all) -- -- local fontencodings = fonts.encodings @@ -41,7 +44,7 @@ local registerafmfeature = afmfeatures.register -- for newcode, oldcode in next, data.unicodes do -- if newcode ~= oldcode then -- if trace_defining then --- report_defining("reencoding U+%04X to U+%04X",newcode,oldcode) +-- report_defining("reencoding U+%05X to U+%05X",oldcode,newcode) -- end -- characters[newcode] = original[oldcode] -- end @@ -69,7 +72,7 @@ local registerafmfeature = afmfeatures.register -- for k,v in next, vector do -- if k ~= v then -- if trace_defining then --- report_defining("remapping U+%04X to U+%04X",k,v) +-- report_defining("remapping U+%05X to U+%05X",k,v) -- end -- local c = original[k] -- characters[v] = c @@ -100,6 +103,7 @@ local registerafmfeature = afmfeatures.register -- we only add and don't replace -- we could also add kerns but we asssume symbols +-- todo: complain if not basemode local function initializeunicoding(tfmdata) local goodies = tfmdata.goodies @@ -114,10 +118,26 @@ local function initializeunicoding(tfmdata) local characters = tfmdata.characters local descriptions = tfmdata.descriptions local oldcoding = tfmdata.resources.unicodes + local originals = { } for name, newcode in next, newcoding do local oldcode = oldcoding[name] - characters [newcode] = characters [oldcode] - descriptions[newcode] = descriptions[oldcode] + if characters[newcode] and not originals[newcode] then + originals[newcode] = { + character = characters [newcode], + description = descriptions[newcode], + } + end + local original = originals[oldcode] + if original then + characters [newcode] = original.character + descriptions[newcode] = original.description + else + characters [newcode] = characters [oldcode] + descriptions[newcode] = descriptions[oldcode] + end + if trace_defining then + report_defining("aliasing glyph '%s' from U+%05X to U+%05X",name,oldcode,newcode) + end end end end @@ -131,3 +151,11 @@ registerafmfeature { } } +registerotffeature { + name = "unicoding", + description = "adapt unicode table", + initializers = { + base = initializeunicoding, + node = initializeunicoding, + } +} diff --git a/tex/context/base/font-fbk.lua b/tex/context/base/font-fbk.lua index d5cec59c9..6712fbe88 100644 --- a/tex/context/base/font-fbk.lua +++ b/tex/context/base/font-fbk.lua @@ -107,7 +107,7 @@ local function composecharacters(tfmdata) end if charsacc then if trace_combining_all then - report_combining("%s (0x%05X) = %s (0x%05X) + %s (0x%05X)",utfchar(i),i,utfchar(chr),chr,utfchar(acc),acc) + report_combining("%s (U+%05X) = %s (U+%05X) + %s (U+%05X)",utfchar(i),i,utfchar(chr),chr,utfchar(acc),acc) end local acc_t = cache[acc] if not acc_t then @@ -176,7 +176,7 @@ local function composecharacters(tfmdata) end else if trace_combining_all then - report_combining("%s (0x%05X) = %s (0x%05X) (simplified)",utfchar(i),i,utfchar(chr),chr) + report_combining("%s (U+%05X) = %s (U+%05X) (simplified)",utfchar(i),i,utfchar(chr),chr) end t.commands = { chr_t } -- else index mess end diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv index f4a1fc5ba..442ac4861 100644 --- a/tex/context/base/font-ini.mkiv +++ b/tex/context/base/font-ini.mkiv @@ -181,11 +181,10 @@ \let\thedefinedfont\relax \def\dodefinedfont[#1]% - {\setfalse\inheritfromfontclass + {\featureinheritancemode\featureinheritancefontonly \iffirstargument\definefont[thedefinedfont][#1]\fi % we can speed this one up \thedefinedfont - \the\everydefinedfont - \settrue\inheritfromfontclass} + \the\everydefinedfont} \unexpanded\def\definedfont {\dosingleempty\dodefinedfont} @@ -701,7 +700,20 @@ \let\relativefontid\empty -\newconditional\inheritfromfontclass % used in \definefont and \definedfont +% 0 = none +% 1 = fontonly +% 2 = classonly +% 3 = fontfirst +% 4 = classfirst + +\setnewconstant\featureinheritancefontnone \zerocount +\setnewconstant\featureinheritancefontonly \plusone +\setnewconstant\featureinheritanceclassonly \plustwo +\setnewconstant\featureinheritancefontfirst \plusthree +\setnewconstant\featureinheritanceclassfirst\plusfour + +\setnewconstant\featureinheritancedefault \featureinheritancefontfirst +\setnewconstant\featureinheritancemode \featureinheritancedefault \unexpanded\def\lowleveldefinefont#1#2% #2 = cs {% we can now set more at the lua end @@ -742,20 +754,22 @@ "#2", % cs, trailing % is gone "\somefontfile", \number\scaledfontsize, - "\ifconditional\inheritfromfontclass\@@fontclassfeatures\fi", + \number\featureinheritancemode, + "\@@fontclassfeatures", "\@@fontfeatures", - "\ifconditional\inheritfromfontclass\@@fontclassfallbacks\fi", + "\@@fontclassfallbacks", "\@@fontfallbacks", 0\currentmathsize, \number\dimexpr\textface\relax, "\relativefontid", % experiment - "\ifconditional\inheritfromfontclass\@@fontclassgoodies\fi", % experiment (not yet used) + "\@@fontclassgoodies", % experiment (not yet used) "\@@fontgoodies" % experiment )}% % \edef\somefontspec{at \somefontsize}% we need the resolved designsize (for fallbacks) \edef\somefontspec{at \number\scaledfontsize sp}% we need the resolved designsize (for fallbacks) \expandafter\let\expandafter\lastrawfontcall\csname#2\endcsname - \the\everydefinefont} + \the\everydefinefont + \setnewconstant\featureinheritancemode\featureinheritancedefault} \def\updatefontclassparameters {\edef\@@fontclassfeatures {\ifcsname\fontclass\fontstyle\s!features \endcsname\csname\fontclass\fontstyle\s!features \endcsname\fi}% @@ -1183,7 +1197,7 @@ \def\newfontidentifier{*\fontclass\lastfontidentifier\fontstyle\fontsize*} \def\dododefinefont#1#2% - {\setfalse\inheritfromfontclass + {\featureinheritancemode\featureinheritancefontonly \edef\lastfontidentifier{#1}% \let\localrelativefontsize\defaultrelativefontsize \let\localabsolutefontsize\fontbody @@ -1192,8 +1206,7 @@ \autofontsizefalse \setfontcharacteristics \the\everyfontswitch - \let\rawfontidentifier\oldrawfontidentifier - \settrue\inheritfromfontclass} + \let\rawfontidentifier\oldrawfontidentifier} \def\xxdododefinefont#1#2#3#4% \autofontsizetrue is set by calling routine {\edef\lastfontidentifier{#3}% diff --git a/tex/context/base/font-log.lua b/tex/context/base/font-log.lua index 5f18c52cb..d89482737 100644 --- a/tex/context/base/font-log.lua +++ b/tex/context/base/font-log.lua @@ -43,7 +43,7 @@ function loggers.onetimemessage(font,char,message,reporter) if not reporter then reporter = report_defining end - reporter("char U+%04X in font '%s' with id %s: %s",char,tfmdata.properties.fullname,font,message) + reporter("char U+%05X in font '%s' with id %s: %s",char,tfmdata.properties.fullname,font,message) category[char] = true end end diff --git a/tex/context/base/font-map.lua b/tex/context/base/font-map.lua index 0733f245c..76733adea 100644 --- a/tex/context/base/font-map.lua +++ b/tex/context/base/font-map.lua @@ -272,9 +272,9 @@ function mappings.addtounicode(data,filename) local index = glyph.index local toun = tounicode[index] if toun then - report_fonts("internal: 0x%05X, name: %s, unicode: 0x%05X, tounicode: %s",index,name,unic,toun) + report_fonts("internal: 0x%05X, name: %s, unicode: U+%05X, tounicode: %s",index,name,unic,toun) else - report_fonts("internal: 0x%05X, name: %s, unicode: 0x%05X",index,name,unic) + report_fonts("internal: 0x%05X, name: %s, unicode: U+%05X",index,name,unic) end end end diff --git a/tex/context/base/font-ota.lua b/tex/context/base/font-ota.lua index 8ca9d8e6a..a820236fd 100644 --- a/tex/context/base/font-ota.lua +++ b/tex/context/base/font-ota.lua @@ -239,7 +239,7 @@ local arab_warned = { } local function warning(current,what) local char = current.char if not arab_warned[char] then - log.report("analyze","arab: character %s (U+%04X) has no %s class", char, char, what) + log.report("analyze","arab: character %s (U+%05X) has no %s class", char, char, what) arab_warned[char] = true end end diff --git a/tex/context/base/font-otb.lua b/tex/context/base/font-otb.lua index d4019b31d..f3285da1c 100644 --- a/tex/context/base/font-otb.lua +++ b/tex/context/base/font-otb.lua @@ -34,15 +34,15 @@ local function gref(descriptions,n) if type(n) == "number" then local name = descriptions[n].name if name then - return format("U+%04X (%s)",n,name) + return format("U+%05X (%s)",n,name) else - return format("U+%04X") + return format("U+%05X") end elseif n then local num, nam = { }, { } for i=2,#n do -- first is likely a key local ni = n[i] - num[i] = format("U+%04X",ni) + num[i] = format("U+%05X",ni) nam[i] = descriptions[ni].name or "?" end return format("%s (%s)",concat(num," "), concat(nam," ")) @@ -374,7 +374,7 @@ local function make_2(present,tfmdata,characters,tree,name,preceding,unicode,don local character = characters[preceding] if not character then if trace_baseinit then - report_prepare("weird ligature in lookup %s: 0x%04X (%s), preceding 0x%04X (%s)",lookupname,v,utfchar(v),preceding,utfchar(preceding)) + report_prepare("weird ligature in lookup %s: U+%05X (%s), preceding U+%05X (%s)",lookupname,v,utfchar(v),preceding,utfchar(preceding)) end character = makefake(tfmdata,name,present) end diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua index 00c612999..7a0d061b3 100644 --- a/tex/context/base/font-otf.lua +++ b/tex/context/base/font-otf.lua @@ -625,7 +625,7 @@ actions["prepare glyphs"] = function(data,filename,raw) unicode = private unicodes[name] = private if trace_private then - report_otf("enhance: glyph %s at index U+%04X is moved to private unicode slot U+%04X",name,index,private) + report_otf("enhance: glyph %s at index 0x%04X is moved to private unicode slot U+%05X",name,index,private) end private = private + 1 nofnames = nofnames + 1 @@ -672,7 +672,7 @@ actions["prepare glyphs"] = function(data,filename,raw) unicode = private unicodes[name] = private if trace_private then - report_otf("enhance: glyph %s at index U+%04X is moved to private unicode slot U+%04X",name,index,private) + report_otf("enhance: glyph %s at index 0x%04X is moved to private unicode slot U+%05X",name,index,private) end private = private + 1 else @@ -730,7 +730,7 @@ actions["prepare unicodes"] = function(data,filename,raw) local description = descriptions[parent] if description then local c = fastcopy(description) - c.comment = format("copy of 0x%04X", parent) + c.comment = format("copy of U+%05X", parent) descriptions[unicode] = c local name = c.name if not unicodes[name] then @@ -740,7 +740,7 @@ actions["prepare unicodes"] = function(data,filename,raw) multiples[nofmultiples] = name -- we can save duplicates if needed else -- make it a notdef - report_otf("weird unicode 0x%04X at index 0x%04X",unicode,index) + report_otf("weird unicode U+%05X at index 0x%04X",unicode,index) end end end @@ -1294,7 +1294,7 @@ actions["reorganize glyph kerns"] = function(data,filename,raw) end end elseif trace_loading then - report_otf("problems with unicode %s of kern %s of glyph 0x%04X",name,k,unicode) + report_otf("problems with unicode %s of kern %s of glyph U+%05X",name,k,unicode) end end end @@ -1379,7 +1379,7 @@ actions["merge kern classes"] = function(data,filename,raw) lookupkerns[second_unicode] = kern end elseif trace_loading then - report_otf("no glyph data for U+%04X", first_unicode) + report_otf("no glyph data for U+%05X", first_unicode) end end end diff --git a/tex/context/base/math-act.lua b/tex/context/base/math-act.lua new file mode 100644 index 000000000..03675933e --- /dev/null +++ b/tex/context/base/math-act.lua @@ -0,0 +1,142 @@ +if not modules then modules = { } end modules ['math-act'] = { + version = 1.001, + comment = "companion to math-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end) +local report_math = logs.reporter("mathematics","initializing") + +local mathematics = mathematics + +local sequencers = utilities.sequencers +local appendgroup = sequencers.appendgroup +local appendaction = sequencers.appendaction +local mathprocessor = nil + +local mathactions = sequencers.reset { + arguments = "target,original", +} + +function fonts.constructors.assignmathparameters(original,target) + if mathactions.dirty then -- maybe use autocompile + mathprocessor = sequencers.compile(mathactions) + end + mathprocessor(original,target) +end + +appendgroup(mathactions,"before") -- user +appendgroup(mathactions,"system") -- private +appendgroup(mathactions,"after" ) -- user + +function mathematics.initializeparameters(target,original) + local mathparameters = original.mathparameters + if mathparameters and next(mathparameters) then + target.mathparameters = mathematics.dimensions(mathparameters) + end +end + +sequencers.appendaction(mathactions,"system","mathematics.initializeparameters") + +local how = { + -- RadicalKernBeforeDegree = "horizontal", + -- RadicalKernAfterDegree = "horizontal", + RadicalDegreeBottomRaisePercent = "unscaled" +} + +function mathematics.scaleparameters(target,original) + if not target.properties.math_is_scaled then + local mathparameters = target.mathparameters + if mathparameters and next(mathparameters) then + local parameters = target.parameters + local factor = parameters.factor + local hfactor = parameters.hfactor + local vfactor = parameters.vfactor + for name, value in next, mathparameters do + local h = how[name] + if h == "unscaled" then + mathparameters[name] = value + elseif h == "horizontal" then + mathparameters[name] = value * hfactor + elseif h == "vertical"then + mathparameters[name] = value * vfactor + else + mathparameters[name] = value * factor + end + end + end + target.properties.math_is_scaled = true + end +end + +sequencers.appendaction(mathactions,"system","mathematics.scaleparameters") + +function mathematics.checkaccentbaseheight(target,original) + local mathparameters = target.mathparameters + if mathparameters then + mathparameters.AccentBaseHeight = nil -- safeguard + end +end + +sequencers.appendaction(mathactions,"system","mathematics.checkaccentbaseheight") + +function mathematics.checkprivateparameters(target,original) + local mathparameters = target.mathparameters + if mathparameters then + if not mathparameters.FractionDelimiterSize then + mathparameters.FractionDelimiterSize = 0 + end + if not mathparameters.FractionDelimiterDisplayStyleSize then + mathparameters.FractionDelimiterDisplayStyleSize = 0 + end + end +end + +sequencers.appendaction(mathactions,"system","mathematics.checkprivateparameters") + +function mathematics.overloadparameters(target,original) + local mathparameters = target.mathparameters + if mathparameters and next(mathparameters) then + local goodies = target.goodies + if goodies then + for i=1,#goodies do + local goodie = goodies[i] + local mathematics = goodie.mathematics + local parameters = mathematics and mathematics.parameters + if parameters then + if trace_defining then + report_math("overloading math parameters in '%s' @ %s",target.properties.fullname,target.parameters.size) + end + for name, value in next, parameters do + local tvalue = type(value) + if tvalue == "string" then + report_math("comment for math parameter '%s': %s",name,value) + else + local oldvalue = mathparameters[name] + local newvalue = oldvalue + if oldvalue then + if tvalue == "number" then + newvalue = value + elseif tvalue == "function" then + newvalue = value(oldvalue,target,original) + elseif not tvalue then + newvalue = nil + end + if trace_defining and oldvalue ~= newvalue then + report_math("overloading math parameter '%s': %s => %s",name,tostring(oldvalue),tostring(newvalue)) + end + else + report_math("invalid math parameter '%s'",name) + end + mathparameters[name] = newvalue + end + end + end + end + end + end +end + +sequencers.appendaction(mathactions,"system","mathematics.overloadparameters") diff --git a/tex/context/base/math-dim.lua b/tex/context/base/math-dim.lua index 1d3f93ad3..7b4b49f68 100644 --- a/tex/context/base/math-dim.lua +++ b/tex/context/base/math-dim.lua @@ -216,10 +216,10 @@ end -- return t.default or t.text_style or 0 -- end -function mathematics.dimensions(dimens) +function mathematics.dimensions(dimens) -- beware, dimens get spoiled if dimens.SpaceAfterScript then dimens.SubscriptShiftDownWithSuperscript = dimens.SubscriptShiftDown * 1.5 - return { }, table.fastcopy(dimens) + return table.fastcopy(dimens), { } elseif dimens.AxisHeight or dimens.axis_height then local t = { } local math_x_height = dimens.x_height or 10*65526 @@ -259,8 +259,11 @@ function mathematics.dimensions(dimens) t[variable] = tt end local d = { - AxisHeight = t . axis . text_style, AccentBaseHeight = t . accent_base_height . text_style, + AxisHeight = t . axis . text_style, + -- DelimitedSubFormulaMinHeight + -- DisplayOperatorMinHeight + -- FlattenedAccentBaseHeight FractionDenominatorDisplayStyleGapMin = t . fraction_denom_vgap . display_style, FractionDenominatorDisplayStyleShiftDown = t . fraction_denom_down . display_style, FractionDenominatorGapMin = t . fraction_denom_vgap . text_style, @@ -274,6 +277,8 @@ function mathematics.dimensions(dimens) FractionDelimiterDisplayStyleSize = t . fraction_del_size . display_style, LowerLimitBaselineDropMin = t . limit_below_bgap . text_style, LowerLimitGapMin = t . limit_below_vgap . text_style, + -- MathLeading + MinConnectorOverlap = t . connector_overlap_min . text_style, OverbarExtraAscender = t . overbar_kern . text_style, OverbarRuleThickness = t . overbar_rule . text_style, OverbarVerticalGap = t . overbar_vgap . text_style, @@ -284,6 +289,10 @@ function mathematics.dimensions(dimens) RadicalKernBeforeDegree = t . radical_degree_before . display_style, RadicalKernAfterDegree = t . radical_degree_after . display_style, RadicalDegreeBottomRaisePercent = t . radical_degree_raise . display_style, + -- ScriptPercentScaleDown + -- ScriptScriptPercentScaleDown + -- SkewedFractionHorizontalGap + -- SkewedFractionVerticalGap SpaceAfterScript = t . space_after_script . text_style, StackBottomDisplayStyleShiftDown = t . stack_denom_down . display_style, StackBottomShiftDown = t . stack_denom_down . text_style, @@ -291,11 +300,15 @@ function mathematics.dimensions(dimens) StackGapMin = t . stack_vgap . text_style, StackTopDisplayStyleShiftUp = t . stack_num_up . display_style, StackTopShiftUp = t . stack_num_up . text_style, + StretchStackGapBelowMin = t . over_delimiter_vgap . text_style, + StretchStackTopShiftUp = t . over_delimiter_bgap . text_style, + StretchStackGapAboveMin = t . under_delimiter_vgap . text_style, + StretchStackBottomShiftDown = t . under_delimiter_bgap . text_style, + SubSuperscriptGapMin = t . subsup_vgap . text_style, SubscriptBaselineDropMin = t . sub_shift_drop . text_style, SubscriptShiftDown = t . sub_shift_down . text_style, SubscriptShiftDownWithSuperscript = t . sub_sup_shift_down . text_style, SubscriptTopMax = t . sub_top_max . text_style, - SubSuperscriptGapMin = t . subsup_vgap . text_style, SuperscriptBaselineDropMax = t . sup_shift_drop . text_style, SuperscriptBottomMaxWithSubscript = t . sup_sub_bottom_max . text_style, SuperscriptBottomMin = t . sup_bottom_min . text_style, @@ -306,14 +319,9 @@ function mathematics.dimensions(dimens) UnderbarVerticalGap = t . underbar_vgap . text_style, UpperLimitBaselineRiseMin = t . limit_above_bgap . text_style, UpperLimitGapMin = t . limit_above_vgap . text_style, - MinConnectorOverlap = t . connector_overlap_min . text_style, - StretchStackGapBelowMin = t . over_delimiter_vgap . text_style, - StretchStackTopShiftUp = t . over_delimiter_bgap . text_style, - StretchStackGapAboveMin = t . under_delimiter_vgap . text_style, - StretchStackBottomShiftDown = t . under_delimiter_bgap . text_style, } - d.AccentBaseHeight = 0 - return t, d -- this might change + d.AccentBaseHeight = 0 -- here? still? + return d, t -- t only for diagnostics else return { }, { } end diff --git a/tex/context/base/math-ext.lua b/tex/context/base/math-ext.lua index ac994ea35..da00c7a9e 100644 --- a/tex/context/base/math-ext.lua +++ b/tex/context/base/math-ext.lua @@ -25,7 +25,7 @@ function extras.add(unicode,t) if unicode >= min and unicode <= max then mathdata[unicode], chardata[unicode] = t, t else - report_math("extra U+%04X should be in range U+%04X - U+%04X",unicode,min,max) + report_math("extra U+%05X should be in range U+%05X - U+%05X",unicode,min,max) end end @@ -47,7 +47,7 @@ function extras.copy(target,original) local nextchar = characters[nextnext] if nextchar then if trace_virtual then - report_math("extra U+%04X in %s at %s maps on U+%04X (class: %s, name: %s)",unicode, + report_math("extra U+%05X in %s at %s maps on U+%05X (class: %s, name: %s)",unicode, file.basename(properties.fullname),parameters.size,nextslot,extradesc.mathclass or "?",extradesc.mathname or "?") end characters[unicode] = nextchar diff --git a/tex/context/base/math-ini.lua b/tex/context/base/math-ini.lua index b211f7dd2..a122f7229 100644 --- a/tex/context/base/math-ini.lua +++ b/tex/context/base/math-ini.lua @@ -9,8 +9,6 @@ if not modules then modules = { } end modules ['math-ext'] = { -- if needed we can use the info here to set up xetex definition files -- the "8000 hackery influences direct characters (utf) as indirect \char's -local utf = unicode.utf8 - local texsprint, format, utfchar, utfbyte = tex.sprint, string.format, utf.char, utf.byte local setmathcode, setdelcode = tex.setmathcode, tex.setdelcode @@ -367,135 +365,3 @@ function mathematics.big(tfmdata,unicode,n) return unicode end --- plugins (will be proper handler, once we have separated generic from context) - -local sequencers = utilities.sequencers -local appendgroup = sequencers.appendgroup -local appendaction = sequencers.appendaction -local mathprocessor = nil - -local mathactions = sequencers.reset { - arguments = "target,original,directives", -} - -function fonts.constructors.mathactions(original,target,directives) - if mathactions.dirty then -- maybe use autocompile - mathprocessor = sequencers.compile(mathactions) - end - mathprocessor(original,target,directives or {}) -end - -appendgroup(mathactions,"before") -- user -appendgroup(mathactions,"system") -- private -appendgroup(mathactions,"after" ) -- user - -function mathematics.initializeparameters(target,original,directives) - local mathparameters = original.mathparameters - if mathparameters and next(mathparameters) then - local _, mp = mathematics.dimensions(mathparameters) - target.mathparameters = mp -- for ourselves - target.MathConstants = mp -- for luatex - end -end - -sequencers.appendaction(mathactions,"system","mathematics.initializeparameters") - -local how = { - -- RadicalKernBeforeDegree = "horizontal", - -- RadicalKernAfterDegree = "horizontal", - RadicalDegreeBottomRaisePercent = "unscaled" -} - -function mathematics.scaleparameters(target,original,directives) - if not directives.disablescaling then - local mathparameters = target.mathparameters - if mathparameters and next(mathparameters) then - local parameters = target.parameters - local factor = parameters.factor - local hfactor = parameters.hfactor - local vfactor = parameters.vfactor - for name, value in next, mathparameters do - local h = how[name] - if h == "unscaled" then - mathparameters[name] = value - elseif h == "horizontal" then - mathparameters[name] = value * hfactor - elseif h == "vertical"then - mathparameters[name] = value * vfactor - else - mathparameters[name] = value * factor - end - end - end - end -end - -sequencers.appendaction(mathactions,"system","mathematics.scaleparameters") - -function mathematics.checkaccentbaseheight(target,original,directives) - local MathConstants = target.MathConstants - if MathConstants then - MathConstants.AccentBaseHeight = nil -- safeguard - end -end - -sequencers.appendaction(mathactions,"system","mathematics.checkaccentbaseheight") - -function mathematics.checkprivateparameters(target,original,directives) - local MathConstants = target.MathConstants - if MathConstants then - if not MathConstants.FractionDelimiterSize then - MathConstants.FractionDelimiterSize = 0 - end - if not MathConstants.FractionDelimiterDisplayStyleSize then - MathConstants.FractionDelimiterDisplayStyleSize = 0 - end - end -end - -sequencers.appendaction(mathactions,"system","mathematics.checkprivateparameters") - -function mathematics.overloadparameters(target,original,directives) - local mathparameters = target.mathparameters - if mathparameters and next(mathparameters) then - local goodies = target.goodies - if goodies then - for i=1,#goodies do - local goodie = goodies[i] - local mathematics = goodie.mathematics - local parameters = mathematics and mathematics.parameters - if parameters then - if trace_defining then - report_math("overloading math parameters in '%s' @ %s",target.properties.fullname,target.parameters.size) - end - for name, value in next, parameters do - local tvalue = type(value) - if tvalue == "string" then - report_math("comment for math parameter '%s': %s",name,value) - else - local oldvalue = mathparameters[name] - local newvalue = oldvalue - if oldvalue then - if tvalue == "number" then - newvalue = value - elseif tvalue == "function" then - newvalue = value(oldvalue,target,original) - elseif not tvalue then - newvalue = nil - end - if trace_defining and oldvalue ~= newvalue then - report_math("overloading math parameter '%s': %s => %s",name,tostring(oldvalue),tostring(newvalue)) - end - else - report_math("invalid math parameter '%s'",name) - end - mathparameters[name] = newvalue - end - end - end - end - end - end -end - -sequencers.appendaction(mathactions,"system","mathematics.overloadparameters") diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv index 43e091969..f778afa08 100644 --- a/tex/context/base/math-ini.mkiv +++ b/tex/context/base/math-ini.mkiv @@ -36,6 +36,7 @@ \registerctxluafile{math-ini}{1.001} \registerctxluafile{math-dim}{1.001} +\registerctxluafile{math-act}{1.001} \registerctxluafile{math-ent}{1.001} \registerctxluafile{math-ext}{1.001} \registerctxluafile{math-vfu}{1.001} diff --git a/tex/context/base/math-noa.lua b/tex/context/base/math-noa.lua index 8c9676ca4..57361fe04 100644 --- a/tex/context/base/math-noa.lua +++ b/tex/context/base/math-noa.lua @@ -149,7 +149,7 @@ local mathgreek = attributes.private("mathgreek") processors.relocate = { } local function report_remap(tag,id,old,new,extra) - report_remapping("remapping %s in font %s from U+%04X (%s) to U+%04X (%s)%s",tag,id,old,utfchar(old),new,utfchar(new),extra or "") + report_remapping("remapping %s in font %s from U+%05X (%s) to U+%05X (%s)%s",tag,id,old,utfchar(old),new,utfchar(new),extra or "") end local remapalphabets = mathematics.remapalphabets diff --git a/tex/context/base/math-vfu.lua b/tex/context/base/math-vfu.lua index b13f1804e..190a89c71 100644 --- a/tex/context/base/math-vfu.lua +++ b/tex/context/base/math-vfu.lua @@ -293,7 +293,7 @@ local function stack(main,characters,id,size,unicode,u1,d12,u2) end end -function vfmath.alas(main,id,size) +function vfmath.addmissing(main,id,size) local characters = main.characters local shared = main.shared local variables = main.goodies.mathematics and main.goodies.mathematics.variables or { } @@ -358,10 +358,6 @@ setmetatable ( reverse, { __index = function(t,name) return r end } ) -local mathdirectives = { - disablescaling = true -} - function vfmath.define(specification,set,goodies) local name = specification.name -- symbolic name local size = specification.size -- given size @@ -486,9 +482,9 @@ function vfmath.define(specification,set,goodies) -- -- we need to set some values in main as well (still?) -- - main.fullname = properties.fullname - main.type = "virtual" - main.nomath = false + main.fullname = properties.fullname + main.type = "virtual" + main.nomath = false -- parameters.x_height = parameters.x_height or 0 -- @@ -718,18 +714,19 @@ function vfmath.define(specification,set,goodies) size = size, } -- - if mathparameters then -- weak catch ? ? ? - vfmath.alas(main,#fontlist,size) - end - -- + main.mathparameters = mathparameters -- still traditional ones + vfmath.addmissing(main,#fontlist,size) mathematics.addfallbacks(main) -- + main.properties.math_is_scaled = true -- signal + fonts.constructors.assignmathparameters(main,main) + -- + main.MathConstants = main.mathparameters -- we directly pass it to TeX (bypasses the scaler) so this is needed + -- if trace_virtual or trace_timings then report_virtual("loading and virtualizing font %s at size %s took %0.3f seconds",name,size,os.clock()-start) end -- - fonts.constructors.mathactions(main,main,mathdirectives) - -- return main end diff --git a/tex/context/base/node-inj.lua b/tex/context/base/node-inj.lua index 80360b47b..6636e2f1a 100644 --- a/tex/context/base/node-inj.lua +++ b/tex/context/base/node-inj.lua @@ -109,7 +109,7 @@ function injections.setmark(start,base,factor,rlmode,ba,ma,index) --ba=baseancho set_attribute(start,markdone,index) return dx, dy, bound else - report_injections("possible problem, U+%04X is base mark without data (id: %s)",base.char,bound) + report_injections("possible problem, U+%05X is base mark without data (id: %s)",base.char,bound) end end index = index or 1 diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 9b377e8a1..8e121dcfb 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/generic/context/luatex-fonts-def.lua b/tex/generic/context/luatex-fonts-def.lua index 1d71bf5d5..0c2f0dbd5 100644 --- a/tex/generic/context/luatex-fonts-def.lua +++ b/tex/generic/context/luatex-fonts-def.lua @@ -81,7 +81,7 @@ end fonts.definers.registersplit(":",colonized,"cryptic") fonts.definers.registersplit("", colonized,"more cryptic") -- catches \font\text=[names] -function definers.applypostprocessors(tfmdata) +function fonts.definers.applypostprocessors(tfmdata) local postprocessors = tfmdata.postprocessors if postprocessors then for i=1,#postprocessors do diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index dbd25af37..0f0437f53 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 03/26/11 12:41:29 +-- merge date : 03/27/11 14:17:54 do -- begin closure to overcome local limits and interference @@ -2913,7 +2913,6 @@ local contextnumbers = specifiers.contextnumbers -- will be directives -constructors.sharebasekerns = false -- true (.5 sec slower on mk but brings down mem from 410M to 310M, beware: then script/lang share too) constructors.dontembed = allocate() constructors.mathactions = { } constructors.autocleanup = true @@ -2971,47 +2970,6 @@ in the process; numbers are of course copies. Here 65536 equals 1pt. (Due to excessive memory usage in CJK fonts, we no longer pass the boundingbox.)

--ldx]]-- --- the following hack costs a bit of runtime but safes memory --- --- basekerns are scaled and will be hashed by table id --- sharedkerns are unscaled and are be hashed by concatenated indexes - ---~ function constructors.check_base_kerns(tfmdata) ---~ if constructors.sharebasekerns then ---~ local sharedkerns = tfmdata.sharedkerns ---~ if sharedkerns then ---~ local basekerns = { } ---~ tfmdata.basekerns = basekerns ---~ return sharedkerns, basekerns ---~ end ---~ end ---~ return nil, nil ---~ end - ---~ function constructors.prepare_base_kerns(tfmdata) ---~ if constructors.sharebasekerns and not tfmdata.sharedkerns then ---~ local sharedkerns = { } ---~ tfmdata.sharedkerns = sharedkerns ---~ for u, chr in next, tfmdata.characters do ---~ local kerns = chr.kerns ---~ if kerns then ---~ local hash = concat(sortedkeys(kerns), " ") ---~ local base = sharedkerns[hash] ---~ if not base then ---~ sharedkerns[hash] = kerns ---~ else ---~ chr.kerns = base ---~ end ---~ end ---~ end ---~ end ---~ end - --- we can cache scaled characters when we are in node mode and don't have --- protruding and expansion: hash == fullname @ size @ protruding @ expansion --- but in practice (except from mk) the otf hash will be enough already so it --- makes no sense to mess up the code now - -- The scaler is only used for otf and afm and virtual fonts. If -- a virtual font has italic correction make sure to set the -- italic_correction flag. Some more flags will be added in @@ -3060,6 +3018,34 @@ function constructors.calculatescale(tfmdata,scaledpoints) return scaledpoints, scaledpoints / (parameters.units or 1000) -- delta end +function constructors.assignmathparameters(target,tfmdata) + -- when a tfm file is loaded, it has already been scaled + -- and it never enters the scaled so this is otf only + local mathparameters = original.mathparameters + if mathparameters and next(mathparameters) then + local targetparameters = target.parameters + local targetmathparameters = { } + local factor = targetparameters.factor + for name, value in next, mathparameters do + if name == "RadicalDegreeBottomRaisePercent" then + targetmathparameters[name] = value + else + targetmathparameters[name] = value * factor + end + end + if not targetmathparameters.AccentBaseHeight then + targetmathparameters.AccentBaseHeight = nil -- safeguard, still needed? + end + if not targetmathparameters.FractionDelimiterSize then + targetmathparameters.FractionDelimiterSize = 0 + end + if not mathparameters.FractionDelimiterDisplayStyleSize then + targetmathparameters.FractionDelimiterDisplayStyleSize = 0 + end + target.mathparameters = targetmathparameters + end +end + function constructors.scale(tfmdata,specification) local target = { } -- the new table -- @@ -3079,23 +3065,22 @@ function constructors.scale(tfmdata,specification) local shared = tfmdata.shared or { } local parameters = tfmdata.parameters or { } local mathparameters = tfmdata.mathparameters or { } - local MathConstants = tfmdata.mathconstants or { } -- local targetcharacters = { } local targetdescriptions = table.derive(descriptions) local targetparameters = table.derive(parameters) - local targetmathparameters = table.derive(mathparameters) + -- local targetmathparameters = table.fastcopy(mathparameters) -- happens elsewhere local targetproperties = table.derive(properties) - local targetgoodies = table.derive(goodies) + local targetgoodies = goodies -- we need to loop so no metatable target.characters = targetcharacters target.descriptions = targetdescriptions target.parameters = targetparameters - target.mathparameters = targetmathparameters + -- target.mathparameters = targetmathparameters -- happens elsewhere target.properties = targetproperties target.goodies = targetgoodies target.shared = shared target.resources = resources - target.unscaled = tfmdata -- the original unscaled one (temp) + target.unscaled = tfmdata -- the original unscaled one -- -- specification.mathsize : 1=text 2=script 3=scriptscript -- specification.textsize : natural (text)size @@ -3205,9 +3190,9 @@ function constructors.scale(tfmdata,specification) target.slant = 0 end -- + targetparameters.factor = delta targetparameters.hfactor = hdelta targetparameters.vfactor = vdelta - targetparameters.factor = delta targetparameters.size = scaledpoints targetparameters.units = units targetparameters.scaledpoints = askedscaledpoints @@ -3224,18 +3209,6 @@ function constructors.scale(tfmdata,specification) end -- target.type = isvirtual and "virtual" or "real" - -- more extensive test - local hasmath = (properties.math or next(mathparameters) or next(MathConstants)) and true - if hasmath then - properties.has_math = true - target.nomath = false - target.MathConstants = MathConstants - target.mathconstants = MathConstants - else - properties.has_math = false - target.nomath = true - target.mathparameters = nil -- nop - end -- this will move to some subtable so that it is copied at once target.postprocessors = tfmdata.postprocessors -- @@ -3263,45 +3236,37 @@ function constructors.scale(tfmdata,specification) if descender then targetparameters.descender = delta * descender end + -- copies, might disappear + targetparameters.xheight = targetparameters.xheight or parameters.x_height + targetparameters.extraspace = targetparameters.extraspace or parameters.extra_space + targetparameters.spacestretch = targetparameters.spacestretch or parameters.space_stretch + targetparameters.spaceshrink = targetparameters.spaceshrink or parameters.space_shrink + -- + local protrusionfactor = (targetquad ~= 0 and 1000/targetquad) or 0 + local scaledwidth = defaultwidth * hdelta + local scaledheight = defaultheight * vdelta + local scaleddepth = defaultdepth * vdelta -- + local hasmath = (properties.has_math or next(mathparameters)) and true if hasmath then - local ma = constructors.mathactions - local ta = type(ma) - if ta == "function" then -- context - ma(target,tfmdata) - elseif ta == "table" then -- generic (we keep the deltas) - for i=1,#ma do - ma[i](target,tfmdata,delta,hdelta,vdelta) - end - end - if not targetparameters[13] then targetparameters[13] = .86*targetx_height end -- mathsupdisplay - if not targetparameters[14] then targetparameters[14] = .86*targetx_height end -- mathsupnormal - if not targetparameters[15] then targetparameters[15] = .86*targetx_height end -- mathsupcramped - if not targetparameters[16] then targetparameters[16] = .48*targetx_height end -- mathsubnormal - if not targetparameters[17] then targetparameters[17] = .48*targetx_height end -- mathsubcombined - if not targetparameters[22] then targetparameters[22] = 0 end -- mathaxisheight - if target.MathConstants then target.MathConstants.AccentBaseHeight = nil end -- safeguard if trace_defining then report_defining("math enabled for: name '%s', fullname: '%s', filename: '%s'", name or "noname",fullname or "nofullname",filename or "nofilename") end + constructors.assignmathparameters(target,tfmdata) -- does scaling and whatever is needed + properties.has_math = true + target.nomath = false + target.MathConstants = target.mathparameters else if trace_defining then report_defining("math disabled for: name '%s', fullname: '%s', filename: '%s'", name or "noname",fullname or "nofullname",filename or "nofilename") end + properties.has_math = false + target.nomath = true + target.mathparameters = nil -- nop end -- - targetparameters.xheight = targetparameters.xheight or parameters.x_height - targetparameters.extraspace = targetparameters.extraspace or parameters.extra_space - targetparameters.spacestretch = targetparameters.spacestretch or parameters.space_stretch - targetparameters.spaceshrink = targetparameters.spaceshrink or parameters.space_shrink - -- - local protrusionfactor = (targetquad ~= 0 and 1000/targetquad) or 0 - local scaledwidth = defaultwidth * hdelta - local scaledheight = defaultheight * vdelta - local scaleddepth = defaultdepth * vdelta - -- local sharedkerns = { } -- for unicode, character in next, characters do @@ -3400,7 +3365,7 @@ function constructors.scale(tfmdata,specification) if vn then chr.next = vn -- if character.vert_variants or character.horiz_variants then - -- report_defining("glyph 0x%05X has combination of next, vert_variants and horiz_variants",index) + -- report_defining("glyph U+%05X has combination of next, vert_variants and horiz_variants",index) -- end else local vv = character.vert_variants @@ -3462,19 +3427,6 @@ function constructors.scale(tfmdata,specification) if not nodemode then local vk = character.kerns if vk then - -- if sharedkerns then - -- local base = basekerns[vk] -- hashed by table id, not content - -- if not base then - -- base = {} - -- for k,v in next, vk do base[k] = v*hdelta end - -- basekerns[vk] = base - -- end - -- chr.kerns = base - -- else - -- local tt = {} - -- for k,v in next, vk do tt[k] = v*hdelta end - -- chr.kerns = tt - -- end local s = sharedkerns[vk] if not s then s = { } @@ -3631,7 +3583,6 @@ function constructors.finalize(tfmdata) -- -- tfmdata.fonts -- tfmdata.unscaled - -- tfmdata.mathconstants -- if not properties.has_math then properties.has_math = not tfmdata.nomath @@ -4534,9 +4485,9 @@ function mappings.addtounicode(data,filename) local index = glyph.index local toun = tounicode[index] if toun then - report_fonts("internal: 0x%05X, name: %s, unicode: 0x%05X, tounicode: %s",index,name,unic,toun) + report_fonts("internal: 0x%05X, name: %s, unicode: U+%05X, tounicode: %s",index,name,unic,toun) else - report_fonts("internal: 0x%05X, name: %s, unicode: 0x%05X",index,name,unic) + report_fonts("internal: 0x%05X, name: %s, unicode: U+%05X",index,name,unic) end end end @@ -5404,7 +5355,7 @@ actions["prepare glyphs"] = function(data,filename,raw) unicode = private unicodes[name] = private if trace_private then - report_otf("enhance: glyph %s at index U+%04X is moved to private unicode slot U+%04X",name,index,private) + report_otf("enhance: glyph %s at index 0x%04X is moved to private unicode slot U+%05X",name,index,private) end private = private + 1 nofnames = nofnames + 1 @@ -5451,7 +5402,7 @@ actions["prepare glyphs"] = function(data,filename,raw) unicode = private unicodes[name] = private if trace_private then - report_otf("enhance: glyph %s at index U+%04X is moved to private unicode slot U+%04X",name,index,private) + report_otf("enhance: glyph %s at index 0x%04X is moved to private unicode slot U+%05X",name,index,private) end private = private + 1 else @@ -5509,7 +5460,7 @@ actions["prepare unicodes"] = function(data,filename,raw) local description = descriptions[parent] if description then local c = fastcopy(description) - c.comment = format("copy of 0x%04X", parent) + c.comment = format("copy of U+%05X", parent) descriptions[unicode] = c local name = c.name if not unicodes[name] then @@ -5519,7 +5470,7 @@ actions["prepare unicodes"] = function(data,filename,raw) multiples[nofmultiples] = name -- we can save duplicates if needed else -- make it a notdef - report_otf("weird unicode 0x%04X at index 0x%04X",unicode,index) + report_otf("weird unicode U+%05X at index 0x%04X",unicode,index) end end end @@ -6073,7 +6024,7 @@ actions["reorganize glyph kerns"] = function(data,filename,raw) end end elseif trace_loading then - report_otf("problems with unicode %s of kern %s of glyph 0x%04X",name,k,unicode) + report_otf("problems with unicode %s of kern %s of glyph U+%05X",name,k,unicode) end end end @@ -6158,7 +6109,7 @@ actions["merge kern classes"] = function(data,filename,raw) lookupkerns[second_unicode] = kern end elseif trace_loading then - report_otf("no glyph data for U+%04X", first_unicode) + report_otf("no glyph data for U+%05X", first_unicode) end end end @@ -6719,15 +6670,15 @@ local function gref(descriptions,n) if type(n) == "number" then local name = descriptions[n].name if name then - return format("U+%04X (%s)",n,name) + return format("U+%05X (%s)",n,name) else - return format("U+%04X") + return format("U+%05X") end elseif n then local num, nam = { }, { } for i=2,#n do -- first is likely a key local ni = n[i] - num[i] = format("U+%04X",ni) + num[i] = format("U+%05X",ni) nam[i] = descriptions[ni].name or "?" end return format("%s (%s)",concat(num," "), concat(nam," ")) @@ -7059,7 +7010,7 @@ local function make_2(present,tfmdata,characters,tree,name,preceding,unicode,don local character = characters[preceding] if not character then if trace_baseinit then - report_prepare("weird ligature in lookup %s: 0x%04X (%s), preceding 0x%04X (%s)",lookupname,v,utfchar(v),preceding,utfchar(preceding)) + report_prepare("weird ligature in lookup %s: U+%05X (%s), preceding U+%05X (%s)",lookupname,v,utfchar(v),preceding,utfchar(preceding)) end character = makefake(tfmdata,name,present) end @@ -7380,7 +7331,7 @@ function injections.setmark(start,base,factor,rlmode,ba,ma,index) --ba=baseancho set_attribute(start,markdone,index) return dx, dy, bound else - report_injections("possible problem, U+%04X is base mark without data (id: %s)",base.char,bound) + report_injections("possible problem, U+%05X is base mark without data (id: %s)",base.char,bound) end end index = index or 1 @@ -10468,7 +10419,7 @@ local arab_warned = { } local function warning(current,what) local char = current.char if not arab_warned[char] then - log.report("analyze","arab: character %s (U+%04X) has no %s class", char, char, what) + log.report("analyze","arab: character %s (U+%05X) has no %s class", char, char, what) arab_warned[char] = true end end @@ -11141,7 +11092,7 @@ end fonts.definers.registersplit(":",colonized,"cryptic") fonts.definers.registersplit("", colonized,"more cryptic") -- catches \font\text=[names] -function definers.applypostprocessors(tfmdata) +function fonts.definers.applypostprocessors(tfmdata) local postprocessors = tfmdata.postprocessors if postprocessors then for i=1,#postprocessors do -- cgit v1.2.3