diff options
-rw-r--r-- | tex/context/base/catc-ctx.tex | 2 | ||||
-rw-r--r-- | tex/context/base/cont-new.tex | 2 | ||||
-rw-r--r-- | tex/context/base/context.tex | 2 | ||||
-rw-r--r-- | tex/context/base/core-def.mkiv | 7 | ||||
-rw-r--r-- | tex/context/base/core-job.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/font-ctx.lua | 15 | ||||
-rw-r--r-- | tex/context/base/font-ini.mkiv | 57 | ||||
-rw-r--r-- | tex/context/base/mlib-pdf.lua | 15 | ||||
-rw-r--r-- | tex/context/base/mult-cld.lua | 185 | ||||
-rw-r--r-- | tex/generic/context/luatex-fonts-merged.lua | 2 |
10 files changed, 180 insertions, 109 deletions
diff --git a/tex/context/base/catc-ctx.tex b/tex/context/base/catc-ctx.tex index 79e89a69b..beaa62479 100644 --- a/tex/context/base/catc-ctx.tex +++ b/tex/context/base/catc-ctx.tex @@ -27,9 +27,9 @@ \startcatcodetable \ctxcatcodes \catcode`\^^I = 10 \catcode`\^^M = 5 - % \catcode`\^^J = 10 % new \catcode`\^^L = 5 \catcode`\ = 10 + % \catcode`\^^J = 10 % new \catcode`\^^Z = 9 \catcode`\\ = 0 \catcode`\{ = 1 diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index c0f9c7a9f..85610a1f8 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2010.11.17 18:14} +\newcontextversion{2010.11.18 19:20} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex index 6bf2f54d5..7a6b122bb 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2010.11.17 18:14} +\edef\contextversion{2010.11.18 19:20} %D For those who want to use this: diff --git a/tex/context/base/core-def.mkiv b/tex/context/base/core-def.mkiv index b0274c79e..ca672d8a5 100644 --- a/tex/context/base/core-def.mkiv +++ b/tex/context/base/core-def.mkiv @@ -26,12 +26,15 @@ % initialization order: +\ifdefined\firststagepreloadfonts \else \let\firststagepreloadfonts \relax \fi +\ifdefined\secondstagepreloadfonts \else \let\secondstagepreloadfonts\relax \fi + \appendtoks \showcontextbanner \to \everyjob \appendtoks \initializenewlinechar \to \everyjob \appendtoks \calculatecurrenttime \to \everyjob \appendtoks \loadsystemfiles \to \everyjob \appendtoks \loadoptionfile \to \everyjob % can load files ! -\appendtoks \preloadfonts \to \everyjob +\appendtoks \firststagepreloadfonts \to \everyjob \appendtoks \settopskip \to \everyjob \appendtoks \initializeMPgraphics \to \everyjob % after loading system files \appendtoks \initializemainlanguage \to \everyjob @@ -56,6 +59,8 @@ \prependtoks \lefttoright \to \everybeforeoutput +\appendtoks \secondstagepreloadfonts \to \everystarttext + % temporary here: \ifdefined\in \let\normalmathin \in \unexpanded\def\in {\mathortext\normalmathin \dospecialin } \else \let\in \dospecialin \fi diff --git a/tex/context/base/core-job.mkiv b/tex/context/base/core-job.mkiv index d0f4cd417..e7771e22c 100644 --- a/tex/context/base/core-job.mkiv +++ b/tex/context/base/core-job.mkiv @@ -65,8 +65,6 @@ \def\registerfileinfo[#1#2]#3% geen \showmessage ? {\writestatus\m!systems{#1#2 file #3 at line \the\inputlineno}} -\ifdefined\preloadfonts\else \let\preloadfonts\relax \fi - \def\loadallsystemfiles#1#2% {\ifx\@@svdirectory\empty \readsysfile{#1}{\showmessage\m!systems2{#1}}{#2}% diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index 91fc72e6b..a633fe259 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -62,7 +62,6 @@ local xheightdata = fonts.xheights fonts.ids = fontdata -- we keep this one for a while (as it is used in mk etc) - -- todo: give parameters at the lua end a metatable --~ function parameters(t,k) @@ -95,10 +94,22 @@ local nulldata = { xheight = 338952, -- 5 quad = 786432, -- 6 extraspace = 85459, -- 7 - }, } +function definers.resetnullfont() + -- resetting is needed because tikz misuses nullfont + local p = nulldata.parameters + p.slant = 0 -- 1 + p.space = 0 -- 2 + p.spacestretch = 0 -- 3 + p.spaceshrink = 0 -- 4 + p.xheight = 0 -- 5 + p.quad = 0 -- 6 + p.extraspace = 0 -- 7 + definers.resetnullfont = function() end +end + setmetatablekey(fontdata, "__index", function(t,k) return nulldata end) diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv index 7f8c374ca..16769ce63 100644 --- a/tex/context/base/font-ini.mkiv +++ b/tex/context/base/font-ini.mkiv @@ -2020,19 +2020,52 @@ % \appendtoks % \to \everysetupdocument +\fontdimen1\nullfont 0\scaledpoint +\fontdimen2\nullfont 256377\scaledpoint +\fontdimen3\nullfont 128188\scaledpoint +\fontdimen4\nullfont 85459\scaledpoint +\fontdimen5\nullfont 338952\scaledpoint +\fontdimen6\nullfont 786432\scaledpoint +\fontdimen7\nullfont 85459\scaledpoint + +\def\resetnullfont % this is needed because some macro packages (tikz) misuse \nullfont + {\dorecurse7{\fontdimen\recurselevel\nullfont\zeropoint}% + \ctxlua{fonts.definers.resetnullfont()}% in luatex 0.70 this will also do the previous + \globallet\resetnullfont\relax} + \newconditional\fontsareloaded -\def\preloadfonts % never called, needs a clean up +\def\preloaddefaultfonts + {\usetypescript[modern]% + \setuptypeface[modern]% + \showmessage\m!fonts6{\normalizedbodyfontsize\normalspace\fontstyle}} + +\def\resetpreloadfonts + {\global\let\firststagepreloadfonts \relax + \global\let\secondstagepreloadfonts\relax + \resetnullfont} + +\def\firststagepreloadfonts % see core-def.mkiv {\global\loadingfontsfalse - \ifconditional\fontsareloaded \else + \ifconditional\fontsareloaded + \resetpreloadfonts + \else \doifmodeelse {*nofonts} {\writestatus\m!fonts{latin modern fonts are not preloaded}} - {\writestatus\m!fonts{preloading latin modern fonts}% - \usetypescript[modern]% - \setuptypeface[modern]% - \showmessage\m!fonts6{\normalizedbodyfontsize\normalspace\fontstyle}}% + {\writestatus\m!fonts{preloading latin modern fonts (first stage)}% + \preloaddefaultfonts + \resetpreloadfonts}% + \fi} + +\def\secondstagepreloadfonts % see core-def.mkiv + {\global\loadingfontsfalse + \ifconditional\fontsareloaded + % nothing + \else + \writestatus\m!fonts{preloading latin modern fonts (second stage)}% + \preloaddefaultfonts \fi - \global\let\preloadfonts\relax} + \resetpreloadfonts} % maybe add this to \everystarttext % @@ -4048,16 +4081,6 @@ \def\dolookupgetkey #1{\ctxlua{tex.write(fonts.names.getlookupkey("#1"))}} \def\cleanfontname #1{\ctxlua{fonts.cleanname("#1")}} -% Experiment: - -\fontdimen1\nullfont 0\scaledpoint -\fontdimen2\nullfont 256377\scaledpoint -\fontdimen3\nullfont 128188\scaledpoint -\fontdimen4\nullfont 85459\scaledpoint -\fontdimen5\nullfont 338952\scaledpoint -\fontdimen6\nullfont 786432\scaledpoint -\fontdimen7\nullfont 85459\scaledpoint - \protect \endinput % \startluacode diff --git a/tex/context/base/mlib-pdf.lua b/tex/context/base/mlib-pdf.lua index 30db3f52c..5ca554292 100644 --- a/tex/context/base/mlib-pdf.lua +++ b/tex/context/base/mlib-pdf.lua @@ -134,16 +134,13 @@ local bend_tolerance = 131/65536 local rx, sx, sy, ry, tx, ty, divider = 1, 0, 0, 1, 0, 0, 1 +local pen_info = mplib.pen_info + local function pen_characteristics(object) - if mplib.pen_info then - local t = mplib.pen_info(object) - rx, ry, sx, sy, tx, ty = t.rx, t.ry, t.sx, t.sy, t.tx, t.ty - divider = sx*sy - rx*ry - return not (sx==1 and rx==0 and ry==0 and sy==1 and tx==0 and ty==0), t.width - else - rx, sx, sy, ry, tx, ty, divider = 1, 0, 0, 1, 0, 0, 1 - return false, 1 - end + local t = pen_info(object) + rx, ry, sx, sy, tx, ty = t.rx, t.ry, t.sx, t.sy, t.tx, t.ty + divider = sx*sy - rx*ry + return not (sx==1 and rx==0 and ry==0 and sy==1 and tx==0 and ty==0), t.width end local function mpconcat(px, py) -- no tx, ty here / we can move this one inline if needed diff --git a/tex/context/base/mult-cld.lua b/tex/context/base/mult-cld.lua index 70c190865..2a2af77ae 100644 --- a/tex/context/base/mult-cld.lua +++ b/tex/context/base/mult-cld.lua @@ -80,6 +80,7 @@ context._flush_ = _flush_ local catcodestack = { } local currentcatcodes = ctxcatcodes +local contentcatcodes = ctxcatcodes local catcodes = { ctx = ctxcatcodes, ctxcatcodes = ctxcatcodes, context = ctxcatcodes, @@ -93,19 +94,23 @@ local catcodes = { function context.pushcatcodes(c) insert(catcodestack,currentcatcodes) currentcatcodes = (c and catcodes[c] or tonumber(c)) or currentcatcodes + contentcatcodes = currentcatcodes end function context.popcatcodes() currentcatcodes = remove(catcodestack) or currentcatcodes + contentcatcodes = currentcatcodes end function context.unprotect() insert(catcodestack,currentcatcodes) currentcatcodes = prtcatcodes + contentcatcodes = currentcatcodes end function context.protect() currentcatcodes = remove(catcodestack) or currentcatcodes + contentcatcodes = currentcatcodes end function tex.fprint(...) -- goodie @@ -113,89 +118,87 @@ function tex.fprint(...) -- goodie end local function writer(command,first,...) ---~ if first == nil then -- we can move the first test to the caller (twice: direct and boolean) ---~ flush(currentcatcodes,command) ---~ else - local t = { first, ... } - flush(currentcatcodes,command) -- todo: ctx|prt|texcatcodes - local direct = false - for i=1,#t do - local ti = t[i] - local typ = type(ti) - if direct then - if typ == "string" or typ == "number" then - flush(currentcatcodes,ti) - else - trace_context("error: invalid use of direct in '%s', only strings and numbers can be flushed directly, not '%s'",command,typ) - end - direct = false - elseif ti == nil then - -- nothing - elseif typ == "string" then - if ti == "" then - flush(currentcatcodes,"{}") - else - flush(currentcatcodes,"{",ti,"}") - end - elseif typ == "number" then + local t = { first, ... } + flush(currentcatcodes,command) -- todo: ctx|prt|texcatcodes + local direct = false + for i=1,#t do + local ti = t[i] + local typ = type(ti) + if direct then + if typ == "string" or typ == "number" then + flush(currentcatcodes,ti) + else + trace_context("error: invalid use of direct in '%s', only strings and numbers can be flushed directly, not '%s'",command,typ) + end + direct = false + elseif ti == nil then + -- nothing + elseif ti == "" then + flush(currentcatcodes,"{}") + elseif typ == "string" or typ == "number" then + if currentcatcodes == contentcatcodes then flush(currentcatcodes,"{",ti,"}") - elseif typ == "table" then - local tn = #ti - if tn == 0 then - local done = false - for k, v in next, ti do - if done then - if v == "" then - flush(currentcatcodes,",",k,'=') - else - flush(currentcatcodes,",",k,'=',v) - end + else + flush(currentcatcodes,"{") + flush(contentcatcodes,ti) + flush(currentcatcodes,"}") + end + elseif typ == "table" then + local tn = #ti + if tn == 0 then + local done = false + for k, v in next, ti do + if done then + if v == "" then + flush(currentcatcodes,",",k,'=') else - if v == "" then - flush(currentcatcodes,"[",k,'=') - else - flush(currentcatcodes,"[",k,'=',v) - end - done = true + flush(currentcatcodes,",",k,'=',v) end - end - flush(currentcatcodes,"]") - elseif tn == 1 then -- some 20% faster than the next loop - local tj = ti[1] - if type(tj) == "function" then - flush(currentcatcodes,"[\\mkivflush{",_store_(tj),"}]") else - flush(currentcatcodes,"[",tj,"]") - end - else -- is concat really faster than flushes here? probably needed anyway (print artifacts) - for j=1,tn do - local tj = ti[j] - if type(tj) == "function" then - ti[j] = "\\mkivflush{" .. _store_(tj) .. "}" + if v == "" then + flush(currentcatcodes,"[",k,'=') + else + flush(currentcatcodes,"[",k,'=',v) end + done = true end - flush(currentcatcodes,"[",concat(ti,","),"]") end - elseif typ == "function" then - flush(currentcatcodes,"{\\mkivflush{",_store_(ti),"}}") -- todo: ctx|prt|texcatcodes - elseif typ == "boolean" then - if ti then - flush(currentcatcodes,"^^M") + flush(currentcatcodes,"]") + elseif tn == 1 then -- some 20% faster than the next loop + local tj = ti[1] + if type(tj) == "function" then + flush(currentcatcodes,"[\\mkivflush{",_store_(tj),"}]") else - direct = true + flush(currentcatcodes,"[",tj,"]") + end + else -- is concat really faster than flushes here? probably needed anyway (print artifacts) + for j=1,tn do + local tj = ti[j] + if type(tj) == "function" then + ti[j] = "\\mkivflush{" .. _store_(tj) .. "}" + end end - elseif typ == "thread" then - trace_context("coroutines not supported as we cannot yield across boundaries") - elseif isnode(ti) then - writenode(ti) + flush(currentcatcodes,"[",concat(ti,","),"]") + end + elseif typ == "function" then + flush(currentcatcodes,"{\\mkivflush{",_store_(ti),"}}") -- todo: ctx|prt|texcatcodes + elseif typ == "boolean" then + if ti then + flush(ctxcatcodes,"^^M") else - trace_context("error: '%s' gets a weird argument '%s'",command,tostring(ti)) + direct = true end + elseif typ == "thread" then + trace_context("coroutines not supported as we cannot yield across boundaries") + elseif isnode(ti) then + writenode(ti) + else + trace_context("error: '%s' gets a weird argument '%s'",command,tostring(ti)) end - if direct then - trace_context("error: direct flushing used in '%s' without following argument",command) - end ---~ end + end + if direct then + trace_context("error: direct flushing used in '%s' without following argument",command) + end end local generics = { } context.generics = generics @@ -286,6 +289,18 @@ local tracedflush = function(...) normalflush(...) local t = { ... } t[1] = "f : " -- replaces the catcode + for i=2,#t do + local ti = t[i] + local tt = type(ti) + if tt == "string" then + -- ok + elseif tt == "number" then + -- ok + else + t[i] = format("<%s>",tostring(ti)) + end + -- currenttrace(format("%02i: %s",i-1,tostring(t[i]))) + end currenttrace(concat(t)) end @@ -380,9 +395,9 @@ function context.egroup() context("}") end -function context.verbatim(...) - flush(vrbcatcodes,...) -end +--~ function context.verbatim(...) +--~ flush(vrbcatcodes,...) +--~ end -- context.delayed @@ -440,6 +455,28 @@ end setmetatable(nested, { __index = indexer, __call = caller } ) +-- verbatim + +local verbatim = { } context.verbatim = verbatim + +local function indexer(t,k) + local command = context[k] + local f = function(...) + local savedcatcodes = contentcatcodes + contentcatcodes = vrbcatcodes + command(...) + contentcatcodes = savedcatcodes + end + t[k] = f + return f +end + +local function caller(t,...) + flush(vrbcatcodes,...) +end + +setmetatable(verbatim, { __index = indexer, __call = caller } ) + -- metafun local metafun = { } context.metafun = metafun diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index c3eb9b2ee..dc682dc78 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 : 11/17/10 18:14:05 +-- merge date : 11/18/10 19:20:30 do -- begin closure to overcome local limits and interference |