diff options
Diffstat (limited to 'tex/context/base/mkxl/font-ctx.lmt')
-rw-r--r-- | tex/context/base/mkxl/font-ctx.lmt | 134 |
1 files changed, 40 insertions, 94 deletions
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 |