diff options
Diffstat (limited to 'tex/context/base/mkxl')
22 files changed, 729 insertions, 594 deletions
diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index bb6268f4a..2950090ea 100644 --- a/tex/context/base/mkxl/cont-new.mkxl +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2022.10.15 10:32} +\newcontextversion{2022.10.21 21:11} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl index c322164c3..c5baad13d 100644 --- a/tex/context/base/mkxl/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \immutable\edef\contextformat {\jobname} -\immutable\edef\contextversion{2022.10.15 10:32} +\immutable\edef\contextversion{2022.10.21 21:11} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/driv-ini.lmt b/tex/context/base/mkxl/driv-ini.lmt index 8b6c2e5ff..c43bf2a83 100644 --- a/tex/context/base/mkxl/driv-ini.lmt +++ b/tex/context/base/mkxl/driv-ini.lmt @@ -30,6 +30,8 @@ local shipout = tex.shipout local texgetbox = tex.getbox local texgetcount = tex.getcount +local c_realpageno = tex.iscount("realpageno") + function converters.engine(driver,boxnumber,mode,number,specification) return shipout(boxnumber) end @@ -204,7 +206,7 @@ function drivers.convert(boxnumber) if currentinstance then callbacks.functions.start_page_number() starttiming(drivers) - convert(currentinstance,boxnumber,texgetcount("realpageno")) + convert(currentinstance,boxnumber,texgetcount(c_realpageno)) stoptiming(drivers) callbacks.functions.stop_page_number() end diff --git a/tex/context/base/mkxl/font-col.mklx b/tex/context/base/mkxl/font-col.mklx index 0e2f302b2..bd099bbe9 100644 --- a/tex/context/base/mkxl/font-col.mklx +++ b/tex/context/base/mkxl/font-col.mklx @@ -95,18 +95,18 @@ % math (experiment, todo clf_) -\def\font_fallbacks_register_math#1#2#3#4% - {\doifelsenothing{#3}% - {\definedfont[#2 at #4\scaledpoint]}% - {\definedfont[#2*#3\space at #4\scaledpoint]}% - \clf_registerfontfallbackid#1\space\fontid\font\space{#2}} - % \def\font_fallbacks_register_math#1#2#3#4% -% {\definedfont[#2\iftok{#3}\emptytoks\else*#3 \fi at #4\scaledpoint]% +% {\doifelsenothing{#3}% +% {\definedfont[#2 at #4\scaledpoint]}% +% {\definedfont[#2*#3\space at #4\scaledpoint]}% % \clf_registerfontfallbackid#1\space\fontid\font\space{#2}} -% \def\font_fallbacks_finish_math -% {\ctxlua{mathematics.finishfallbacks()}} +% % % \def\font_fallbacks_register_math#1#2#3#4% +% % % {\definedfont[#2\iftok{#3}\emptytoks\else*#3 \fi at #4\scaledpoint]% +% % % \clf_registerfontfallbackid#1\space\fontid\font\space{#2}} +% % % +% % % \def\font_fallbacks_finish_math +% % % {\ctxlua{mathematics.finishfallbacks()}} % check : only replace when present in replacement font (default: no) % force : force replacent even when basefont has glyph (default: yes) diff --git a/tex/context/base/mkxl/font-con.lmt b/tex/context/base/mkxl/font-con.lmt index 319d5fe48..2e32193e9 100644 --- a/tex/context/base/mkxl/font-con.lmt +++ b/tex/context/base/mkxl/font-con.lmt @@ -445,7 +445,7 @@ function constructors.scale(tfmdata,specification) local hasquality = parameters.expansion or parameters.protrusion local hasitalics = properties.hasitalics local autoitalicamount = properties.autoitalicamount - local stackmath = not properties.nostackmath + -- local stackmath = not properties.nostackmath local haskerns = properties.haskerns or properties.mode == "base" -- we can have afm in node mode local hasligatures = properties.hasligatures or properties.mode == "base" -- we can have afm in node mode local realdimensions = properties.realdimensions @@ -720,7 +720,8 @@ function constructors.scale(tfmdata,specification) -- if vo then -- chr.bottomovershoot = vo*hdelta -- end - if stackmath then -- not ok yet + -- + -- if stackmath then -- not ok yet local mk = character.mathkerns if mk then local tr = mk.topright @@ -734,7 +735,8 @@ function constructors.scale(tfmdata,specification) bottomleft = bl and mathkerns(bl,vdelta) or nil, } end - end + -- end + -- if hasitalics then local vi = character.italic if vi and vi ~= 0 then diff --git a/tex/context/base/mkxl/font-ctx.lmt b/tex/context/base/mkxl/font-ctx.lmt index 75572e089..83c0a912b 100644 --- a/tex/context/base/mkxl/font-ctx.lmt +++ b/tex/context/base/mkxl/font-ctx.lmt @@ -90,6 +90,7 @@ local setsubtype = nuts.setsubtype local texgetdimen = tex.getdimen local texsetcount = tex.setcount +local texiscount = tex.iscount local texget = tex.get local texdefinefont = tex.definefont @@ -1119,12 +1120,16 @@ local specifiers = { } do -- else too many locals - local starttiming = statistics.starttiming - local stoptiming = statistics.stoptiming + local starttiming = statistics.starttiming + local stoptiming = statistics.stoptiming - local setmacro = tokens.setters.macro - local ctxcatcodes = tex.ctxcatcodes - local texconditionals = tex.conditionals + local setmacro = tokens.setters.macro + local ctxcatcodes = tex.ctxcatcodes + local texconditionals = tex.conditionals + + local c_scaledfontmode = texiscount("scaledfontmode") + local c_scaledfontsize = texiscount("scaledfontsize") + local c_lastfontid = texiscount("lastfontid") local reported = setmetatableindex(function(t,k) local v = setmetatableindex(function(t,k) @@ -1166,7 +1171,7 @@ do -- else too many locals local mode, fontsize, sx, sy = lpegmatch(sizepattern,size) -- print(size,mode,fontsize,sx,sy) if mode and fontsize and fontsize ~= "" then - texsetcount("scaledfontmode",mode) + texsetcount(c_scaledfontmode,mode) -- ctx_setsomefontsize(fontsize) -- We use a catcodetable, just in case it's 1.2\exheight (a corner case that showed -- up in the lmtx manual: marking that changed size in the mids of some verbatim). @@ -1178,15 +1183,15 @@ do -- else too many locals setmacro("somefontsizey",sy) end else - texsetcount("scaledfontmode",0) + texsetcount(c_scaledfontmode,0) -- ctx_setemptyfontsize() end elseif true then -- so we don't need to check in tex - texsetcount("scaledfontmode",2) + texsetcount(c_scaledfontmode,2) -- ctx_setemptyfontsize() else - texsetcount("scaledfontmode",0) + texsetcount(c_scaledfontmode,0) -- ctx_setemptyfontsize() end specification = definers.makespecification(str,lookup,name,sub,method,detail,size) @@ -1374,99 +1379,36 @@ do -- else too many locals local properties = tfmdata.properties -- we use char0 as signal; cf the spec pdf can handle this (no char in slot) characters[0] = nil - -- characters[0x00A0] = { width = parameters.space } - -- characters[0x2007] = { width = characters[0x0030] and characters[0x0030].width or parameters.space } -- figure - -- characters[0x2008] = { width = characters[0x002E] and characters[0x002E].width or parameters.space } -- period - -- - local fallbacks = specification.fallbacks or "" - local mathsize = (mathsize == 1 or mathsize == 2 or mathsize == 3) and mathsize or nil -- can be unset so we test 1 2 3 - if fallbacks ~= "" and mathsize and not busy then - busy = true - -- We need this ugly hack in order to resolve fontnames (at the \TEX end). Originally - -- math was done in Lua after loading (plugged into aftercopying). - -- - -- After tl 2017 I'll also do text fallbacks this way (although backups there are done - -- in a completely different way.) - if trace_defining then - report_defining("defining %a, id %a, target %a, features %a / %a, fallbacks %a / %a, step %a", - name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,1) - end - mathematics.resolvefallbacks(tfmdata,specification,fallbacks) - context(function() - -- We're doing math fallbacks. - busy = false - mathematics.finishfallbacks(tfmdata,specification,fallbacks) - tfmdata.original = specification.specification - constructors.beforepassingfonttotex(tfmdata) - local id = definefont(tfmdata,properties.id) - csnames[id] = specification.cs - properties.id = id -- already set - definers.register(tfmdata,id) -- to be sure, normally already done - texdefinefont(global,cs,id) - -- texdefinefont(cs,id,global and "global") - constructors.finalize(tfmdata) - if trace_defining then - report_defining("defining %a, id %a, target %a, features %a / %a, fallbacks %a / %a, step %a", - name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,2) - end - -- resolved (when designsize is used): - local size = round(tfmdata.parameters.size or 655360) - setmacro("somefontsize",size.."sp") - -- ctx_setsomefontsize(size .. "sp") - texsetcount("scaledfontsize",size) - lastfontid = id - -- - if trace_defining then - report_defining("memory usage after: %s",statistics.memused()) - report_defining("stop stage two") - end - -- - texsetcount("global","lastfontid",lastfontid) - specifiers[lastfontid] = { str, size } - if not mathsize then - -- forget about it (can't happen here) - elseif mathsize == 0 then - -- can't happen (here) - else - -- maybe only 1 2 3 (we already test for this) - lastmathids[mathsize] = lastfontid - end - stoptiming(fonts) - end) - return - else - tfmdata.original = specification.specification - local id = definefont(tfmdata,properties.id) - csnames[id] = specification.cs - properties.id = id -- already set - definers.register(tfmdata,id) -- to be sure, normally already done - texdefinefont(global,cs,id) - -- texdefinefont(cs,id,global and "global") - constructors.finalize(tfmdata) - if trace_defining then - report_defining("defining %a, id %a, target %a, features %a / %a, fallbacks %a / %a, step %a", - name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,"-") - end - -- resolved (when designsize is used): - local size = round(tfmdata.parameters.size or 655360) - setmacro("somefontsize",size.."sp") - -- ctx_setsomefontsize(size .. "sp") - texsetcount("scaledfontsize",size) - lastfontid = id + tfmdata.original = specification.specification + local id = definefont(tfmdata,properties.id) + csnames[id] = specification.cs + properties.id = id -- already set + definers.register(tfmdata,id) -- to be sure, normally already done + texdefinefont(global,cs,id) + -- texdefinefont(cs,id,global and "global") + constructors.finalize(tfmdata) + if trace_defining then + report_defining("defining %a, id %a, target %a, features %a / %a, fallbacks %a / %a, step %a", + name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,"-") end + -- resolved (when designsize is used): + local size = round(tfmdata.parameters.size or 655360) + setmacro("somefontsize",size.."sp") + texsetcount(c_scaledfontsize,size) + lastfontid = id elseif tfmtype == "number" then if trace_defining then report_defining("reusing %s, id %a, target %a, features %a / %a, fallbacks %a / %a, goodies %a / %a, designsize %a / %a", name,tfmdata,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,classgoodies,goodies,classdesignsize,fontdesignsize) end csnames[tfmdata] = specification.cs +-- \definedfont ends up here texdefinefont(global,cs,tfmdata) -- texdefinefont(cs,tfmdata,global and "global") -- resolved (when designsize is used): local size = round(fontdata[tfmdata].parameters.size or 0) - -- ctx_setsomefontsize(size .. "sp") setmacro("somefontsize",size.."sp") - texsetcount("scaledfontsize",size) + texsetcount(c_scaledfontsize,size) lastfontid = tfmdata else local nice = nice_cs(cs) @@ -1474,7 +1416,7 @@ do -- else too many locals report_defining("unable to define %a as %a",name,nice) end lastfontid = -1 - texsetcount("scaledfontsize",0) + texsetcount(c_scaledfontsize,0) -- ctx_letvaluerelax(cs) -- otherwise the current definition takes the previous one end if trace_defining then @@ -1482,7 +1424,7 @@ do -- else too many locals report_defining("stop stage two") end -- - texsetcount("global","lastfontid",lastfontid) + texsetcount("global",c_lastfontid,lastfontid) specifiers[lastfontid] = { str, size } if not mathsize then -- forget about it @@ -1606,6 +1548,8 @@ do -- else too many locals local n = 0 + local d_bodyfontsize = tex.isdimen("bodyfontsize") + function definers.internal(specification,cs) specification = specification or { } local name = specification.name @@ -1613,7 +1557,7 @@ do -- else too many locals local number = tonumber(specification.number) local id = nil if not size then - size = texgetdimen("bodyfontsize") + size = texgetdimen(d_bodyfontsize) end if number then id = number @@ -1670,6 +1614,8 @@ end -- have delayed definitions and so we never know what style is taken -- as start. +local c_font_scaled_points = texiscount("c_font_scaled_points") + function constructors.calculatescale(tfmdata,scaledpoints,relativeid,specification) local parameters = tfmdata.parameters local units = parameters.units or 1000 @@ -1691,7 +1637,7 @@ function constructors.calculatescale(tfmdata,scaledpoints,relativeid,specificati -- a temp hack till we have upgraded all mechanisms local delta = round(scaledpoints/units) local size = round(scaledpoints) - texsetcount("c_font_scaled_points",size) + texsetcount(c_font_scaled_points,size) -- return size, delta end diff --git a/tex/context/base/mkxl/font-imp-math.lmt b/tex/context/base/mkxl/font-imp-math.lmt index 04fe5c04c..bd445caea 100644 --- a/tex/context/base/mkxl/font-imp-math.lmt +++ b/tex/context/base/mkxl/font-imp-math.lmt @@ -20,56 +20,55 @@ local texconditionals = tex.conditionals -- tfmdata.properties.mathnolimitsmode = tonumber(value) or 0 -local splitter = lpeg.splitat(",",tonumber) -local lpegmatch = lpeg.match - -local function initialize(tfmdata,value) - local mathparameters = tfmdata.mathparameters - if mathparameters then - local sup, sub - if type(value) == "string" then - sup, sub = lpegmatch(splitter,value) -- settings_to_array - if not sup then - sub, sup = 0, 0 - elseif not sub then - sub, sup = sup, 0 - end - elseif type(value) == "number" then - sup, sub = 0, value - end - if sup then - mathparameters.NoLimitSupFactor = sup - end - if sub then - mathparameters.NoLimitSubFactor = sub - end - end -end - -registerotffeature { - name = "mathnolimitsmode", - description = "influence nolimits placement", - initializers = { - base = initialize, - node = initialize, - } -} - - --- this will become a mode in the engine - -local function initialize(tfmdata,value) - tfmdata.properties.nostackmath = value and true -end +-- local splitter = lpeg.splitat(",",tonumber) +-- local lpegmatch = lpeg.match +-- +-- local function initialize(tfmdata,value) +-- local mathparameters = tfmdata.mathparameters +-- if mathparameters then +-- local sup, sub +-- if type(value) == "string" then +-- sup, sub = lpegmatch(splitter,value) -- settings_to_array +-- if not sup then +-- sub, sup = 0, 0 +-- elseif not sub then +-- sub, sup = sup, 0 +-- end +-- elseif type(value) == "number" then +-- sup, sub = 0, value +-- end +-- if sup then +-- mathparameters.NoLimitSupFactor = sup +-- end +-- if sub then +-- mathparameters.NoLimitSubFactor = sub +-- end +-- end +-- end +-- +-- registerotffeature { +-- name = "mathnolimitsmode", +-- description = "influence nolimits placement", +-- initializers = { +-- base = initialize, +-- node = initialize, +-- } +-- } -registerotffeature { - name = "nostackmath", - description = "disable math stacking mechanism", - initializers = { - base = initialize, - node = initialize, - } -} +-- this will become a mode in the engine -- done +-- +-- local function initialize(tfmdata,value) +-- tfmdata.properties.nostackmath = value and true +-- end +-- +-- registerotffeature { +-- name = "nostackmath", +-- description = "disable math stacking mechanism", +-- initializers = { +-- base = initialize, +-- node = initialize, +-- } +-- } -- A quick and dirty and low level implementation but okay for testing: diff --git a/tex/context/base/mkxl/font-ini.mklx b/tex/context/base/mkxl/font-ini.mklx index 67663b7db..1fab52386 100644 --- a/tex/context/base/mkxl/font-ini.mklx +++ b/tex/context/base/mkxl/font-ini.mklx @@ -667,9 +667,10 @@ \mutable\let\somefontsizex\empty \mutable\let\somefontsizey\empty -\newcount\scaledfontmode % also used at the lua end -\newcount\scaledfontsize % also used at the lua end -\newcount\lastfontid % also used at the lua end / tex end +% \newcount\scaledfontmode % font-lib.mklx +% \newcount\scaledfontsize % font-lib.mklx +% \newcount\lastfontid % font-lib.mklx + \newtoks \everydefinefont \aliased\let\c_font_feature_inheritance_fontnone \zerocount % none @@ -692,13 +693,11 @@ \immutable\dimensiondef\d_font_scaled_default 10pt -\newcount\c_font_future_glyph_scale - % todo: move all to lua: use localcall for resolving filename -\newcount\c_font_future_glyph_scale -\newcount\c_font_scaled_font_mode_saved -\newcount\c_font_scaled_points +% \newcount\c_font_future_glyph_scale % font-lib.mklx +% \newcount\c_font_scaled_font_mode_saved % font-lib.mklx +% \newcount\c_font_scaled_points % font-lib.mklx \mutable\let\somefontspec \empty \mutable\let\lastrawfontcall \relax @@ -1218,7 +1217,7 @@ \ifcsname\??fontenvironments \s!default\s!text \endcsname\lastnamedcs\else \csname\??fontenvironments \s!default \endcsname \fi} -\setvalue{\??fontenvironments\s!default}{1} +\defcsname\??fontenvironments\s!default\endcsname{1} %D In the following macros we use \type {\currentxfontsize} to hold the current %D x||size of the font. This enables us to support for instance \type {\sl} inside a @@ -1313,10 +1312,10 @@ % todo: class:size % todo: make assignments global -\letvalue\??fontenvironments\empty % so we default to empty +\letcsname\??fontenvironments\endcsname\empty % so we default to empty \permanent\def\bodyfontvariable#parameter% - {\csname\??fontenvironments + {\begincsname\??fontenvironments \ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname\fontclass\normalizedbodyfontsize#parameter\orelse \ifcsname\??fontenvironments\fontclass #parameter\endcsname\fontclass #parameter\orelse \ifcsname\??fontenvironments \normalizedbodyfontsize#parameter\endcsname \normalizedbodyfontsize#parameter\orelse @@ -1329,13 +1328,20 @@ \ifcsname\??fontenvironments \normalizedbodyfontsize#parameter\endcsname\lastnamedcs\orelse \ifcsname\??fontenvironments\s!default #parameter\endcsname\lastnamedcs\fi} -\permanent\def\bodyfontsizevariable#size#parameter% - {\csname\??fontenvironments - \ifcsname\??fontenvironments\fontclass#size#parameter\endcsname\fontclass#size#parameter\orelse - \ifcsname\??fontenvironments\fontclass #parameter\endcsname\fontclass #parameter\orelse - \ifcsname\??fontenvironments #size#parameter\endcsname #size#parameter\orelse - \ifcsname\??fontenvironments\s!default #parameter\endcsname\s!default #parameter\fi - \endcsname} +% \permanent\def\bodyfontsizevariable#size#parameter% +% {\begincsname\??fontenvironments +% \ifcsname\??fontenvironments\fontclass#size#parameter\endcsname\fontclass#size#parameter\orelse +% \ifcsname\??fontenvironments\fontclass #parameter\endcsname\fontclass #parameter\orelse +% \ifcsname\??fontenvironments #size#parameter\endcsname #size#parameter\orelse +% \ifcsname\??fontenvironments\s!default #parameter\endcsname\s!default #parameter\fi +% \endcsname} + +\def\font_bodyfontvariable#parameter% + {\ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname\lastnamedcs\orelse + \ifcsname\??fontenvironments\fontclass #parameter\endcsname\lastnamedcs\orelse + \ifcsname\??fontenvironments\v!all \normalizedbodyfontsize#parameter\endcsname\lastnamedcs\orelse + \ifcsname\??fontenvironments \normalizedbodyfontsize#parameter\endcsname\lastnamedcs\orelse + \ifcsname\??fontenvironments\s!default #parameter\endcsname\lastnamedcs\fi} \def\font_bodyfontsizevariable#size#parameter% {\ifcsname\??fontenvironments\fontclass#size#parameter\endcsname\lastnamedcs\orelse @@ -2387,6 +2393,28 @@ }% \gletcsname\??fontbodyfaces\fontbody\endcsname\font_basics_set_faces} +% \permanent\def\currentbodyfontdimension#parameter% there can be factors here +% {\the\dimexpr +% \ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname +% \lastnamedcs +% \orelse\ifcsname\??fontenvironments\fontclass\s!default#parameter\endcsname +% \lastnamedcs +% \dimexpr\normalizedbodyfontsize\relax +% \orelse\ifcsname\??fontenvironments\normalizedbodyfontsize#parameter\endcsname +% \lastnamedcs +% \else +% \csname\??fontenvironments\s!default#parameter\endcsname +% \dimexpr\normalizedbodyfontsize\relax +% \fi +% \relax} + +% \setupbodyfontenvironment [all] [12pt] [x=4pt,small=4pt] +% \setupbodyfontenvironment [pagella] [12pt] [x=4pt,small=4pt] +% +% \setupbodyfont[pagella,12pt] +% +% \starttext normal {\tx tx} {\small small} \stoptext + \permanent\def\currentbodyfontdimension#parameter% there can be factors here {\the\dimexpr \ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname @@ -2394,6 +2422,8 @@ \orelse\ifcsname\??fontenvironments\fontclass\s!default#parameter\endcsname \lastnamedcs \dimexpr\normalizedbodyfontsize\relax + \orelse\ifcsname\??fontenvironments\v!all\normalizedbodyfontsize#parameter\endcsname + \lastnamedcs \orelse\ifcsname\??fontenvironments\normalizedbodyfontsize#parameter\endcsname \lastnamedcs \else diff --git a/tex/context/base/mkxl/font-lib.mklx b/tex/context/base/mkxl/font-lib.mklx index f7342c7d4..05367dae8 100644 --- a/tex/context/base/mkxl/font-lib.mklx +++ b/tex/context/base/mkxl/font-lib.mklx @@ -15,6 +15,18 @@ \unprotect +\newcount\scaledfontmode +\newcount\scaledfontsize +\newcount\lastfontid + +\newcount\c_font_future_glyph_scale +\newcount\c_font_scaled_font_mode_saved +\newcount\c_font_scaled_points + +\ifdefined\globalbodyfontsize \else \newdimen\globalbodyfontsize \fi +\ifdefined\localbodyfontsize \else \newdimen\localbodyfontsize \fi +\ifdefined\bodyfontsize \else \newdimen\bodyfontsize \fi + \registerctxluafile{font-ini}{autosuffix} \registerctxluafile{font-log}{} \registerctxluafile{font-con}{autosuffix} % kind of early diff --git a/tex/context/base/mkxl/font-pre.mkxl b/tex/context/base/mkxl/font-pre.mkxl index 8cb0b5b6c..4a7442d10 100644 --- a/tex/context/base/mkxl/font-pre.mkxl +++ b/tex/context/base/mkxl/font-pre.mkxl @@ -412,13 +412,13 @@ [mode=base, % mode=none, % better, maybe do this last kern=yes, -% flac=yes, % handled differently -% liga=yes, % makes no sense -% mode=node, -% mathnolimitsmode={0,800}, % now in lfg files + % flac=yes, % handled differently + % liga=yes, % makes no sense + % mode=node, + % mathnolimitsmode={0,800}, % now in lfg files mathalternates=yes, - mathitalics=yes, % we pass them - mathdimensions=all, + % mathitalics=yes, % we pass them + % mathdimensions=all, % mathkerns=yes, % staircase=yes, compactmath=yes, @@ -467,10 +467,10 @@ \definefontfeature[math-scriptscript-r2l] [mathematics-r2l] [ssty=2,mathsize=yes] % this will go away: could be a mode in the engine - -\definefontfeature[math-nostack-text] [math-text] [nostackmath=yes] -\definefontfeature[math-nostack-script] [math-script] [nostackmath=yes] -\definefontfeature[math-nostack-scriptscript][math-scriptscript][nostackmath=yes] +% +% \definefontfeature[math-nostack-text] [math-text] [nostackmath=yes] +% \definefontfeature[math-nostack-script] [math-script] [nostackmath=yes] +% \definefontfeature[math-nostack-scriptscript][math-scriptscript][nostackmath=yes] % \definefontfeature[mathtext] [math-text] % \definefontfeature[mathscript] [math-script] @@ -987,11 +987,9 @@ \startsetups experiment:fonts:compact \settrue\c_font_compact - % \definefontfeature[virtualmath] [mathematics] [compactmath=yes] % \definefontfeature[virtualmath-l2r] [mathematics-l2r][compactmath=yes] % \definefontfeature[virtualmath-r2l] [mathematics-r2l][compactmath=yes] - % \definefontfeature[math-text] [mathematics] [compactmath=yes] % \definefontfeature[math-script] [mathematics] [compactmath=yes] % \definefontfeature[math-scriptscript] [mathematics] [compactmath=yes] diff --git a/tex/context/base/mkxl/lpdf-ano.lmt b/tex/context/base/mkxl/lpdf-ano.lmt index e3904f16e..ed26b512e 100644 --- a/tex/context/base/mkxl/lpdf-ano.lmt +++ b/tex/context/base/mkxl/lpdf-ano.lmt @@ -112,6 +112,10 @@ local pdf_named = pdfconstant("Named") local autoprefix = "#" local usedautoprefixes = { } +function codeinjections.setautoprefix(prefix) + autoprefix = prefix ~= "" and prefix or autoprefix +end + local function registerautoprefix(name) local internal = autoprefix .. name if usedautoprefixes[internal] == nil then diff --git a/tex/context/base/mkxl/math-act.lmt b/tex/context/base/mkxl/math-act.lmt index 7fb4f9b9f..713635583 100644 --- a/tex/context/base/mkxl/math-act.lmt +++ b/tex/context/base/mkxl/math-act.lmt @@ -13,7 +13,7 @@ local type, next, tonumber = type, next, tonumber local fastcopy, copytable, insert, remove = table.fastcopy, table.copy, table.insert, table.remove local formatters = string.formatters local byte = string.byte -local setmetatableindex, sortedhash = table.setmetatableindex, table.sortedhash +local setmetatableindex, sortedkeys, sortedhash = table.setmetatableindex, table.sortedkeys, table.sortedhash local lpegmatch = lpeg.match local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end) @@ -54,7 +54,8 @@ local fontproperties = fonts.hashes.properties local mathgaps = mathematics.gaps -local use_math_goodies = true directives.register("math.nogoodies", function(v) use_math_goodies = not v end) +local use_math_goodies = true directives.register("math.nogoodies", function(v) use_math_goodies = not v end) +local checkitalics = false trackers .register("math.checkitalics", function(v) checkitalics = v end) local mathfontparameteractions = sequencers.new { name = "mathparameters", @@ -136,40 +137,45 @@ local how = { DelimiterPercent = "unscaled", } -function mathematics.scaleparameters(target,original) - if not target.properties.math_is_scaled then - local mathparameters = target.mathparameters - if mathparameters and next(mathparameters) then - local parameters = target.parameters - local factor = parameters.factor - local hfactor = parameters.hfactor - local vfactor = parameters.vfactor - for name, value in next, mathparameters do - local h = how[name] - if h == "unscaled" then - -- kept - elseif h == "horizontal" then - value = value * hfactor - elseif h == "vertical"then - value = value * vfactor - else - value = value * factor - end - mathparameters[name] = value +local function scaleparameters(mathparameters,parameters) + if mathparameters and next(mathparameters) and parameters then + local factor = parameters.factor + local hfactor = parameters.hfactor + local vfactor = parameters.vfactor + for name, value in next, mathparameters do + local h = how[name] + if h == "unscaled" then + -- kept + elseif h == "horizontal" then + value = value * hfactor + elseif h == "vertical"then + value = value * vfactor + else + value = value * factor end + mathparameters[name] = value end + end +end + +function mathematics.scaleparameters(target,original) + if not target.properties.math_is_scaled then + scaleparameters(target.mathparameters,target.parameters) target.properties.math_is_scaled = true end end -- AccentBaseHeight vs FlattenedAccentBaseHeight -function mathematics.checkaccentbaseheight(target,original) - local mathparameters = target.mathparameters - if mathparameters and mathparameters.AccentBaseHeight == 0 then - mathparameters.AccentBaseHeight = target.parameters.xheight -- needs checking - end -end +-- function mathematics.checkaccentbaseheight(target,original) +-- local mathparameters = target.mathparameters +-- if mathparameters and mathparameters.AccentBaseHeight == 0 then +-- if trace_defining then +-- report_math("zero AccentBaseHeight corrected %a @ %p",target.properties.fullname,target.parameters.size) +-- end +-- mathparameters.AccentBaseHeight = target.parameters.xheight -- needs checking +-- end +-- end function mathematics.overloadparameters(target,original) if use_math_goodies then @@ -183,8 +189,6 @@ function mathematics.overloadparameters(target,original) if mathematics then local parameters = mathematics.parameters local bigslots = mathematics.bigslots or mathematics.bigs --- inspect(parameters) --- print("before",mathparameters.AxisHeight) if parameters then if trace_defining then report_math("overloading math parameters in %a @ %p",target.properties.fullname,target.parameters.size) @@ -207,7 +211,6 @@ function mathematics.overloadparameters(target,original) end mathparameters[name] = newvalue end --- print("after ",mathparameters.AxisHeight) for name, value in next, parameters do local tvalue = type(value) if tvalue == "string" then @@ -250,29 +253,34 @@ local function report_tweak(fmt,target,original,...) local metadata = (original and original.shared.rawdata.metadata) or (target and target .shared.rawdata.metadata) local parameters = target.parameters - report_mathtweak( - "%a, size %P, math size %i, %s", - metadata and metadata.fontname or "unknown", - parameters.size or 655360, - parameters.mathsize or 1, - string.formatters[fmt](...) - ) + if parameters then + report_mathtweak( + "%a, size %P, math size %i, %s", + metadata and metadata.fontname or "unknown", + parameters.size or 655360, + parameters.mathsize or 1, + string.formatters[fmt](...) + ) + else + print("something is wrong") + end else report_mathtweak("") end end mathtweaks.subsets = { - acenorsuvxz = { 0x1D44E, 0x1D450, 0x1D452, 0x1D45B, 0x1D45C, 0x1D45F, 0x1D460, 0x1D462, 0x1D463, 0x1D465, 0x1D467 }, - bhklt = { 0x1D44F, 0x1D455, 0x1D458, 0x1D459, 0x1D461 }, - d = { 0x1D451 }, - f = { 0x1D453 }, - gjqy = { 0x1D454, 0x1D457, 0x1D45E, 0x1D466 }, - i = { 0x1D456 }, - mw = { 0x1D45A, 0x1D464 }, - p = { 0x1D45D }, - dotless = { 0x00049, 0x0004A, 0x00131, 0x00237, 0x1D6A4, 0x1D6A5 }, - integrals = { 0x0222B, 0x0222C, 0x0222D, 0x0222E, 0x0222F, 0x02230, 0x02231, 0x02232, 0x02233, 0x02A0B, 0x02A0C, 0x02A0D, 0x02A0E, 0x02A0F, 0x02A10, 0x02A11, 0x02A12, 0x02A13, 0x02A14, 0x02A15, 0x02A16, 0x02A17, 0x02A18, 0x02A19, 0x02A1A, 0x02A1B, 0x02A1C }, + acenorsuvxz = { 0x1D44E, 0x1D450, 0x1D452, 0x1D45B, 0x1D45C, 0x1D45F, 0x1D460, 0x1D462, 0x1D463, 0x1D465, 0x1D467 }, + bhklt = { 0x1D44F, 0x1D455, 0x1D458, 0x1D459, 0x1D461 }, + d = { 0x1D451 }, + f = { 0x1D453 }, + gjqy = { 0x1D454, 0x1D457, 0x1D45E, 0x1D466 }, + i = { 0x1D456 }, + mw = { 0x1D45A, 0x1D464 }, + p = { 0x1D45D }, + dotless = { 0x00049, 0x0004A, 0x00131, 0x00237, 0x1D6A4, 0x1D6A5 }, + integrals = { 0x0222B, 0x0222C, 0x0222D, 0x0222E, 0x0222F, 0x02230, 0x02231, 0x02232, 0x02233, 0x02A0B, 0x02A0C, 0x02A0D, 0x02A0E, 0x02A0F, 0x02A10, 0x02A11, 0x02A12, 0x02A13, 0x02A14, 0x02A15, 0x02A16, 0x02A17, 0x02A18, 0x02A19, 0x02A1A, 0x02A1B, 0x02A1C, 0x02320, 0x02321 }, + horizontalfences = { 0x023B4, 0x023B5, 0x023DC, 0x023DD, 0x023DE, 0x023DF, 0x023E0, 0x023E1 }, -- not really used } local function getalso(target,original) @@ -519,7 +527,7 @@ do else report_mathtweak("invalid dimension entry %U",k) end --- character.tweaked = true +-- character.tweaked = true if v.all then local nxt = character.next if nxt then @@ -594,10 +602,6 @@ do report_mathtweak(parameters.text or "no message") end -end - -do - function mathtweaks.showinfo(target,original,parameters) local mathparameters = target.mathparameters for k, v in sortedhash(mathparameters) do @@ -650,7 +654,7 @@ do end end if trace_tweaking and count > 0 then - report_mathtweak("%i variants wiped",count) + report_tweak("%i variants wiped",target,original,count) end end end @@ -677,7 +681,7 @@ do end end if trace_tweaking and count > 0 then - report_mathtweak("%i permanent replacements",count) + report_tweak("%i permanent replacements",target,original,count) end end end @@ -698,7 +702,7 @@ do end end if trace_tweaking and count > 0 then - report_mathtweak("%i permanent substitutions",count) + report_tweak("%i permanent substitutions",target,original,count) end end end @@ -741,7 +745,6 @@ do end for k, v in next, list do -- no need for sortedhash(list) unless we report --- for k, v in sortedhash(list) do -- no need for sortedhash(list) unless we report stepper(k,function(n) -- todo: also make stepper accept a table add(v,n) end) @@ -766,7 +769,7 @@ do -- end if trace_tweaking and count > 0 then - report_mathtweak("%i kern pairs",count) + report_tweak("%i kern pairs",target,original,count) end end end @@ -775,16 +778,6 @@ end do - function mathtweaks.variants(target,original,parameters) - report_mathtweak("todo: remove 'variants' tweak from goodie file") - end - - mathtweaks.variant = mathtweaks.variants - -end - -do - -- see changed hack in math-fbk local nps = fonts.helpers.newprivateslot @@ -956,35 +949,35 @@ do unicode = 0x002D, -- hyphen minus }, ["unary plus"] = { - original = 0x002B, - extend = .5, - squeeze = .5, - width = .5, - height = .5, - yoffset = .2, - mode = 2, - wline = .5, - unicode = 0x002B, + original = 0x002B, + extend = .5, + squeeze = .5, + width = .5, + height = .5, + yoffset = .2, + mode = 2, + wline = .5, + unicode = 0x002B, }, ["unary plus minus"] = { - original = 0x00B1, - extend = .5, - squeeze = .5, - width = .5, - height = .5, - yoffset = .2, - mode = 2, - wline = .5, + original = 0x00B1, + extend = .5, + squeeze = .5, + width = .5, + height = .5, + yoffset = .2, + mode = 2, + wline = .5, }, ["unary minus plus"] = { - original = 0x2213, - extend = .5, - squeeze = .5, - width = .5, - height = .5, - yoffset = .2, - mode = 2, - wline = .5, + original = 0x2213, + extend = .5, + squeeze = .5, + width = .5, + height = .5, + yoffset = .2, + mode = 2, + wline = .5, }, } @@ -1015,7 +1008,7 @@ do v = table.combine(p,v) p.preset = nil else - goto NEXT + goto next end end local charslot = v.original @@ -1033,7 +1026,7 @@ do end processedprivates[name] = v end - ::NEXT:: + ::next:: end end mathtweaks.dimensions(target,original,{ @@ -1051,12 +1044,17 @@ do local targetcharacters= target.characters local factor = tonumber(parameters.factor) or 0 if factor ~= 0 then + local count = 0 for k, v in next, targetcharacters do local a = v.topanchor if a and a > 0 then v.topanchor = a * factor + count = count + 1 end end + if trace_tweaking and count > 0 then + report_tweak("%i top anchors fixed",target,original,count) + end end end @@ -1069,20 +1067,26 @@ do -- actually this should be a an engine feature driven by category because we don't -- want this in display mode .. only a test for MS and HH - local issymbol = characters.is_symbol +-- local issymbol = characters.is_symbol +-- +-- function mathtweaks.oldstylemath(target,original,parameters) +-- local chardata = characters.data +-- local characters = target.characters +-- local axis = target.mathparameters.AxisHeight +-- local delta = (parameters.factor or .1) * axis +-- target.mathparameters.AxisHeight = (axis - delta) +-- for k, v in sortedhash(characters) do +-- if issymbol[k] then -- quick hack, engine knows +-- print("old style math",k,chardata[k].description) +-- v.yoffset = -delta +-- v.height = (v.height or 0) - delta +-- v.depth = (v.depth or 0) - delta +-- end +-- end +-- end function mathtweaks.oldstylemath(target,original,parameters) - local characters = target.characters - local axis = target.mathparameters.AxisHeight - local delta = (parameters.factor or .1) * axis - target.mathparameters.AxisHeight = (axis - delta) - for k, v in sortedhash(characters) do - if issymbol[k] then -- quick hack, engine knows - v.yoffset = -delta - v.height = (v.height or 0) - delta - v.depth = (v.depth or 0) - delta - end - end + -- not relevant end end @@ -1170,7 +1174,7 @@ do else local done = false local italic = c.italic - if move then + if move and not c.advance then -- advance check prevents double move local width = c.width or 0 c.advance = width if correct then @@ -1183,23 +1187,14 @@ do if topanchor then c.topanchor = topanchor + llx end --- if c.bottomleft or c.topleft then --- print("BEFORE",c.bottomleft,c.topleft,llx) --- c.bottomleft = (c.bottomleft or 0) - llx --- c.topleft = (c.topleft or 0) - llx --- print("AFTER",c.bottomleft,c.topleft,llx) --- else - c.bottomleft = (c.bottomleft or 0) - llx - c.topleft = (c.topleft or 0) - llx --- end + c.bottomleft = (c.bottomleft or 0) - llx + c.topleft = (c.topleft or 0) - llx done = true end end if italic and italic ~= 0 then c.width = width + italic --- print(">>>",bottomright) c.bottomright = - italic --- c.bottomright = c.bottomright - italic done = true else c.width = width @@ -1223,18 +1218,36 @@ do goto smaller ::smaller:: s = c.smaller + ::variants:: + -- no italics here anyway butr we could check them some day else break end end end local list = parameters.list -- todo: ranges - if type(list) == "string" then + if list == "letters" or parameters.letters then + local chardata = characters.data + for k, v in sortedhash(targetcharacters) do + if v.italic then + local d = chardata[v.unicode] + local c = d and d.category + if c == "ll" or c == "lu" then + step(k) + end + end + end + return + elseif not list or list == "all" or list == true or parameters.all then + list = sortedkeys(targetcharacters) + elseif type(list) == "string" then list = { list } end for i=1,#list do local l = list[i] - if type(l) == "table" then + if not l then + -- can be false + elseif type(l) == "table" then for i=1,#l do step(i,l[i]) end @@ -1258,7 +1271,9 @@ do mathtweaks.wipeaccents = mathtweaks.wipeanchors function mathtweaks.wipeitalics(target,original,parameters) - wipe(target,original,parameters,"italic") + if not checkitalics then + wipe(target,original,parameters,"italic") + end end function mathtweaks.moveitalics(target,original,parameters) @@ -1295,7 +1310,7 @@ do mathtweaks.topaccents = mathtweaks.topanchors - function mathtweaks.limits(target,original,parameters) + function mathtweaks.movelimits(target,original,parameters) local characters = target.characters local list = parameters.list if list then @@ -1310,16 +1325,18 @@ do local c = characters[u] if c then local italic = c.italic - if italic and italic ~= 0 then - local width = c.width or 0 - local half = (italic/2) * factor - c.topanchor = width + half - c.bottomanchor = width - half - c.bottomright = - italic - c.italic = nil - if trace_tweaking then - -- todo + if italic then + if italic ~= 0 then + local width = c.width or 0 + local half = (italic/2) * factor + c.topanchor = width + half + c.bottomanchor = width - half + c.bottomright = - italic + if trace_tweaking then + -- todo + end end + c.italic = nil end local s = c.smaller if s then @@ -1348,6 +1365,9 @@ do relocate(k,tonumber(v) or factor) end end + if not next(done) then + report_tweak("no need to move limits",target,original) + end end end @@ -2028,11 +2048,11 @@ do end data.height = depth data.depth = height -if data.rorrim then - -- the original does the magic -else - data.yoffset = depth - height -end + if data.rorrim then + -- the original does the magic + else + data.yoffset = depth - height + end end local smaller = data.smaller if smaller then @@ -2315,10 +2335,8 @@ do local parameters = target.parameters local linewidth = target.MathConstants.RadicalRuleThickness -- make option local basechar = characters[radical] - local baseheight = basechar.height -/2 - local basedepth = basechar.depth -/2 + local baseheight = basechar.height/2 + local basedepth = basechar.depth/2 local basetotal = baseheight + basedepth local used = baseheight -- @@ -2846,19 +2864,41 @@ end do - function mathtweaks.diagnose(target,original,parameters) - local characters = target.characters - for k, v in sortedhash(characters) do - local italic = v.italic - if italic then - report_tweak("italics: %U %p",target,original,k,italic) + function mathtweaks.parameters(target,original,parameters) + local newparameters = parameters.list + local oldparameters = target.mathparameters + if newparameters and oldparameters then + newparameters = copytable(newparameters) + scaleparameters(newparameters,target.parameters) + for name, newvalue in next, newparameters do + oldparameters[name] = newvalue end end --- inspect(characters[0xF0929]) + end + + function mathtweaks.bigslots(target,original,parameters) + local list = parameters.list + if list then + target.bigslots = list + end end end +-- do +-- +-- function mathtweaks.diagnose(target,original,parameters) +-- local characters = target.characters +-- for k, v in sortedhash(characters) do +-- local italic = v.italic +-- if italic then +-- report_tweak("italics: %C %p",target,original,k,italic) +-- end +-- end +-- end +-- +-- end + do function mathtweaks.setoptions(target,original,parameters) @@ -2944,105 +2984,110 @@ do end) function mathtweaks.replacealphabets(target,original,parameters) - local feature = parameters.feature - local features = target.specification.features.normal - if not feature or features[feature] == true then - local list = parameters.list - if list then - local definedfont = fonts.definers.internal - local copiedglyph = fonts.handlers.vf.math.copy_glyph + local list = parameters.list + if list then + local features = target.specification.features.normal + local definedfont = fonts.definers.internal + local copiedglyph = fonts.handlers.vf.math.copy_glyph -- does a deep copy, including parts and so - local getsubstitution = fonts.handlers.otf.getsubstitution - local fontdata = fonts.hashes.identifiers - -- - local fonts = target.fonts - local size = target.size - local characters = target.characters - -- compact: size = 655360 - if not fonts then - fonts = { } - target.fonts = fonts - end - if #fonts == 0 then - fonts[1] = { id = 0, size = size } -- self, will be resolved later - end - for i=1,#list do - local entry = list[i] - local filename = entry.filename - local feature = entry.feature - local thesource = entry.source - local thetarget = entry.target or thesource - if thesource and thetarget then - local sourcerange = type(thesource) == "table" and thesource or blocks[thesource] -- .gaps - local targetrange = type(thetarget) == "table" and thetarget or blocks[thetarget] -- .gaps - if sourcerange and targetrange then - local firsttarget = targetrange.first - local firstsource = sourcerange.first - local lastsource = sourcerange.last or firstsource - if firstsource and firsttarget then - local offset = firsttarget - firstsource - local topovershoot = entry.topovershoot - if filename then - local rscale = entry.rscale or 1 -- todo - size = size * rscale -- maybe use scale in vf command - -- load font, todo: set language and script, the effect hack is ugly - local fullname = filename - local effect = features.effect - if effect then - fullname = fullname .. "*" .. effects["effect={"..effect.."}"] - end - local id = definedfont { - name = fullname, - size = size, - } - local chars = fontchars[id] - local dropin = fontdata[id] - local index = #fonts + 1 - fonts[index] = { id = id, size = size } - -- copy characters - for s=firstsource,lastsource do - local t = s + offset - local sourceunicode = mathgaps[s] or s + local getsubstitution = fonts.handlers.otf.getsubstitution + local fontdata = fonts.hashes.identifiers + -- + local fonts = target.fonts + local size = target.size + local characters = target.characters +-- local descriptions = target.descriptions + -- compact: size = 655360 + if not fonts then + fonts = { } + target.fonts = fonts + end + if #fonts == 0 then + fonts[1] = { id = 0, size = size } -- self, will be resolved later + end + for i=1,#list do + local entry = list[i] + local filename = entry.filename or parameters.filename + local feature = entry.feature + local thesource = entry.source + local thetarget = entry.target or thesource + if thesource and thetarget then + local sourcerange = type(thesource) == "table" and thesource or blocks[thesource] -- .gaps + local targetrange = type(thetarget) == "table" and thetarget or blocks[thetarget] -- .gaps + if sourcerange and targetrange then + local firsttarget = targetrange.first + local firstsource = sourcerange.first + local lastsource = sourcerange.last or firstsource + if firstsource and firsttarget then + local offset = firsttarget - firstsource + local topovershoot = entry.topovershoot + if filename then + local rscale = entry.rscale or 1 -- todo + size = size * rscale -- maybe use scale in vf command + -- load font, todo: set language and script, the effect hack is ugly + local fullname = filename + local effect = features.effect + if effect then + fullname = fullname .. "*" .. effects["effect={"..effect.."}"] + end + local id = definedfont { + name = fullname, + size = size, + } + local chars = fontchars[id] + local dropin = fontdata[id] + local index = #fonts + 1 + fonts[index] = { id = id, size = size } + -- copy characters + for s=firstsource,lastsource do + local t = s + offset + local sourceunicode = mathgaps[s] or s + if chars[sourceunicode] then local targetunicode = mathgaps[t] or t if feature then sourceunicode = getsubstitution(dropin,sourceunicode,feature,true,"math","dflt") or sourceunicode end if trace_tweaking then - report_mathtweak("copying %s %U from file %a to %s %U",thesource,sourceunicode,filename,thetarget,targetunicode) + report_tweak("copying %s %U from file %a to %s %U",target,original,thesource,sourceunicode,filename,thetarget,targetunicode) end characters[targetunicode] = copiedglyph(target,characters,chars,sourceunicode,index) +-- description end - elseif feature then - for s=firstsource,lastsource do - local t = s + offset - local sourceunicode = mathgaps[s] or s - local targetunicode = mathgaps[t] or t - local variant = getsubstitution(original,sourceunicode,feature,true,"math","dflt") - local data = characters[variant] - if data then - if trace_tweaking then - report_mathtweak("copying %s %U from feature %a to %s %U",thesource,sourceunicode,feature,thetarget,targetunicode) - end - characters[targetunicode] = copytable(data) + end + elseif feature then + for s=firstsource,lastsource do + local t = s + offset + local sourceunicode = mathgaps[s] or s + local targetunicode = mathgaps[t] or t + local variant = getsubstitution(original,sourceunicode,feature,true,"math","dflt") + local data = characters[variant] + if data then + if trace_tweaking then + report_tweak("copying %s %U from feature %a to %s %U",target,original,thesource,sourceunicode,feature,thetarget,targetunicode) end + characters[targetunicode] = copytable(data) +-- description end - else - for s=firstsource,lastsource do - local t = s + offset - local sourceunicode = mathgaps[s] or s - local targetunicode = mathgaps[t] or t + end + else + for s=firstsource,lastsource do + local t = s + offset + local sourceunicode = mathgaps[s] or s + local targetunicode = mathgaps[t] or t + if sourceunicode ~= targetunicode then local data = characters[sourceunicode] if data then if trace_tweaking then - report_mathtweak("copying %s %U to %s %U",thesource,sourceunicode,thetarget,targetunicode) + report_tweak("copying %s %U to %s %U",target,original,thesource,sourceunicode,thetarget,targetunicode) end characters[targetunicode] = copytable(data) +-- description end end end - else - -- error end + else + -- error end end end @@ -3050,13 +3095,38 @@ do end end -end + function mathtweaks.fallbacks(target,original,parameters) + local fallbacks = target.specification.fallbacks + if fallbacks then + local definitions = fonts.collections.definitions[fallbacks] + if definitions then + local list = { } + for i=1,#definitions do + local definition = definitions[i] + -- local check = definition.check + -- local force = definition.force + local first = definition.start + local last = definition.stop + local offset = definition.offset or first + list[#list+1] = { + filename = definition.font, + rscale = definition.rscale or 1, + source = { first = first, last = last }, + target = { first = offset, last = offset + (last - first) }, + } + end + mathtweaks.replacealphabets(target,original,{ + tweak = "replacealphabets", + list = list, + } ) + end + end + end -local apply_tweaks = true +end -directives.register("math.applytweaks", function(v) - apply_tweaks = v; -end) +local apply_tweaks = true directives.register("math.applytweaks", function(v) apply_tweaks = v end) +local applied_tweaks = 0 local function applytweaks(when,target,original) if apply_tweaks then @@ -3073,6 +3143,8 @@ local function applytweaks(when,target,original) local mathematics = goodie.mathematics local tweaks = mathematics and mathematics.tweaks if type(tweaks) == "table" then + statistics.starttiming(mathtweaks) + applied_tweaks = applied_tweaks + 1 tweaks = tweaks[when] if type(tweaks) == "table" then if trace_defining then @@ -3084,19 +3156,24 @@ local function applytweaks(when,target,original) if type(tweak) == "table" then local action = mathtweaks[tweak.tweak or ""] if action then - local version = tweak.version - if version and version ~= target.tweakversion then - report_math("skipping tweak %a version %a",tweak.tweak,version) - elseif original then - action(target,original,tweak) - else - action(target,tweak) + local feature = tweak.feature + local features = target.specification.features.normal + if not feature or features[feature] == true then + local version = tweak.version + if version and version ~= target.tweakversion then + report_math("skipping tweak %a version %a",tweak.tweak,version) + elseif original then + action(target,original,tweak) + else + action(target,tweak) + end end end end end end end + statistics.stoptiming(mathtweaks) end tweaked[when] = true target.tweaked = tweaked @@ -3125,6 +3202,12 @@ function mathematics.tweakaftercopyingfont(target,original) end end +statistics.register("math tweaking time",function() + if applied_tweaks > 0 then + return string.format("%s seconds, %s math goodie tables", statistics.elapsedtime(mathtweaks),applied_tweaks) + end +end) + do local defaults = { @@ -3146,9 +3229,12 @@ do }, } + local reported = table.setmetatableindex("table") + function mathematics.checkaftercopyingfont(target,original) local mathparameters = target.mathparameters -- why not hasmath if mathparameters then + local chardata = characters.data local characters = target.characters -- for i=1,#defaults do @@ -3179,6 +3265,35 @@ do local ca = mathematics.alphabets.ca.tf register(sr.ucletters,ca.ucletters) register(sr.lcletters,ca.lcletters) + -- + if checkitalics then + local italics = 0 + local metadata = original.shared.rawdata.metadata + local fontname = metadata and metadata.fontname or false + for k, v in sortedhash(characters) do + local italic = v.italic + if italic then + local unicode = v.unicode + if unicode and not reported[fontname][unicode] then -- there can be variants + local data = chardata[unicode] + local description = data.description or "" + local category = data.category or "--" + report_tweak("italics: %C %p %s %s",target,original,k,italic,category,description) + reported[fontname][unicode] = true + end + italics = italics + 1 + end + end + if italics > 0 then + report_tweak("still has %i italics",target,original,italics) + goto NEXTSTEP + end + end + + target.properties.mathitalics = false + target.properties.textitalics = false + ::NEXTSTEP:: + -- more to come end end @@ -3195,7 +3310,7 @@ end sequencers.appendaction("mathparameters","system","mathematics.overloadparameters") sequencers.appendaction("mathparameters","system","mathematics.scaleparameters") -sequencers.appendaction("mathparameters","system","mathematics.checkaccentbaseheight") -- should go in lfg instead +----------.appendaction("mathparameters","system","mathematics.checkaccentbaseheight") -- should go in lfg instead ----------.appendaction("mathparameters","system","mathematics.checkprivateparameters") -- after scaling ! sequencers.appendaction("beforecopyingcharacters","system","mathematics.tweakbeforecopyingfont") @@ -3329,111 +3444,3 @@ interfaces.implement { -- can be public with two times "integerargument" context(kind) end } - -local stack = { } - -function mathematics.registerfallbackid(n,id,name) - if trace_collecting then - report_math("resolved fallback font %i, name %a, id %a, used %a", - n,name,id,fontproperties[id].fontname) - end - stack[#stack][n] = id -end - -interfaces.implement { -- will be shared with text - name = "registerfontfallbackid", - arguments = { "integer", "integer", "string" }, - actions = mathematics.registerfallbackid, -} - --- todo: run this directly .. can be done in luametatex - -function mathematics.resolvefallbacks(target,specification,fallbacks) - local definitions = fonts.collections.definitions[fallbacks] - if definitions then - local size = specification.size -- target.size - local list = { } - insert(stack,list) - context.pushcatcodes("prt") -- context.unprotect() - for i=1,#definitions do - local definition = definitions[i] - local name = definition.font - local features = definition.features or "" - local size = size * (definition.rscale or 1) - -- compact: size = 655360 - context.font_fallbacks_register_math(i,name,features,size) - if trace_collecting then - report_math("registering fallback font %i, name %a, size %a, features %a",i,name,size,features) - end - end - context.popcatcodes() - end -end - -function mathematics.finishfallbacks(target,specification,fallbacks) - local list = remove(stack) - if list and #list > 0 then - local definitions = fonts.collections.definitions[fallbacks] - if definitions and #definitions > 0 then - if trace_collecting then - report_math("adding fallback characters to font %a",specification.hash) - end - ----- definedfont = fonts.definers.internal - local copiedglyph = fonts.handlers.vf.math.copy_glyph - local fonts = target.fonts - local size = specification.size -- target.size - local characters = target.characters - -- compact: size = 655360 - if not fonts then - fonts = { } - target.fonts = fonts - end - if #fonts == 0 then - fonts[1] = { id = 0, size = size } -- self, will be resolved later - end - local done = { } - for i=1,#definitions do - local definition = definitions[i] - local name = definition.font - local start = definition.start - local stop = definition.stop - local gaps = definition.gaps - local check = definition.check - local force = definition.force - local rscale = definition.rscale or 1 - local offset = definition.offset or start - local id = list[i] - if id then - local index = #fonts + 1 - fonts[index] = { id = id, size = size } - local chars = fontchars[id] - local function remap(unic,unicode,gap) - if check and not chars[unicode] then - return - end - if force or (not done[unic] and not characters[unic]) then - if trace_collecting then - report_math("replacing math character %C by %C using vector %a and font id %a for %a%s%s", - unic,unicode,fallbacks,id,fontproperties[id].fontname,check and ", checked",gap and ", gap plugged") - end - characters[unic] = copiedglyph(target,characters,chars,unicode,index) - done[unic] = true - end - end - local step = offset - start - for unicode = start, stop do - remap(unicode + step,unicode,false) - end - if gaps then - for unic, unicode in next, gaps do - remap(unic,unicode,true) - remap(unicode,unicode,true) - end - end - end - end - elseif trace_collecting then - report_math("no fallback characters added to font %a",specification.hash) - end - end -end diff --git a/tex/context/base/mkxl/math-ini.mkxl b/tex/context/base/mkxl/math-ini.mkxl index 29af7a659..c1beb071c 100644 --- a/tex/context/base/mkxl/math-ini.mkxl +++ b/tex/context/base/mkxl/math-ini.mkxl @@ -1958,6 +1958,13 @@ %D For previous variants of the function styling you can check the git repository %D end April 2022. +% \startTEXpage[offset=1dk] +% $\sin(x) = 10$ +% \m[functionstyle=sans]{\sin(x) = 10} +% \startformula \sin(x) = 10 \stopformula +% \startformula[functionstyle=sans] \sin(x) = 10 \stopformula +% \stopTEXpage + \protected\def\math_function_handle#1#2#3% {\begingroup \letdummyparameter\c!mathlimits\empty @@ -1989,6 +1996,17 @@ \egroup \endgroup} +\appendtoks + \edef\p_functionstyle{\formulaparameter\c!functionstyle}% + \ifempty\p_functionstyle\else + \letmathematicsparameter\c!functionstyle\p_functionstyle + \fi + \edef\p_functioncolor{\formulaparameter\c!functioncolor}% + \ifempty\p_functioncolor\else + \letmathematicsparameter\c!functioncolor\p_functioncolor + \fi +\to \everybeforedisplayformula + \permanent\tolerant\protected\def\mfunction [#1]{\math_function_handle{#1}\firstofoneargument} \permanent\tolerant\protected\def\mfunctionlabeltext[#1]{\math_function_handle{#1}\mathlabeltext} @@ -3948,7 +3966,7 @@ \installcorenamespace{mathrules} -\permanent\protected\def\enablemathrules{\letgvalue{\??mathrules\fontclass}\plusone} +\permanent\protected\def\enablemathrules{\gletcsname\??mathrules\fontclass\endcsname\plusone} \appendtoks \mathrulesmode\ifcsname\??mathrules\fontclass\endcsname @@ -4378,13 +4396,13 @@ %D \stoptyping \definesystemattribute[mathaxis][public] - \def\math_axis_inject#1% {\mathatom \s!class \mathghostcode \s!unpack { \showmakeup[strut]% todo: shortcut + \scratchdimen.5\Umathfractionrule\mathstyle \srule - \s!height \dimexpr\Umathaxis\mathstyle+.2\points\relax - \s!depth -\dimexpr\Umathaxis\mathstyle-.2\points\relax + \s!height \dimexpr\Umathaxis\mathstyle+\scratchdimen\relax + \s!depth -\dimexpr\Umathaxis\mathstyle-\scratchdimen\relax \s!attr \mathaxisattribute #1% \relax}} diff --git a/tex/context/base/mkxl/math-vfu.lmt b/tex/context/base/mkxl/math-vfu.lmt index 906c9ccf6..86d1fca0d 100644 --- a/tex/context/base/mkxl/math-vfu.lmt +++ b/tex/context/base/mkxl/math-vfu.lmt @@ -651,6 +651,7 @@ local function copy_glyph(main,target,original,unicode,slot) kerns = olddata.kerns, mathkerns = olddata.mathkerns, tounicode = olddata.tounicode, + smaller = olddata.smaller, commands = { { "slot", slot, nextglyph } }, } local newnextglyph = addprivate(main,formatters["M-N-%H"](nextglyph),newnextdata) @@ -703,7 +704,12 @@ local function copy_glyph(main,target,original,unicode,slot) vvi.glyph = addprivate(main,formatters["M-V-%H"](oldglyph),newdata) end end - return newdata + local smaller = olddata.smaller + if smaller then + local smallerdata = copy_glyph(main,target,original,smaller,slot) + glyphdata.smaller = addprivate(main,formatters["M-S-%H"](smaller),smallerdata) + end + return glyphdata end end diff --git a/tex/context/base/mkxl/mlib-int.lmt b/tex/context/base/mkxl/mlib-int.lmt index 9165d5423..686f1985d 100644 --- a/tex/context/base/mkxl/mlib-int.lmt +++ b/tex/context/base/mkxl/mlib-int.lmt @@ -7,8 +7,6 @@ if not modules then modules = { } end modules ['mlib-int'] = { } local factor = number.dimenfactors.bp -local mpstring = mp.string -local injectnumeric = mp.inject.numeric local isdimen = tex.isdimen local iscount = tex.iscount local getdimen = tex.getdimen @@ -53,49 +51,78 @@ end do - local d_paperheight = isdimen("paperheight") registerdirect("PaperHeight", function() return getdimen(d_paperheight) * factor end) - local d_paperwidth = isdimen("paperwidth") registerdirect("PaperWidth", function() return getdimen(d_paperwidth) * factor end) - local d_printpaperheight = isdimen("printpaperheight") registerdirect("PrintPaperHeight", function() return getdimen(d_printpaperheight) * factor end) - local d_printpaperwidth = isdimen("printpaperwidth") registerdirect("PrintPaperWidth", function() return getdimen(d_printpaperwidth) * factor end) - local d_topspace = isdimen("topspace") registerdirect("TopSpace", function() return getdimen(d_topspace) * factor end) - local d_bottomspace = isdimen("bottomspace") registerdirect("BottomSpace", function() return getdimen(d_bottomspace) * factor end) - local d_backspace = isdimen("backspace") registerdirect("BackSpace", function() return getdimen(d_backspace) * factor end) - local d_cutspace = isdimen("cutspace") registerdirect("CutSpace", function() return getdimen(d_cutspace) * factor end) - local d_makeupheight = isdimen("makeupheight") registerdirect("MakeupHeight", function() return getdimen(d_makeupheight) * factor end) - local d_makeupwidth = isdimen("makeupwidth") registerdirect("MakeupWidth", function() return getdimen(d_makeupwidth) * factor end) - local d_topheight = isdimen("topheight") registerdirect("TopHeight", function() return getdimen(d_topheight) * factor end) - local d_topdistance = isdimen("topdistance") registerdirect("TopDistance", function() return getdimen(d_topdistance) * factor end) - local d_headerheight = isdimen("headerheight") registerdirect("HeaderHeight", function() return getdimen(d_headerheight) * factor end) - local d_headerdistance = isdimen("headerdistance") registerdirect("HeaderDistance", function() return getdimen(d_headerdistance) * factor end) - local d_textheight = isdimen("textheight") registerdirect("TextHeight", function() return getdimen(d_textheight) * factor end) - local d_footerdistance = isdimen("footerdistance") registerdirect("FooterDistance", function() return getdimen(d_footerdistance) * factor end) - local d_footerheight = isdimen("footerheight") registerdirect("FooterHeight", function() return getdimen(d_footerheight) * factor end) - local d_bottomdistance = isdimen("bottomdistance") registerdirect("BottomDistance", function() return getdimen(d_bottomdistance) * factor end) - local d_bottomheight = isdimen("bottomheight") registerdirect("BottomHeight", function() return getdimen(d_bottomheight) * factor end) - local d_leftedgewidth = isdimen("leftedgewidth") registerdirect("LeftEdgeWidth", function() return getdimen(d_leftedgewidth) * factor end) - local d_leftedgedistance = isdimen("leftedgedistance") registerdirect("LeftEdgeDistance", function() return getdimen(d_leftedgedistance) * factor end) - local d_leftmarginwidth = isdimen("leftmarginwidth") registerdirect("LeftMarginWidth", function() return getdimen(d_leftmarginwidth) * factor end) - local d_leftmargindistance = isdimen("leftmargindistance") registerdirect("LeftMarginDistance", function() return getdimen(d_leftmargindistance) * factor end) - local d_textwidth = isdimen("textwidth") registerdirect("TextWidth", function() return getdimen(d_textwidth) * factor end) - local d_rightmargindistance = isdimen("rightmargindistance") registerdirect("RightMarginDistance", function() return getdimen(d_rightmargindistance) * factor end) - local d_rightmarginwidth = isdimen("rightmarginwidth") registerdirect("RightMarginWidth", function() return getdimen(d_rightmarginwidth) * factor end) - local d_rightedgedistance = isdimen("rightedgedistance") registerdirect("RightEdgeDistance", function() return getdimen(d_rightedgedistance) * factor end) - local d_rightedgewidth = isdimen("rightedgewidth") registerdirect("RightEdgeWidth", function() return getdimen(d_rightedgewidth) * factor end) - -end - -do - - local onrightpage = structures.pages.on_right - - registerdirect("InnerMarginDistance", function() return getdimen(onrightpage() and d_leftmargindistance or d_rightmargindistance) * factor end) - registerdirect("InnerMarginWidth", function() return getdimen(onrightpage() and d_leftmarginwidth or d_rightmarginwidth ) * factor end) - registerdirect("OuterMarginDistance", function() return getdimen(onrightpage() and d_rightmargindistance or d_leftmargindistance ) * factor end) - registerdirect("OuterMarginWidth", function() return getdimen(onrightpage() and d_rightmarginwidth or d_leftmarginwidth ) * factor end) - registerdirect("InnerEdgeDistance", function() return getdimen(onrightpage() and d_leftmargindistance or d_rightmargindistance) * factor end) - registerdirect("InnerEdgeWidth", function() return getdimen(onrightpage() and d_leftmarginwidth or d_rightmarginwidth ) * factor end) - registerdirect("OuterEdgeDistance", function() return getdimen(onrightpage() and d_rightedgedistance or d_leftedgedistance ) * factor end) - registerdirect("OuterEdgeWidth", function() return getdimen(onrightpage() and d_rightedgewidth or d_leftedgewidth ) * factor end) + -- These get swapped so the d_ numbers change. + + registerdirect("PaperHeight", function() return getdimen("paperheight") * factor end) + registerdirect("PaperWidth", function() return getdimen("paperwidth") * factor end) + registerdirect("PrintPaperHeight", function() return getdimen("printpaperheight") * factor end) + registerdirect("PrintPaperWidth", function() return getdimen("printpaperwidth") * factor end) + registerdirect("BackSpace", function() return getdimen("backspace") * factor end) + registerdirect("CutSpace", function() return getdimen("cutspace") * factor end) + + registerdirect("LeftEdgeWidth", function() return getdimen("leftedgewidth") * factor end) + registerdirect("LeftEdgeDistance", function() return getdimen("leftedgedistance") * factor end) + registerdirect("LeftMarginWidth", function() return getdimen("leftmarginwidth") * factor end) + registerdirect("LeftMarginDistance", function() return getdimen("leftmargindistance") * factor end) + registerdirect("RightMarginDistance", function() return getdimen("rightmargindistance") * factor end) + registerdirect("RightMarginWidth", function() return getdimen("rightmarginwidth") * factor end) + registerdirect("RightEdgeDistance", function() return getdimen("rightedgedistance") * factor end) + registerdirect("RightEdgeWidth", function() return getdimen("rightedgewidth") * factor end) + + -- leftmargintotal rightmargintotal -- not yet + -- leftedgetotal rightedgetotal + -- leftsidetotal rightsidetotal + -- leftcombitotal rightcombitotal + -- innermargintotal outermargintotal + -- inneredgetotal outeredgetotal + -- innercombitotal outercombitotal + -- innersidetotal outersidetotal + + local d_leftedgewidth = isdimen("leftedgewidth") + local d_leftedgedistance = isdimen("leftedgedistance") + local d_leftmarginwidth = isdimen("leftmarginwidth") + local d_leftmargindistance = isdimen("leftmargindistance") + local d_rightmargindistance = isdimen("rightmargindistance") + local d_rightmarginwidth = isdimen("rightmarginwidth") + local d_rightedgedistance = isdimen("rightedgedistance") + local d_rightedgewidth = isdimen("rightedgewidth") + + registerdirect("InnerMarginDistance", function() return getdimen(d_leftmargindistance ) * factor end) + registerdirect("InnerMarginWidth", function() return getdimen(d_leftmarginwidth ) * factor end) + registerdirect("OuterMarginDistance", function() return getdimen(d_rightmargindistance) * factor end) + registerdirect("OuterMarginWidth", function() return getdimen(d_rightmarginwidth ) * factor end) + registerdirect("InnerEdgeDistance", function() return getdimen(d_leftmargindistance ) * factor end) + registerdirect("InnerEdgeWidth", function() return getdimen(d_leftmarginwidth ) * factor end) + registerdirect("OuterEdgeDistance", function() return getdimen(d_rightedgedistance ) * factor end) + registerdirect("OuterEdgeWidth", function() return getdimen(d_rightedgewidth ) * factor end) + + -- local onrightpage = structures.pages.on_right + + -- registerdirect("InnerMarginDistance", function() return getdimen(onrightpage() and "leftmargindistance" or "rightmargindistance") * factor end) + -- registerdirect("InnerMarginWidth", function() return getdimen(onrightpage() and "leftmarginwidth" or "rightmarginwidth" ) * factor end) + -- registerdirect("OuterMarginDistance", function() return getdimen(onrightpage() and "rightmargindistance" or "leftmargindistance" ) * factor end) + -- registerdirect("OuterMarginWidth", function() return getdimen(onrightpage() and "rightmarginwidth" or "leftmarginwidth" ) * factor end) + -- registerdirect("InnerEdgeDistance", function() return getdimen(onrightpage() and "leftmargindistance" or "rightmargindistance") * factor end) + -- registerdirect("InnerEdgeWidth", function() return getdimen(onrightpage() and "leftmarginwidth" or "rightmarginwidth" ) * factor end) + -- registerdirect("OuterEdgeDistance", function() return getdimen(onrightpage() and "rightedgedistance" or "leftedgedistance" ) * factor end) + -- registerdirect("OuterEdgeWidth", function() return getdimen(onrightpage() and "rightedgewidth" or "leftedgewidth" ) * factor end) + + -- These have stable d_ numbers. + + local d_topspace = isdimen("topspace") registerdirect("TopSpace", function() return getdimen(d_topspace) * factor end) + local d_bottomspace = isdimen("bottomspace") registerdirect("BottomSpace", function() return getdimen(d_bottomspace) * factor end) + local d_makeupheight = isdimen("makeupheight") registerdirect("MakeupHeight", function() return getdimen(d_makeupheight) * factor end) + local d_makeupwidth = isdimen("makeupwidth") registerdirect("MakeupWidth", function() return getdimen(d_makeupwidth) * factor end) + local d_topheight = isdimen("topheight") registerdirect("TopHeight", function() return getdimen(d_topheight) * factor end) + local d_topdistance = isdimen("topdistance") registerdirect("TopDistance", function() return getdimen(d_topdistance) * factor end) + local d_headerheight = isdimen("headerheight") registerdirect("HeaderHeight", function() return getdimen(d_headerheight) * factor end) + local d_headerdistance = isdimen("headerdistance") registerdirect("HeaderDistance", function() return getdimen(d_headerdistance) * factor end) + local d_textheight = isdimen("textheight") registerdirect("TextHeight", function() return getdimen(d_textheight) * factor end) + local d_footerdistance = isdimen("footerdistance") registerdirect("FooterDistance", function() return getdimen(d_footerdistance) * factor end) + local d_footerheight = isdimen("footerheight") registerdirect("FooterHeight", function() return getdimen(d_footerheight) * factor end) + local d_bottomdistance = isdimen("bottomdistance") registerdirect("BottomDistance", function() return getdimen(d_bottomdistance) * factor end) + local d_bottomheight = isdimen("bottomheight") registerdirect("BottomHeight", function() return getdimen(d_bottomheight) * factor end) + local d_textwidth = isdimen("textwidth") registerdirect("TextWidth", function() return getdimen(d_textwidth) * factor end) end diff --git a/tex/context/base/mkxl/node-ali.lmt b/tex/context/base/mkxl/node-ali.lmt index 4b52f2d4b..69b1e7aa0 100644 --- a/tex/context/base/mkxl/node-ali.lmt +++ b/tex/context/base/mkxl/node-ali.lmt @@ -314,7 +314,7 @@ interfaces.implement { end, } --- Let's put it here (for now) (some locals above) .. will be cleaned up! +-- This will go to math-ali.lmt do @@ -538,7 +538,7 @@ deltas = { } for count=1,#records do if count == lindex then if centered and overflow then - lwidth = lwidth - tex.getdimen("d_math_eqalign_number_distance") + lwidth = lwidth - texgetdimen("d_math_eqalign_number_distance") end setwidth(records[count],lwidth) elseif count == rindex then diff --git a/tex/context/base/mkxl/scrn-ini.lmt b/tex/context/base/mkxl/scrn-ini.lmt index 82b9bd02e..2d01a1a28 100644 --- a/tex/context/base/mkxl/scrn-ini.lmt +++ b/tex/context/base/mkxl/scrn-ini.lmt @@ -52,3 +52,11 @@ interfaces.implement { actions = setidentityvariable, arguments = "2 strings", } + +interfaces.implement { + name = "setautoprefix", + actions = function(prefix) + backends.codeinjections.setautoprefix(prefix) + end, + arguments = "string", +} diff --git a/tex/context/base/mkxl/scrn-ini.mklx b/tex/context/base/mkxl/scrn-ini.mklx index 8a7f89c42..1308ff6ec 100644 --- a/tex/context/base/mkxl/scrn-ini.mklx +++ b/tex/context/base/mkxl/scrn-ini.mklx @@ -206,4 +206,8 @@ \scrn_identity_document {date}\c!date \to \everystartdocument % or stop +\appendtoks + \clf_setautoprefix{\interactionparameter\c!prefix}% +\to \everysetupinteraction + \protect \endinput diff --git a/tex/context/base/mkxl/tabl-ntb.mkxl b/tex/context/base/mkxl/tabl-ntb.mkxl index d36d113e1..a0e85e839 100644 --- a/tex/context/base/mkxl/tabl-ntb.mkxl +++ b/tex/context/base/mkxl/tabl-ntb.mkxl @@ -1219,7 +1219,8 @@ \ifcsname\tabl_ntb_row_pattern\c_tabl_ntb_current_row\c_tabl_ntb_current_col\endcsname \scratchcounter\numexpr\c_tabl_ntb_maximum_row-\c_tabl_ntb_current_row+\plusone\relax \ifnum\tabl_ntb_get_row\c_tabl_ntb_current_row\c_tabl_ntb_current_col>\scratchcounter - \tabl_ntb_set_row\c_tabl_ntb_current_row\c_tabl_ntb_current_col{\the\scratchcounter}% +% \tabl_ntb_set_row\c_tabl_ntb_current_row\c_tabl_ntb_current_col{\the\scratchcounter}% + \tabl_ntb_set_row\c_tabl_ntb_current_row\c_tabl_ntb_current_col\scratchcounter \fi \fi \tabl_ntb_let_ht\c_tabl_ntb_current_row\c_tabl_ntb_current_col\zeropoint diff --git a/tex/context/base/mkxl/trac-vis.lmt b/tex/context/base/mkxl/trac-vis.lmt index e00944413..e2c79022a 100644 --- a/tex/context/base/mkxl/trac-vis.lmt +++ b/tex/context/base/mkxl/trac-vis.lmt @@ -48,6 +48,7 @@ local getattr = nuts.getattr local getsubtype = nuts.getsubtype local getbox = nuts.getbox local getlist = nuts.getlist +local getprev = nuts.getprev local getnext = nuts.getnext local getboth = nuts.getboth local getwhd = nuts.getwhd @@ -1313,7 +1314,9 @@ local ruledstrut do if getsubtype(current) == strut_code then local w = strut_size local a = getattr(current,a_mathaxis) + setattr(current,a_layer,l_strut) if a then + local p = getprev(current) local b, e for n in traverseid(math_code,current) do e = n @@ -1336,17 +1339,17 @@ local ruledstrut do head, current, rule = nuts.remove(head,current) local kern = new_kern(-w) if a == 2 then - insertnodebefore(head,e,kern) - insertnodebefore(head,e,rule) + head = insertnodebefore(head,e,kern) + head = insertnodebefore(head,e,rule) else insertnodeafter(head,b,kern) insertnodeafter(head,b,rule) end + current = p else setwidth(current,w) - head, current = insertnodeafter(head,current,new_kern(w)) + head, current = insertnodeafter(head,current,new_kern(-w)) end - setattr(current,a_layer,l_strut) end end return head, current diff --git a/tex/context/base/mkxl/type-imp-euler.mkxl b/tex/context/base/mkxl/type-imp-euler.mkxl new file mode 100644 index 000000000..c0a3f73f6 --- /dev/null +++ b/tex/context/base/mkxl/type-imp-euler.mkxl @@ -0,0 +1,67 @@ +%D \module +%D [ file=type-otf, +%D version=2007.07.30, +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=Euler, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\loadtypescriptfile[texgyre] +\loadtypescriptfile[dejavu] + +\definefontfeature[pagellaovereuler][pagellaovereuler=yes] +\definefontfeature[euleroverpagella][euleroverpagella=yes] + +\starttypescriptcollection[pagella-eulernova] + + \starttypescript [\s!serif] [eulernova] [\s!name] + \setups[\s!font:\s!fallback:\s!serif] + \definefontsynonym [\s!Serif] [\s!file:euler.otf] [\s!features=\s!default] + \stoptypescript + + \starttypescript [\s!math] [eulernova] [\s!name] + \definefontsynonym [\s!MathRoman] [\s!file:euler.otf] [\s!features={\s!math\mathsizesuffix,mathextra},\s!goodies=euler-math] + \stoptypescript + + \starttypescript [pagella-eulernova] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [pagella] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] [\s!rscale=0.9] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [eulernova] [\s!default] + \quittypescriptscanning + \stoptypescript + + \starttypescript [eulernova] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [eulernova] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] [\s!rscale=0.9] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [eulernova] [\s!default] + \quittypescriptscanning + \stoptypescript + + \starttypescript [\s!math] [euleroverpagella] [\s!name] + \definefontsynonym [\s!MathRoman] [texgyrepagella-math] [\s!features={\s!math\mathsizesuffix,euleroverpagella,mathextra},\s!fallbacks=euleroverpagella,\s!goodies=pagella-math] + \stoptypescript + + \starttypescript [\s!math] [pagellaovereuler] [\s!name] + \definefontsynonym [\s!MathRoman] [\s!file:euler.otf] [\s!features={\s!math\mathsizesuffix,pagellaovereuler,mathextra},\s!fallbacks=pagellaovereuler,\s!goodies=euler-math] + \stoptypescript + + \starttypescript [pagella-with-euler,euleroverpagella] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [pagella] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] [\s!rscale=0.9] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [euleroverpagella] [\s!default] + \quittypescriptscanning + \stoptypescript + + \starttypescript [euler-with-pagella,pagellaovereuler] + \definetypeface [\typescriptone] [\s!rm] [\s!serif] [eulernova] [\s!default] + \definetypeface [\typescriptone] [\s!tt] [\s!mono] [dejavu] [\s!default] [\s!rscale=0.9] + \definetypeface [\typescriptone] [\s!mm] [\s!math] [pagellaovereuler] [\s!default] + \quittypescriptscanning + \stoptypescript + +\stoptypescriptcollection diff --git a/tex/context/base/mkxl/typo-itc.lmt b/tex/context/base/mkxl/typo-itc.lmt index f2f6c428e..f0b6980f4 100644 --- a/tex/context/base/mkxl/typo-itc.lmt +++ b/tex/context/base/mkxl/typo-itc.lmt @@ -82,7 +82,7 @@ function typesetters.italics.forcevariant(variant) forcedvariant = variant end --- We use the same key as the tex font handler. So, if a valua has already be set, we +-- We use the same key as the tex font handler. So, if a value has already be set, we -- use that one. local function setitalicinfont(font,char) @@ -108,6 +108,7 @@ local function setitalicinfont(font,char) end end end + -- we don't want to do this each time so we also set zero here if trace_italics then report_italics("setting italic correction of %C of font %a to %p",char,font,italic) end |