diff options
Diffstat (limited to 'tex')
46 files changed, 1428 insertions, 322 deletions
diff --git a/tex/context/base/attr-ini.lua b/tex/context/base/attr-ini.lua index b8cf7e92c..b1a27086e 100644 --- a/tex/context/base/attr-ini.lua +++ b/tex/context/base/attr-ini.lua @@ -418,6 +418,7 @@ colors.attribute = 0 colors.selector = 0 colors.default = 1 colors.main = nil +colors.triggering = true -- This is a compromis between speed and simplicity. We used to store the -- values and data in one array, which made in neccessary to store the @@ -589,7 +590,6 @@ end shipouts.plugins.color = { namespace = colors, - triggering = true, initializer = states.initialize, finalizer = states.finalize, processor = states.selective, @@ -607,6 +607,7 @@ transparencies.data = transparencies.data or { } transparencies.values = transparencies.values or { } transparencies.enabled = false transparencies.template = "%s:%s" +transparencies.triggering = true input.storage.register(false, "transparencies/registered", transparencies.registered, "transparencies.registered") input.storage.register(false, "transparencies/values", transparencies.values, "transparencies.values") @@ -656,7 +657,6 @@ end shipouts.plugins.transparency = { namespace = transparencies, - triggering = true, initializer = states.initialize, finalizer = states.finalize , processor = states.process , @@ -741,26 +741,33 @@ function effects.register(effect,stretch,rulethickness) return effects.registered[stamp] end +--~ backends.pdf.effects = { +--~ normal = 1, +--~ inner = 1, +--~ outer = 2, +--~ both = 3, +--~ hidden = 4, +--~ } backends.pdf.effects = { - normal = 1, - inner = 1, - outer = 2, - both = 3, - hidden = 4, + normal = 0, + inner = 0, + outer = 1, + both = 2, + hidden = 3, } function effects.reference(effect,stretch,rulethickness) -- will move, test code, we will develop a proper model for that - effect = backends.pdf.effects[effects] or backends.pdf.effects['normal'] - if stretch > 0 then - stretch = stretch .. " w " - else - stretch = "" - end + effect = backends.pdf.effects[effect] or backends.pdf.effects['normal'] if rulethickness > 0 then - rulethickness = number.dimenfactors["bp"]*rulethickness.. " Tc " + rulethickness = number.dimenfactors["bp"]*rulethickness .. " w " else rulethickness = "" end + if stretch > 0 then + stretch = stretch.. " Tc " + else + stretch = "" + end return backends.pdf.literal(string.format("%s%s%s Tr",stretch,rulethickness,effect)) -- watch order end diff --git a/tex/context/base/attr-ini.tex b/tex/context/base/attr-ini.tex index ae7cf019e..80a9e66cb 100644 --- a/tex/context/base/attr-ini.tex +++ b/tex/context/base/attr-ini.tex @@ -214,8 +214,23 @@ \def\doattributedcopy {\afterassignment\dodoattributedcopy\attributeboxcount} \def\doattributedbox {\afterassignment\dodoattributedbox \attributeboxcount} -\def\dodoattributedcopy{\startinheritattributes\ifvbox\attributeboxcount\vbox\else\hbox\fi{\unhcopy\attributeboxcount}\stopinheritattributes} -\def\dodoattributedbox {\startinheritattributes\ifvbox\attributeboxcount\vbox\else\hbox\fi{\unhbox \attributeboxcount}\stopinheritattributes} +\def\dodoattributedcopy + {\startinheritattributes + \ifvbox\attributeboxcount + \vbox{\unvcopy\attributeboxcount}% + \else + \hbox{\unhcopy\attributeboxcount}% + \fi + \stopinheritattributes} + +\def\dodoattributedbox + {\startinheritattributes + \ifvbox\attributeboxcount + \vbox{\unvbox\attributeboxcount}% + \else + \hbox{\unhbox\attributeboxcount}% + \fi + \stopinheritattributes} \def\enableattributeinheritance {\ctxlua{nodes.triggering=true}% diff --git a/tex/context/base/char-cmp.lua b/tex/context/base/char-cmp.lua index 42f66143c..412f1a073 100644 --- a/tex/context/base/char-cmp.lua +++ b/tex/context/base/char-cmp.lua @@ -258,3 +258,5 @@ characters.texligatures = { { 'hyphen', 'emdash' } } } + +--~ U+2019: right single quotation mark / quoteright diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 74d4173a3..0bf3c2ec6 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -25,6 +25,18 @@ \unprotect +% \appendtoks +% \ctxlua{ +% table.insert(input.stop_actions, function() +% tex.sprint(tex.ctxcatcodes,"\\immediatewriteutilitytua{end}") +% tex.sprint(tex.ctxcatcodes,"\\immediatewriteutilitytua{}") +% tex.sprint(tex.ctxcatcodes,"\\immediatewriteutilitytua{end of utility file}") +% end) +% }% +% \to \everyopenutilities + +\def\writestatus#1#2{\ctxlua{ctx.writestatus(\!!bs#1\!!es,\!!bs#2\!!es)}} + \ifx\clearmarks\undefined \def\clearmarks {\begingroup\afterassignment\doclearmarks\scratchcounter} \def\doclearmarks{\normalmarks\scratchcounter{}\endgroup} @@ -53,28 +65,8 @@ %D For the moment we report some statistics. Later this will become an option, %D but for now we need this information. -\appendtoks - \writestatus\m!lua{used config path - \ctxlua{tex.print(caches.configpath(texmf.instance))}}% - \writestatus\m!lua{used cache path - \ctxlua{tex.print(caches.path)}}% - \writestatus\m!lua{modules/dumps/instances - \ctxlua{tex.print((status.luabytecodes-500).."/"..input.storage.done.."/"..status.luastates)}}% - \writestatus\m!lua{input load time - \ctxlua{input.loadtime(texmf.instance)} seconds}% - \writestatus\m!lua{fonts load time - \ctxlua{input.loadtime(fonts)} seconds}% - \writestatus\m!lua{xml load time - \ctxlua{input.loadtime(lxml)} seconds}% - \writestatus\m!lua{mps conversion time - \ctxlua{input.loadtime(mptopdf)} seconds}% - \writestatus\m!lua{node processing time - \ctxlua{input.loadtime(nodes)} seconds (including kernel)}% - \writestatus\m!lua{kernel processing time - \ctxlua{input.loadtime(kernel)} seconds}% - \writestatus\m!lua{attribute processing time - \ctxlua{input.loadtime(attributes)} seconds}% - \writestatus\m!lua{language load time - \ctxlua{input.loadtime(languages)} seconds (n=\ctxlua{tex.print(languages.hyphenation.n())})}% - \writestatus\m!lua{loaded fonts - \ctxlua{tex.print(fonts.logger.report())}}% - \writestatus\m!lua{loaded patterns - \ctxlua{tex.print(languages.logger.report())}}% - \writestatus\m!lua{current memory usage - \ctxlua{tex.print(status.luastate_bytes)} bytes}% - \writestatus\m!lua{cleaned up reserved nodes - \ctxlua{ - tex.print(string.format("\letterpercent s nodes, \letterpercent s lists (of \letterpercent s)", nodes.cleanup_reserved(\number\topofboxstack))) - }}% -\to \everybye - % \appendtoks -% \ctxlua{nodes.check_for_leaks()}% +% \ctxlua{ctx.show_statistics()}% % \to \everygoodbye \appendtoks @@ -161,17 +153,3 @@ % \expanded{\defineactivecharacter \number"2000E} {\textdir TRT\relax} % \expanded{\defineactivecharacter \number"2000F} {\textdir TLT\relax} - -\startluacode - local ss = { } - function ctx.writestatus(a,b) - local s = ss[a] - if not ss[a] then - s = a:rpadd(15) .. ":" - ss[a] = s - end - texio.write_nl(s .. b) - end -\stopluacode - -\def\writestatus#1#2{\ctxlua{ctx.writestatus([[#1]],[[#2]])}} diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 5cc33d0f2..0193e847a 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{2007.12.18 19:11} +\newcontextversion{2007.12.31 11:54} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new @@ -60,10 +60,11 @@ {\endgraf \ifdim\pagetotal>\pagegoal \ifdim\dimexpr\pagetotal-\pageshrink\relax>\pagegoal - \penalty\outputpenalty + \goodbreak % \penalty0 \else \page \fi + \else \fi} % \setupcaption [figure] [align=flushleft] diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex index 938eb9801..047b5c9e0 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -42,7 +42,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2007.12.18 19:11} +\edef\contextversion{2007.12.31 11:54} %D For those who want to use this: diff --git a/tex/context/base/core-box.tex b/tex/context/base/core-box.tex index 16a894151..e3e2d6330 100644 --- a/tex/context/base/core-box.tex +++ b/tex/context/base/core-box.tex @@ -646,21 +646,21 @@ [\v!middle] [\c!corner=\v!middle,\c!location=\v!middle] -\definelayerpreset - [\v!middle\v!top] - [\c!location=\v!bottom,\c!hoffset=.5\layerwidth] +% \definelayerpreset +% [\v!middle\v!top] +% [\c!location=\v!bottom,\c!hoffset=.5\layerwidth] -\definelayerpreset - [\v!middle\v!bottom] - [\c!location=\v!top,\c!hoffset=.5\layerwidth,\c!voffset=\layerheight] +% \definelayerpreset +% [\v!middle\v!bottom] +% [\c!location=\v!top,\c!hoffset=.5\layerwidth,\c!voffset=\layerheight] -\definelayerpreset - [\v!middle\v!left] - [\c!location=\v!right,\c!voffset=.5\layerwidth] +% \definelayerpreset +% [\v!middle\v!left] +% [\c!location=\v!right,\c!voffset=.5\layerheight] -\definelayerpreset - [\v!middle\v!right] - [\c!location=\v!left,\c!hoffset=\layerwidth,\c!voffset=.5\layerheight] +% \definelayerpreset +% [\v!middle\v!right] +% [\c!location=\v!left,\c!hoffset=\layerwidth,\c!voffset=.5\layerheight] \definelayerpreset [\v!middle\v!top] @@ -672,7 +672,7 @@ \definelayerpreset [\v!middle\v!left] - [\c!location=\v!right,\c!corner=\v!left,\c!dy=.5\layerwidth] + [\c!location=\v!right,\c!corner=\v!left,\c!dy=.5\layerheight] \definelayerpreset [\v!middle\v!right] @@ -748,9 +748,9 @@ \setvalue{\??ab\??ab gr}{\baselinerightbox} \setvalue{\??ab\??ab \v!line }{\baselinemiddlebox} % \v!grid is taken -\setvalue{\??ab\??ab \v!line\v!left }{\baselineleftbox} +\setvalue{\??ab\??ab \v!line\v!left }{\baselineleftbox} \setvalue{\??ab\??ab \v!line\v!middle}{\baselinemiddlebox} -\setvalue{\??ab\??ab \v!line\v!right}{\baselinerightbox} +\setvalue{\??ab\??ab \v!line\v!right }{\baselinerightbox} \def\offsetbox {\dodoubleempty\dooffsetbox[]} diff --git a/tex/context/base/core-fig.tex b/tex/context/base/core-fig.tex index 9a2eb8474..be614d194 100644 --- a/tex/context/base/core-fig.tex +++ b/tex/context/base/core-fig.tex @@ -913,8 +913,8 @@ \checkfilename\@@efcache \ifnum\kindoffile=\plusone \let\wantedfigurepath\@@efcache % root related path - \else - \edef\wantedfigurepath{\wantedconversionpath/\@@efcache}% + \else % brrr + \edef\wantedfigurepath{\@@efcache,\wantedconversionpath/\@@efcache}% in case of explicit paths, what a mess \fi \fi \let\wantedfiguretype \empty diff --git a/tex/context/base/core-not.tex b/tex/context/base/core-not.tex index fa86a9847..500a28893 100644 --- a/tex/context/base/core-not.tex +++ b/tex/context/base/core-not.tex @@ -1192,7 +1192,6 @@ \newdimen\totalnoteheight - \def\doaddtototalnoteheight#1% {\ifdim\ht#1>\zeropoint \advance\totalnoteheight\ht #1% diff --git a/tex/context/base/core-spa.lua b/tex/context/base/core-spa.lua index c6827e1c2..4942c7ae1 100644 --- a/tex/context/base/core-spa.lua +++ b/tex/context/base/core-spa.lua @@ -10,6 +10,141 @@ if not modules then modules = { } end modules ['core-spa'] = { -- vertical space handler +vspacing = vspacing or { } + +vspacing.categories = { + [0] = 'discard', + [1] = 'largest', + [2] = 'force' , + [3] = 'penalty', + [4] = 'add' , + [5] = 'disable', + [6] = 'nowhite', + [7] = 'goback', +} + +function vspacing.tocategories(str) + local t = { } + for s in str:gmatch("[^, ]") do + local n = tonumber(s) + if n then + t[vspacing.categories[n]] = true + else + t[b] = true + end + end + return t +end + +function vspacing.tocategory(str) + if type(str) == "string" then + return set.tonumber(vspacing.tocategories(str)) + else + return set.tonumber({ [vspacing.categories[str]] = true }) + end +end + +function vspacing.tostring(t) + local str = nil + for k,v in pairs(vspacing.categories) do + if t[v] then + if str then str = str .. " +" .. v else str = "+" .. v end + else + if str then str = str .. " -" .. v else str = "-" .. v end + end + end + return str or "" +end + +do + + local map = { } + local skip = { } + + vspacing.fixed = false + + function vspacing.analyse(str) + local category, order, penalty, command, fixed = { }, 0, 0, { }, vspacing.fixed + local function analyse(str) + for sign,amount,_,keyword in str:gmatch("([+%-]*)([%.%d]*)([%*]*)([^,%* ]+)") do + if keyword then + if map[keyword] then + analyse(map[keyword]) + elseif keyword == "fixed" then + fixed = true + elseif keyword == "flexible" then + fixed = false + else + local a, b = keyword:match("(.-):(.-)$") + if a and b then + if a == "category" then + -- is a set + local n = tonumber(b) + if n then + category[vspacing.categories[n]] = true + else + category[b] = true + end + elseif a == "order" then + -- last one counts + order = tonumber(b) or 0 + elseif a == "penalty" then + -- last one counts + penalty = tonumber(b) or 0 + elseif a == "skip" then + -- last one counts + command[#command+1] = { 1, tonumber[b] } + end + else + if amount == "" then amount = 1 end + if sign == "-" then amount = -amount end + if skip[keyword] then + command[#command+1] = { amount, skip[keyword][1], skip[keyword][2] } + end + end + end + end + end + end + analyse(str) + category = set.tonumber(category) + local p = print + p("\\startblankhandling") + if category > 0 then + p(("\\setblankcategory{%s}"):format(category)) + end + if order > 0 then + p(("\\setblankorder{%s}"):format(order)) + end + if penalty > 0 then + p(("\\setblankpenalty{%s}"):format(penalty)) + end + for k,v in ipairs(command) do + p(("\\addblankskip{%s}{%s}{%s}"):format(v[1],v[2],v[3])) + end + if fixed then + p("\\fixedblankskip") + else + p("\\flexibleblankskip") + end + p("\\stopblankhandling") + end + + function vspacing.setmap(from,to) + map[from] = to + end + + function vspacing.setskip(key,value,grid) + if value ~= "" then + if grid == "" then grid = value end + skip[key] = { value, grid } + end + end + +end + +-- implementation + nodes.snapvalues = { } function nodes.setsnapvalue(n,ht,dp) @@ -31,13 +166,16 @@ do trace_list = { } end local function trace_skip(str,sc,so,sp,data) - trace_list[#trace_list+1] = string.format("%s %8s %8s %8s %8s", str:padd(8), data.spec.width, sc or "-", so or "-", sp or "-") + trace_list[#trace_list+1] = string.format("%s %10s %10s %10s %10s", str:padd(8), (data.spec and data.spec.width) or "?", sc or "-", so or "-", sp or "-") + end + local function trace_info(...) + trace_list[#trace_list+1] = table.concat({...}," ") end local function trace_done(str,data) if data.id == penalty then - trace_list[#trace_list+1] = string.format("%s %8s penalty", str:padd(8), data.penalty) + trace_list[#trace_list+1] = string.format("%s %10s penalty", str:padd(8), data.penalty) else - trace_list[#trace_list+1] = string.format("%s %8s glue", str:padd(8), data.spec.width) + trace_list[#trace_list+1] = string.format("%s %10s glue", str:padd(8), (data.spec and data.spec.width) or "?") end end local function show_tracing() @@ -54,13 +192,55 @@ do -- alignment box begin_of_par vmode_par hmode_par insert penalty before_display after_display + local user_skip = 0 + local line_skip = 1 + local baseline_skip = 2 + local par_skip = 3 + local above_display_skip = 4 + local below_display_skip = 5 + local above_display_short_skip = 6 + local below_display_short_skip = 7 + local left_skip_code = 8 + local right_skip_code = 9 + local top_skip_code = 10 + local split_top_skip_code = 11 + local tab_skip_code = 12 + local space_skip_code = 13 + local xspace_skip_code = 14 + local par_fill_skip_code = 15 + local thin_mu_skip_code = 16 + local med_mu_skip_code = 17 + local thick_mu_skip_code = 18 + + local skips = { + [ 0] = "user_skip", + [ 1] = "line_skip", + [ 2] = "baseline_skip", + [ 3] = "par_skip", + [ 4] = "above_display_skip", + [ 5] = "below_display_skip", + [ 6] = "above_display_short_skip", + [ 7] = "below_display_short_skip", + [ 8] = "left_skip_code", + [ 9] = "right_skip_code", + [10] = "top_skip_code", + [11] = "split_top_skip_code", + [12] = "tab_skip_code", + [13] = "space_skip_code", + [14] = "xspace_skip_code", + [15] = "par_fill_skip_code", + [16] = "thin_mu_skip_code", + [17] = "med_mu_skip_code", + [18] = "thick_mu_skip_code", + } + function nodes.is_display_math(head) local n = head.prev while n do local id = n.id if id == penalty then elseif id == glue then - if n.subtype == 6 then + if n.subtype == 6 then -- above_display_short_skip return true end else @@ -73,7 +253,7 @@ do local id = n.id if id == penalty then elseif id == glue then - if n.subtype == 7 then + if n.subtype == 7 then -- below_display_short_skip return true end else @@ -84,29 +264,17 @@ do return false end - -- helpers - - -- local free = node.free - - local line_skip = 1 - local baseline_skip = 2 - local par_skip = 3 - local above_display_skip = 4 - local below_display_skip = 5 - local above_display_short_skip = 6 - local below_display_short_skip = 7 - local top_skip = 8 - local split_top_skip = 9 - local function collapser(head,where) if head and head.next then +node.slide(head) -- hm, why input.starttiming(nodes) local trace = nodes.trace_collapse local current, tail = head, nil local glue_order, glue_data = 0, nil local penalty_order, penalty_data, natural_penalty = 0, nil, nil if trace then reset_tracing() end - local parskip, ignore_parskip = nil, false + local parskip, ignore_parskip, ignore_following, ignore_whitespace = nil, false, false, false + if trace then trace_info("start analyzing") end while current do local id = current.id if id == glue and current.subtype == 0 then -- todo, other subtypes, like math @@ -121,60 +289,78 @@ do if trace then trace_skip("natural",sc,so,sp,current) end glue_order, glue_data = 0, nil current = current.next - elseif sc < 1 or sc > 4 then -- 0 = discard, > 3 = unsupported - if trace then trace_skip("ignore",sc,so,sp,current) end - head, current = nodes.remove(head, current, true) else - if sp then - if not penalty_data then - penalty_data = sp - elseif penalty_order < so then - penalty_order, penalty_data = so, sp - elseif penalty_order == so and sp > penalty_data then - penalty_data = sp - end + local sct = set.totable(sc) + if trace then trace_info("catset",vspacing.tostring(sct)) end + if sct.disable then + ignore_following = true + end + if sct.nowhite then + ignore_whitespace = true end - if not glue_data then - if trace then trace_skip("assign",sc,so,sp,current) end - glue_order = so - head, current, glue_data = nodes.remove(head, current) - elseif glue_order < so then - if trace then trace_skip("force",sc,so,sp,current) end - glue_order = so - node.free(glue_data) - head, current, glue_data = nodes.remove(head, current) - elseif glue_order == so then - if sc == 1 then - if current.spec.width > glue_data.spec.width then - if trace then trace_skip("larger",sc,so,sp,current) end + if sct.discard then + if trace then trace_skip("ignore",sc,so,sp,current) end + head, current = nodes.remove(head, current, true) + else + if sp then + if not penalty_data then + penalty_data = sp + elseif penalty_order < so then + penalty_order, penalty_data = so, sp + elseif penalty_order == so and sp > penalty_data then + penalty_data = sp + end + end + if ignore_following then + if trace then trace_skip("disabled",sc,so,sp,current) end + head, current = nodes.remove(head, current, true) + elseif not glue_data then + if trace then trace_skip("assign",sc,so,sp,current) end + glue_order = so + head, current, glue_data = nodes.remove(head, current) + elseif glue_order < so then + if trace then trace_skip("force",sc,so,sp,current) end + glue_order = so + node.free(glue_data) + head, current, glue_data = nodes.remove(head, current) + elseif glue_order == so then + if sct.largest then + if current.spec.width > glue_data.spec.width then + if trace then trace_skip("larger",sc,so,sp,current) end + node.free(glue_data) + head, current, glue_data = nodes.remove(head, current) + else + if trace then trace_skip("smaller",sc,so,sp,current) end + head, current = nodes.remove(head, current, true) + end + elseif sct.goback then + if trace then trace_skip("force",sc,so,sp,current) end + node.free(glue_data) + head, current, glue_data = nodes.remove(head, current) + elseif sct.force then + -- todo: inject kern + if trace then trace_skip("force",sc,so,sp,current) end node.free(glue_data) head, current, glue_data = nodes.remove(head, current) + elseif sct.penalty then + if trace then trace_skip("penalty",sc,so,sp,current) end + node.free(glue_data) + head, current = nodes.remove(head, current, true) + elseif sct.add then + if trace then trace_skip("add",sc,so,sp,current) end + local old, new = glue_data.spec, current.spec + old.width = old.width + new.width + old.stretch = old.stretch + new.stretch + old.shrink = old.shrink + new.shrink + head, current = nodes.remove(head, current, true) else - if trace then trace_skip("smaller",sc,so,sp,current) end + if trace then trace_skip("unknown",sc,so,sp,current) end head, current = nodes.remove(head, current, true) end - elseif sc == 2 then - if trace then trace_skip("force",sc,so,sp,current) end - node.free(glue_data) - head, current, glue_data = nodes.remove(head, current) - elseif sc == 3 then - if trace then trace_skip("penalty",sc,so,sp,current) end - node.free(glue_data) - head, current = nodes.remove(head, current, true) - elseif sc == 4 then - if trace then trace_skip("add",sc,so,sp,current) end - local old, new = glue_data.spec, current.spec - old.width = old.width + new.width - old.stretch = old.stretch + new.stretch - old.shrink = old.shrink + new.shrink - head, current = nodes.remove(head, current, true) else if trace then trace_skip("unknown",sc,so,sp,current) end head, current = nodes.remove(head, current, true) end - else - if trace then trace_skip("unknown",sc,so,sp,current) end - head, current = nodes.remove(head, current, true) end end -- elseif id == penalty then @@ -190,6 +376,8 @@ do -- else -- current = current.next -- end + elseif ignore_whitespace then + head, current = nodes.remove(head, current, true) else current = current.next end @@ -197,6 +385,7 @@ do parskip = current current = current.next else + if trace then trace_info(node.type(current)) end if glue_data then head, current = nodes.before(head,current,glue_data) if trace then trace_done("before",glue_data) end @@ -218,30 +407,34 @@ do end current = current.next end - tail = current + tail = current -- WRONG ! ! ! ! end + if trace then trace_info("stop analyzing") end -- if natural_penalty and (not penalty_data or natural_penalty > penalty_data) then -- penalty_data = natural_penalty -- end + if trace then trace_info("start flushing") end if parskip and glue_data then - if parskip.spec.width > glue_data.spec.width then - glue_data.spec.width = parskip.spec.width + local ps, gs = parskip.spec, glue_data.spec + if ps and gs and ps.width > gs.width then + gs.width = ps.width + head, current = nodes.remove(head, parskip, true) end - head, current = nodes.remove(head, parskip, true) + end + if glue_data then + if trace then trace_done("first",glue_data) end + head, tail = nodes.after(head,tail,glue_data) end if penalty_data then local p = nodes.penalty(penalty_data) - if trace then trace_done("before",p) end + if trace then trace_done("second",p) end head, head = nodes.before(head,head,p) end - if glue_data then - if trace then trace_done("after",glue_data) end - head, tail = nodes.after(head,tail,glue_data) - end + if trace then trace_info("stop flushing") end if trace then show_tracing() end input.stoptiming(nodes) end - return head + return head, true end local head, tail = nil, nil @@ -260,6 +453,7 @@ do function nodes.handle_page_spacing(t, where) -- we need to add the latest t too, else we miss skips and such if t then +-- node.slide(t) -- redunant if t.next then local tt = node.slide(t) local id = tt.id @@ -298,6 +492,7 @@ do function nodes.handle_vbox_spacing(t) if t and t.next then +node.slide(t) return collapser(t,'whole') else return t diff --git a/tex/context/base/core-spa.mkiv b/tex/context/base/core-spa.mkiv index 4fcad6b31..20a172310 100644 --- a/tex/context/base/core-spa.mkiv +++ b/tex/context/base/core-spa.mkiv @@ -22,6 +22,7 @@ % 2 == force even if smaller % 3 == only take penalty component % 4 == add to existing skip +% 5 == ignore following skips (== disable) % penalty: % @@ -228,6 +229,82 @@ % \setbreakpoints[compound] +% experimental code, not yet interfaced: + +% category: +% 0 == discard discard +% 1 == only if larger largest +% 2 == force even if smaller force +% 3 == only take penalty component penalty +% 4 == add to existing skip add +% 5 == disable (ignore following) disable +% 6 == kill whitespace nowhite +% 7 == discard previous goback +% +% penalty: larger wins +% order: larger wins +% category:2,order:5,penalty:10000,skip:value|kw +% +% always -- obsolete +% none -- obsolete +% outer -- obsolete +% reset -- obsolete +% \defineblankmethod [\v!joinedup] {\ifvmode\nointerlineskip\fi} + +% todo, in grid mode: vspacing.fixed = false + +\def\startblankhandling{\begingroup \blankskip \zeropoint} +\def\stopblankhandling {\vskip \blankskip \endgroup} +\def\setblankcategory#1{\dosetattribute{skip-category}{#1}} +\def\setblankorder #1{\dosetattribute{skip-order}{#1}} +\def\setblankpenalty #1{\dosetattribute{skip-penalty}{#1}} +\def\addblankskip#1#2#3{\advance\blankskip#1\dimexpr\ifgridsnapping#3\else#2\fi\relax} +\def\fixedblankskip {\blankskip1\blankskip} +\def\flexibleblankskip {\blankskip1\blankskip\!!plus \skipgluefactor\blankskip\!!minus\skipgluefactor\blankskip} + +\def\definevspacingamount + {\dotripleempty\dodefinevspacingamount} + +\def\dodefinevspacingamount[#1][#2][#3]% + {\ctxlua{vspacing.setskip("#1","\detokenize{#2}","\detokenize{#3}")}} + +\def\definevspacing + {\dodoubleempty\dodefinevspacing} + +\def\dodefinevspacing[#1][#2]% + {\ctxlua{vspacing.setmap("#1","\detokenize{#2}")}} + +\def\vspacing + {\dosingleempty\dovspacing} + +\def\dovspacing[#1]% + {\ctxlua{vspacing.analyse("\iffirstargument#1\else default\fi")}} + +\definevspacingamount[big] [\bigskipamount] [\openlineheight] +\definevspacingamount[medium] [\medskipamount] [.50\openlineheight] +\definevspacingamount[small] [\smallskipamount][.25\openlineheight] +\definevspacingamount[line] [\openlineheight] [\openlineheight] +\definevspacingamount[formula][\medskipamount] [.50\openlineheight] +\definevspacingamount[white] [\parskip] [\openlineheight] + +\definevspacing[halfline][.5*line] +\definevspacing[weak] [order:0] +\definevspacing[strong] [order:100] +\definevspacing[samepage][penalty:10000] +\definevspacing[force] [category:2] +\definevspacing[disable] [category:5] +\definevspacing[nowhite] [category:6] +\definevspacing[goback] [category:7] +\definevspacing[always] [category:0] + +\definevspacing[default][big] + +\definevspacing[whatever][4*big] +\vspacing[2*big,-medium,-3*small,whatever,halfline,order:10,category:4,strong,samepage] +\vspacing[2*big,category:disable] +\vspacing[2*big,disable] +\vspacing[2*big,back] + \protect \endinput \starttext diff --git a/tex/context/base/core-spa.tex b/tex/context/base/core-spa.tex index 561c0844e..6d606dce9 100644 --- a/tex/context/base/core-spa.tex +++ b/tex/context/base/core-spa.tex @@ -245,6 +245,8 @@ % \type{\normalskipamount} equals the current baseline % distance. +% \lineskiplimit = -\maxdimen -> freezes baselineskip + % can be conditionals \newif\ifblanknowhite \blanknowhitefalse @@ -507,7 +509,7 @@ \defineblankmethod [\v!none] {\global\blankresettrue} \defineblankmethod [\v!joinedup] {\ifvmode\nointerlineskip\fi} -\defineblankmethod [\v!always] {\redowhitespace} % experimental +\defineblankmethod [\v!always] {\redowhitespace} % experimental % happens often, so we speed this up: % diff --git a/tex/context/base/core-tsp.tex b/tex/context/base/core-tsp.tex index 806e45053..1338b79f1 100644 --- a/tex/context/base/core-tsp.tex +++ b/tex/context/base/core-tsp.tex @@ -72,7 +72,6 @@ \@@sibefore \let\next} % \bgroup - \def\checksplitfloat {\ifconditional\splitfloatdone\else \blank{\tttf \getmessage\m!floatblocks{13}\empty}\blank diff --git a/tex/context/base/core-uti.mkiv b/tex/context/base/core-uti.mkiv index 8059ed69d..9b2f35c30 100644 --- a/tex/context/base/core-uti.mkiv +++ b/tex/context/base/core-uti.mkiv @@ -57,7 +57,7 @@ \immediatewriteutilitytua{}% \immediatewriteutilitytua{-- begin of utility file}% \immediatewriteutilitytua{}% - \immediatewriteutilitytua{do}% +% \immediatewriteutilitytua{do}% \immediatewriteutilitytua{if job and job.version and not job.version == "\utilityversion" then return end}% \immediatewriteutilitytua{if not job then job = { } end}% \immediatewriteutilitytua{job.version = "\utilityversion"}% @@ -65,9 +65,9 @@ \to \everyopenutilities \appendtoks - \immediatewriteutilitytua{end}% - \immediatewriteutilitytua{}% - \immediatewriteutilitytua{-- end of utility file}% +% \immediatewriteutilitytua{end}% +% \immediatewriteutilitytua{}% +% \immediatewriteutilitytua{-- end of utility file}% %\immediate\closeout\utility@tua \to \everycloseutilities @@ -77,9 +77,9 @@ \ctxlua { do if not job then job = { } end job.version = "\utilityversion" - % local settings = loadfile("\jobname.tuc") local settings = io.loaddata("\jobname.tuc") - if settings and settings:find("\letterpercent -\letterpercent -\letterpercent s*end of utility file\letterpercent s*$") then + if settings then + % if settings and settings:find("\letterpercent -\letterpercent -\letterpercent s*end of utility file\letterpercent s*$") then settings = loadstring(settings) if settings then settings() @@ -87,7 +87,7 @@ logs.report("utilityfile","invalid, not loaded") end else - logs.report("utilityfile","unfinished, not loaded") + logs.report("utilityfile","not present") end end}% \to \everyjob diff --git a/tex/context/base/enco-ini.mkiv b/tex/context/base/enco-ini.mkiv index 45e467252..563b72861 100644 --- a/tex/context/base/enco-ini.mkiv +++ b/tex/context/base/enco-ini.mkiv @@ -25,6 +25,16 @@ characters.context.define() } % redefines all \characters +\newbox\accenttestbox + +\unexpanded\def\dobuildtextaccent#1#2% + {\begingroup + \global\setbox\accenttestbox\hbox{#1}% + \scratchcounter\ctxlua{characters.charcode(\number\accenttestbox)}% + \ifcase\scratchcounter\else\accent\scratchcounter\fi + \relax#2% + \endgroup} + \useencoding[032,033,037] % fallbacks for some unicode chars, todo \setupencoding[\s!default=ec] % for the moment keep it this way, till fonts are there diff --git a/tex/context/base/enco-ini.tex b/tex/context/base/enco-ini.tex index 05bec2ba7..4c85bac5b 100644 --- a/tex/context/base/enco-ini.tex +++ b/tex/context/base/enco-ini.tex @@ -1004,27 +1004,15 @@ \newbox\accenttestbox \unexpanded\def\dobuildtextaccent#1#2% - {{\global\setbox\accenttestbox\hbox{#1}% - \scratchcounter\ctxlua{characters.charcode(\number\accenttestbox)}% - \ifcase\scratchcounter\or\accent\scratchcounter\fi - \relax#2}} + {\begingroup + \global\setbox\accenttestbox\hbox{#1}% + \scratchcounter\ctxlua{characters.charcode(\number\accenttestbox)}% + \ifcase\scratchcounter\else\accent\scratchcounter\fi + \relax#2% + \endgroup} \endLUATEX -% will be overloaded later - -\definecommand ` {\buildtextaccent\textgrave} -\definecommand ' {\buildtextaccent\textacute} -\definecommand r {\buildtextaccent\textring} -\definecommand v {\buildtextaccent\textcaron} -\definecommand u {\buildtextaccent\textbreve} -\definecommand = {\buildtextaccent\textmacron} -\definecommand ^ {\buildtextaccent\textcircumflex} -\definecommand . {\buildtextaccent\textdotaccent} -\definecommand H {\buildtextaccent\texthungarumlaut} -\definecommand ~ {\buildtextaccent\texttilde} -\definecommand " {\buildtextaccent\textdiaeresis} - % some fake ones, name will change into build \unexpanded\def\bottomaccent#1#2#3#4#5% down right slantcorrection accent char @@ -1050,11 +1038,6 @@ \def\buildtextcedilla {\bottomaccent{0ex}{0}{5}{\textcedilla}} \def\buildtextogonek {\bottomaccent{-.1ex}{.5}{0}{\textogonek}} -\definecommand c {\buildtextcedilla} -\definecommand b {\buildtextmacron} -\definecommand d {\buildtextbottomdot} -\definecommand k {\buildtextogonek} - %D A collectors item: \def\buildtextbottomcomma{\bottomaccent{.15ex}{0}{5}{\tx,}} @@ -1087,19 +1070,6 @@ \def\donormalmathaccent#1% {\getvalue{normalmathaccent\string#1}} -\definemathaccent acute {\buildmathaccent\mathacute} -\definemathaccent grave {\buildmathaccent\mathgrave} -\definemathaccent ddot {\buildmathaccent\mathddot} -\definemathaccent tilde {\buildmathaccent\mathtilde} -\definemathaccent bar {\buildmathaccent\mathbar} -\definemathaccent breve {\buildmathaccent\mathbreve} -\definemathaccent check {\buildmathaccent\mathcheck} -\definemathaccent hat {\buildmathaccent\mathhat} -\definemathaccent vec {\buildmathaccent\mathvec} -\definemathaccent dot {\buildmathaccent\mathdot} -\definemathaccent widetilde {\buildmathaccent\mathwidetilde} -\definemathaccent widehat {\buildmathaccent\mathwidehat} - %D Some precautions: \ifx\usepdffontresource\undefined @@ -1212,6 +1182,38 @@ %D We preload several encodings: +\loadmarkfile{enco-ini} + +\definecommand ` {\buildtextaccent\textgrave} +\definecommand ' {\buildtextaccent\textacute} +\definecommand r {\buildtextaccent\textring} +\definecommand v {\buildtextaccent\textcaron} +\definecommand u {\buildtextaccent\textbreve} +\definecommand = {\buildtextaccent\textmacron} +\definecommand ^ {\buildtextaccent\textcircumflex} +\definecommand . {\buildtextaccent\textdotaccent} +\definecommand H {\buildtextaccent\texthungarumlaut} +\definecommand ~ {\buildtextaccent\texttilde} +\definecommand " {\buildtextaccent\textdiaeresis} + +\definecommand c {\buildtextcedilla} +\definecommand b {\buildtextmacron} +\definecommand d {\buildtextbottomdot} +\definecommand k {\buildtextogonek} + +\definemathaccent acute {\buildmathaccent\mathacute} +\definemathaccent grave {\buildmathaccent\mathgrave} +\definemathaccent ddot {\buildmathaccent\mathddot} +\definemathaccent tilde {\buildmathaccent\mathtilde} +\definemathaccent bar {\buildmathaccent\mathbar} +\definemathaccent breve {\buildmathaccent\mathbreve} +\definemathaccent check {\buildmathaccent\mathcheck} +\definemathaccent hat {\buildmathaccent\mathhat} +\definemathaccent vec {\buildmathaccent\mathvec} +\definemathaccent dot {\buildmathaccent\mathdot} +\definemathaccent widetilde {\buildmathaccent\mathwidetilde} +\definemathaccent widehat {\buildmathaccent\mathwidehat} + \useencoding[def] % defaults (partly simplified) \useencoding[acc] % accent commands \useencoding[raw] % simplified (incomplete) @@ -1219,8 +1221,6 @@ \useencoding[cas] % case mapping, not needed in mkiv \useencoding[mis] % a few commands -\loadmarkfile{enco-ini} - % \useencoding[ans,il2,ec,tbo,pdf,uc,pol,qx,t5,cyr,agr] % pol and il2 will go away, not needed in mkiv % \useencoding[032,033,037] % fallbacks for some unicode chars % \setupencoding[\s!default=ec] % was: [\s!default=\s!default] diff --git a/tex/context/base/font-afm.lua b/tex/context/base/font-afm.lua index 23cc7421e..7834c1b7f 100644 --- a/tex/context/base/font-afm.lua +++ b/tex/context/base/font-afm.lua @@ -592,6 +592,10 @@ function fonts.tfm.set_normal_feature(specification,name,value) end function fonts.tfm.read_from_afm(specification) +--~ local fullname = input.findbinfile(texmf.instance,specification.name,"afm") or "" +--~ if fullname ~= "" then +--~ specification.filename = fullname +--~ end local tfmtable = fonts.afm.afm_to_tfm(specification) if tfmtable then tfmtable.name = specification.name @@ -677,7 +681,7 @@ end fonts.afm.features.register('liga',true) fonts.afm.features.register('kerns',true) -fonts.afm.features.register('extrakerns') +fonts.afm.features.register('extrakerns') -- needed? fonts.initializers.node.afm.ligatures = fonts.initializers.base.afm.ligatures fonts.initializers.node.afm.texligatures = fonts.initializers.base.afm.texligatures @@ -689,6 +693,11 @@ fonts.initializers.node.afm.liga = fonts.initializers.base.afm.ligatures fonts.initializers.base.afm.tlig = fonts.initializers.base.afm.texligatures fonts.initializers.node.afm.tlig = fonts.initializers.base.afm.texligatures +fonts.initializers.base.afm.trep = fonts.tfm.replacements +fonts.initializers.node.afm.trep = fonts.tfm.replacements + +fonts.afm.features.register('trep') -- todo: also proper features for afm + -- tfm features fonts.initializers.base.afm.equaldigits = fonts.initializers.common.equaldigits diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua index 8e0f47624..fbeae362b 100644 --- a/tex/context/base/font-otf.lua +++ b/tex/context/base/font-otf.lua @@ -21,7 +21,7 @@ if not modules then modules = { } end modules ['font-otf'] = { -- vhal vjmo vkna vkrn vpal vrt2 --[[ldx-- -<p>This module is sparesely documented because it is a moving target. +<p>This module is sparsely documented because it is a moving target. The table format of the reader changes and we experiment a lot with different methods for supporting features.</p> @@ -40,7 +40,7 @@ number by one when there's a fix in the <l n='fontforge'/> library or fonts = fonts or { } fonts.otf = fonts.otf or { } -fonts.otf.version = 2.00 +fonts.otf.version = 2.01 fonts.otf.pack = true fonts.otf.tables = fonts.otf.tables or { } fonts.otf.meanings = fonts.otf.meanings or { } @@ -1033,31 +1033,91 @@ end fonts.otf.cidmaps = { } +--~ function fonts.otf.cidmap(registry,ordering,supplement) +--~ local template = "%s-%s-%s.cidmap" +--~ local filename = string.format(template,registry,ordering,supplement) +--~ local supplement = tonumber(supplement) +--~ local cidmap = fonts.otf.cidmaps[filename] +--~ if not cidmap then +--~ for i=supplement,0,-1 do +--~ logs.report("load otf",string.format("checking cidmap, registry: %s, ordering: %s, supplement: %s",registry,ordering,i)) +--~ filename = string.format(template,registry,ordering,i) +--~ local fullname = input.find_file(texmf.instance,filename,'cid') or "" +--~ if fullname ~= "" then +--~ cidmap = fonts.otf.load_cidmap(fullname) +--~ if cidmap then +--~ logs.report("load otf",string.format("using cidmap file %s",filename)) +--~ fonts.otf.cidmaps[filename] = cidmap +--~ if i < supplement then +--~ for j=i+1,supplement do +--~ filename = string.format(template,registry,ordering,j) +--~ fonts.otf.cidmaps[filename] = cidmap -- copy of ref +--~ end +--~ end +--~ return cidmap +--~ end +--~ end +--~ end +--~ end +--~ return cidmap +--~ end + +fonts.otf.cidmax = 10 + function fonts.otf.cidmap(registry,ordering,supplement) + -- cf Arthur R. we can safely scan upwards since cids are downward compatible local template = "%s-%s-%s.cidmap" - local filename = string.format(template,registry,ordering,supplement) local supplement = tonumber(supplement) - local cidmap = fonts.otf.cidmaps[filename] - if not cidmap then - for i=supplement,0,-1 do - logs.report("load otf",string.format("checking cidmap, registry: %s, ordering: %s, supplement: %s",registry,ordering,i)) - filename = string.format(template,registry,ordering,i) + logs.report("load otf",string.format("needed cidmap, registry: %s, ordering: %s, supplement: %s",registry,ordering,supplement)) + local function locate(registry,ordering,supplement) + local filename = string.format(template,registry,ordering,supplement) + local cidmap = fonts.otf.cidmaps[filename] + if not cidmap then + logs.report("load otf",string.format("checking cidmap, registry: %s, ordering: %s, supplement: %s, filename: %s",registry,ordering,supplement,filename)) local fullname = input.find_file(texmf.instance,filename,'cid') or "" if fullname ~= "" then cidmap = fonts.otf.load_cidmap(fullname) if cidmap then logs.report("load otf",string.format("using cidmap file %s",filename)) fonts.otf.cidmaps[filename] = cidmap - if i < supplement then - for j=i+1,supplement do - filename = string.format(template,registry,ordering,j) - fonts.otf.cidmaps[filename] = cidmap -- copy of ref - end - end return cidmap end end end + return cidmap + end + local cidmap = locate(registry,ordering,supplement) + if not cidmap then + local cidnum = nil + -- next highest (alternatively we could start high) + if supplement < fonts.otf.cidmax then + for supplement=supplement+1,fonts.otf.cidmax do + local c = locate(registry,ordering,supplement) + if c then + cidmap, cidnum = c, supplement + break + end + end + end + -- next lowest (least worse fit) + if not cidmap and supplement > 0 then + for supplement=supplement-1,0,-1 do + local c = locate(registry,ordering,supplement) + if c then + cidmap, cidnum = c, supplement + break + end + end + end + -- prevent further lookups + if cidmap and cidnum > 0 then + for s=0,cidnum-1 do + filename = string.format(template,registry,ordering,s) + if not fonts.otf.cidmaps[filename] then + fonts.otf.cidmaps[filename] = cidmap -- copy of ref + end + end + end end return cidmap end @@ -1118,7 +1178,8 @@ function fonts.otf.enhance.before(data,filename) local int_to_uni = data.map.backmap for index, glyph in pairs(data.glyphs) do if glyph.name then - local unic = glyph.unicode or -1 + local unic = glyph.unicode or glyph.unicodeenc or -1 + glyph.unicodeenc = nil -- older luatex version if index > 0 and (unic == -1 or unic >= 0x110000) then while uni_to_int[private] do private = private + 1 @@ -1129,6 +1190,8 @@ function fonts.otf.enhance.before(data,filename) if fonts.trace then logs.report("load otf",string.format("enhance: glyph %s at index %s is moved to private unicode slot %s",glyph.name,index,private)) end + else + glyph.unicode = unic -- safeguard for older version end end end @@ -2093,11 +2156,7 @@ function fonts.initializers.base.otf.tlig(tfm,value) fonts.otf.features.aux.resolve_ligatures(tfm,ligatures,'tlig') end -function fonts.initializers.base.otf.trep(tfm,value) - tfm.characters[0x0022] = table.fastcopy(tfm.characters[0x201D]) - tfm.characters[0x0027] = table.fastcopy(tfm.characters[0x2019]) - tfm.characters[0x0060] = table.fastcopy(tfm.characters[0x2018]) -end +fonts.initializers.base.otf.trep = fonts.tfm.replacements table.insert(fonts.triggers,"tlig") table.insert(fonts.triggers,"trep") @@ -4298,16 +4357,16 @@ do local left_punctuation = table.tohash { 0x2018, -- ‘ 0x201C, -- “ - 0x300C, -- 「 left quote - 0x300E, -- 『 left double quote - 0x3008, -- 〈 Left book quote - 0x300A, -- 《 Left double book quote - 0x3014, -- 〔 left book quote - 0x3016, --〖 left double book quote - 0x3010, -- 【 left double book quote - 0xFF08, -- ( left parenthesis - 0xFF3B, -- [ left square brackets - 0xFF5B, -- { left curve bracket + 0x3008, -- 〈 Left book quote + 0x300A, -- 《 Left double book quote + 0x300C, -- 「 left quote + 0x300E, -- 『 left double quote + 0x3010, -- 【 left double book quote + 0x3014, -- 〔 left book quote + 0x3016, --〖 left double book quote + 0xFF08, -- ( left parenthesis + 0xFF3B, -- [ left square brackets + 0xFF5B, -- { left curve bracket } local right_punctuation = table.tohash { @@ -4351,8 +4410,8 @@ do -- will move to node-ini : - local allowbreak = nodes.penalty( -100) nodes.register(allowbreak) - local nobreak = nodes.penalty( 10000) nodes.register(nobreak) + local allowbreak = nodes.penalty( -100) nodes.register(allowbreak) + local nobreak = nodes.penalty(10000) nodes.register(nobreak) fonts.analyzers.methods.stretch_hang = true diff --git a/tex/context/base/font-tfm.lua b/tex/context/base/font-tfm.lua index 32ea6232a..e102f06df 100644 --- a/tex/context/base/font-tfm.lua +++ b/tex/context/base/font-tfm.lua @@ -104,22 +104,45 @@ do with the fact that <l n='tex'/> uses a negative multiple of 1000 as a signal for a font scaled based on the design size.</p> --ldx]]-- +do + + local factors = { + pt = 65536.0, + bp = 65781.8, + } + + function fonts.tfm.setfactor(f) + fonts.tfm.factor = factors[f or 'pt'] or factors.pt + end + + fonts.tfm.setfactor() + +end + function fonts.tfm.scaled(scaledpoints, designsize) -- handles designsize in sp as well if scaledpoints < 0 then if designsize then - if designsize > 65536 then -- or just 1000 + if designsize > fonts.tfm.factor then -- or just 1000 / when? mp? return (- scaledpoints/1000) * designsize -- sp's else - return (- scaledpoints/1000) * designsize * 65536 + return (- scaledpoints/1000) * designsize * fonts.tfm.factor end else - return (- scaledpoints/1000) * 10 * 65536 + return (- scaledpoints/1000) * 10 * fonts.tfm.factor end else return scaledpoints end end +--~ function fonts.tfm.scaled(scaledpoints, designsize) +--~ if scaledpoints < 0 then +--~ return (- scaledpoints/1000) * (designsize or 10) * fonts.tfm.factor +--~ else +--~ return scaledpoints +--~ end +--~ end + --[[ldx-- <p>Before a font is passed to <l n='tex'/> we scale it. Here we also need to scale virtual characters.</p> @@ -284,11 +307,16 @@ function fonts.logger.save(tfmtable,source,specification) -- save file name in s end function fonts.logger.report(separator) - local t = { } - for _,v in pairs(table.sortedkeys(fonts.loaded)) do - t[#t+1] = v .. ":" .. fonts.loaded[v].source + local s = table.sortedkeys(fonts.loaded) + if #s > 0 then + local t = { } + for _,v in ipairs(s) do + t[#t+1] = v .. ":" .. fonts.loaded[v].source + end + return table.concat(t,separator or " ") + else + return "none" end - return table.concat(t,separator or " ") end function fonts.logger.format(name) @@ -703,3 +731,12 @@ do end end + +function fonts.tfm.replacements(tfm,value) +--~ tfm.characters[0x0022] = table.fastcopy(tfm.characters[0x201D]) +--~ tfm.characters[0x0027] = table.fastcopy(tfm.characters[0x2019]) +--~ tfm.characters[0x0060] = table.fastcopy(tfm.characters[0x2018]) + tfm.characters[0x0022] = tfm.characters[0x201D] + tfm.characters[0x0027] = tfm.characters[0x2019] + tfm.characters[0x0060] = tfm.characters[0x2018] +end diff --git a/tex/context/base/l-set.lua b/tex/context/base/l-set.lua new file mode 100644 index 000000000..2bcf664f8 --- /dev/null +++ b/tex/context/base/l-set.lua @@ -0,0 +1,70 @@ +-- filename : l-set.lua +-- author : Hans Hagen, PRAGMA-ADE, Hasselt NL +-- copyright: PRAGMA ADE / ConTeXt Development Team +-- license : see context related readme files + +if not versions then versions = { } end versions['l-set'] = 1.001 + +if not set then set = { } end + +do + + local nums = { } + local tabs = { } + local concat = table.concat + + set.create = table.tohash + + function set.tonumber(t) + if next(t) then + local s = "" + -- we could save mem by sorting, but it slows down + for k, v in pairs(t) do + if v then + -- why bother about the leading space + s = s .. " " .. k + end + end + if not nums[s] then + tabs[#tabs+1] = t + nums[s] = #tabs + end + return nums[s] + else + return 0 + end + end + + function set.totable(n) + if n == 0 then + return { } + else + return tabs[n] or { } + end + end + + function set.contains(n,s) + if type(n) == "table" then + return n[s] + elseif n == 0 then + return false + else + local t = tabs[n] + return t and t[s] + end + end + +end + +--~ local c = set.create{'aap','noot','mies'} +--~ local s = set.tonumber(c) +--~ local t = set.totable(s) +--~ print(t['aap']) +--~ local c = set.create{'zus','wim','jet'} +--~ local s = set.tonumber(c) +--~ local t = set.totable(s) +--~ print(t['aap']) +--~ print(t['jet']) +--~ print(set.contains(t,'jet')) +--~ print(set.contains(t,'aap')) + diff --git a/tex/context/base/l-xml.lua b/tex/context/base/l-xml.lua index a15e3e81b..685907df0 100644 --- a/tex/context/base/l-xml.lua +++ b/tex/context/base/l-xml.lua @@ -152,6 +152,12 @@ do return "" end + local cleanup = false + + function xml.set_text_cleanup(fnc) + cleanup = fnc + end + local function add_attribute(namespace,tag,value) if tag == "xmlns" then xmlns[#xmlns+1] = xml.resolvens(value) @@ -206,7 +212,11 @@ do end end local function add_text(text) - dt[#dt+1] = text + if cleanup and #text > 0 then + dt[#dt+1] = cleanup(text) + else + dt[#dt+1] = text + end end local function add_special(what, spacing, text) if #spacing > 0 then @@ -1834,15 +1844,14 @@ do if unicode and unicode.utf8 then end end - local entities = xml.entities local function resolve(e) - local e = entities[e] - if e then - return e + local ee = entities[e] + if ee then + return ee elseif e:find("#x") then - return char(tonumber(s:sub(3),16)) + return char(tonumber(e:sub(3),16)) else local h = entities.handler return (h and h(e)) or "&" .. e .. ";" @@ -1863,6 +1872,33 @@ do if unicode and unicode.utf8 then end end + function xml.utfize_text(str) + if str:find("&#") then + return str:gsub("&#x(.-);",toutf) + else + return str + end + end + + function xml.resolve_text_entities(str) + if str:find("&") then + return str:gsub("&(.-);",resolve) + else + return str + end + end + + function xml.show_text_entities(str) + if str:find("&") then + return str:gsub("&(.-);","[%1]") + else + return str + end + end + +-- xml.set_text_cleanup(xml.show_text_entities) +-- xml.set_text_cleanup(xml.resolve_text_entities) + end end --~ xml.lshow("/../../../a/(b|c)[@d='e']/f") diff --git a/tex/context/base/luat-inp.lua b/tex/context/base/luat-inp.lua index 167ec145f..628b85766 100644 --- a/tex/context/base/luat-inp.lua +++ b/tex/context/base/luat-inp.lua @@ -289,7 +289,7 @@ do end function input.elapsedtime(instance) - return string.format("%0.3f",instance.loadtime or 0) + return string.format("%0.3f",(instance and instance.loadtime) or 0) end function input.report_loadtime(instance) @@ -298,9 +298,7 @@ function input.report_loadtime(instance) end end -function input.loadtime(instance) - tex.print(input.elapsedtime(instance)) -end +input.loadtime = input.elapsedtime function input.env(instance,key) return instance.environment[key] or input.osenv(instance,key) diff --git a/tex/context/base/luat-lib.tex b/tex/context/base/luat-lib.tex index 149e4d350..a068125b6 100644 --- a/tex/context/base/luat-lib.tex +++ b/tex/context/base/luat-lib.tex @@ -38,6 +38,7 @@ \registerctxluafile{l-lpeg} {1.001} \registerctxluafile{l-boolean}{1.001} \registerctxluafile{l-number} {1.001} +\registerctxluafile{l-set} {1.001} \registerctxluafile{l-math} {1.001} \registerctxluafile{l-table} {1.001} \registerctxluafile{l-md5} {1.001} diff --git a/tex/context/base/luat-tex.lua b/tex/context/base/luat-tex.lua index 591f3af20..0fb262698 100644 --- a/tex/context/base/luat-tex.lua +++ b/tex/context/base/luat-tex.lua @@ -169,6 +169,78 @@ end -- callback into the file io and related things; disabling kpse + +if texconfig and not texlua then do + + -- this is not the right place, because we refer to quite some not yet defined tables, but who cares ... + + ctx = ctx or { } + + local ss = { } + + function ctx.writestatus(a,b) + local s = ss[a] + if not ss[a] then + s = a:rpadd(15) .. ": " + ss[a] = s + end + texio.write_nl(s .. b .. "\n") + end + + function ctx.show_statistics() + local function ws(...) + ctx.writestatus("mkiv lua stats",string.format(...)) + end + if caches then + ws("used config path - %s", caches.configpath(texmf.instance)) + ws("used cache path - %s", caches.path) + end + if status.luabytecodes > 0 and input.storage and input.storage.done then + ws("modules/dumps/instances - %s/%s/%s", status.luabytecodes-500, input.storage.done, status.luastates) + end + if texmf.instance then + ws("input load time - %s seconds", input.loadtime(texmf.instance)) + end + if fonts then + ws("fonts load time - %s seconds", input.loadtime(fonts)) + end + if xml then + ws("xml load time - %s seconds", input.loadtime(lxml)) + end + if mptopdf then + ws("mps conversion time - %s seconds", input.loadtime(mptopdf)) + end + if nodes then + ws("node processing time - %s seconds (including kernel)", input.loadtime(nodes)) + end + if kernel then + ws("kernel processing time - %s seconds", input.loadtime(kernel)) + end + if attributes then + ws("attribute processing time - %s seconds", input.loadtime(attributes)) + end + if languages then + ws("language load time - %s seconds (n=%s)", input.loadtime(languages), languages.hyphenation.n()) + end + if status.luastate_bytes then + ws("current memory usage - %s bytes", status.luastate_bytes) + end + if nodes then + ws("cleaned up reserved nodes - %s nodes, %s lists (of %s)", nodes.cleanup_reserved(tex.count[24])) -- \topofboxstack + end + if languages then + ws("loaded patterns - %s", languages.logger.report()) + end + if status.node_mem_usage then + ws("node memory usage - %s", status.node_mem_usage) + end + if fonts then + ws("loaded fonts - %s", fonts.logger.report()) -- last because it is often a long list + end + end + +end end + if texconfig and not texlua then texconfig.kpse_init = false @@ -263,54 +335,56 @@ if texconfig and not texlua then end - if callback and (input.logmode() == 'xml') then - - function input.start_page_number() - texio.write_nl("<p real='" .. tex.count[0] .. "' page='"..tex.count[1].."' sub='"..tex.count[2].."'") - end - function input.stop_page_number() - texio.write("/>") - texio.write_nl("") - end + if callback then - callback.register('start_page_number' , input.start_page_number) - callback.register('stop_page_number' , input.stop_page_number ) + if input.logmode() == 'xml' then - function input.report_output_pages(p,b) - texio.write_nl("<v k='pages'>"..p.."</v>") - texio.write_nl("<v k='bytes'>"..b.."</v>") - texio.write_nl("") - end - function input.report_output_log() - end + function input.start_page_number() + texio.write_nl("<p real='" .. tex.count[0] .. "' page='"..tex.count[1].."' sub='"..tex.count[2].."'") + end + function input.stop_page_number() + texio.write("/>") + texio.write_nl("") + end - callback.register('report_output_pages', input.report_output_pages) - callback.register('report_output_log' , input.report_output_log ) + callback.register('start_page_number' , input.start_page_number) + callback.register('stop_page_number' , input.stop_page_number ) - function input.start_run() - texio.write_nl("<?xml version='1.0' standalone='yes'?>") - texio.write_nl("<job xmlns='www.tug.org/luatex/schemas/context-job.rng'>") - texio.write_nl("") - end - function input.stop_run() - texio.write_nl("</job>") - end - function input.show_statistics() - for k,v in pairs(status.list()) do - texio.write_nl("log","<v k='"..k.."'>"..tostring(v).."</v>") + function input.report_output_pages(p,b) + texio.write_nl("<v k='pages'>"..p.."</v>") + texio.write_nl("<v k='bytes'>"..b.."</v>") + texio.write_nl("") + end + function input.report_output_log() end - end - table.insert(input.start_actions, input.start_run) + callback.register('report_output_pages', input.report_output_pages) + callback.register('report_output_log' , input.report_output_log ) - table.insert(input.stop_actions, input.show_statistics) - table.insert(input.stop_actions, input.stop_run) + function input.start_run() + texio.write_nl("<?xml version='1.0' standalone='yes'?>") + texio.write_nl("<job xmlns='www.tug.org/luatex/schemas/context-job.rng'>") + texio.write_nl("") + end + function input.stop_run() + texio.write_nl("</job>") + end + function input.show_statistics() + for k,v in pairs(status.list()) do + texio.write_nl("log","<v k='"..k.."'>"..tostring(v).."</v>") + end + end + + table.insert(input.start_actions, input.start_run) + table.insert(input.stop_actions , input.show_statistics) + table.insert(input.stop_actions , input.stop_run) - function input.start_run() for _, a in pairs(input.start_actions) do a() end end - function input.stop_run () for _, a in pairs(input.stop_actions ) do a() end end + else + table.insert(input.stop_actions , input.show_statistics) + end - callback.register('start_run', input.start_run) - callback.register('stop_run' , input.stop_run ) + callback.register('start_run', function() for _, a in pairs(input.start_actions) do a() end end) + callback.register('stop_run' , function() for _, a in pairs(input.stop_actions ) do a() end ctx.show_statistics() end) end @@ -339,7 +413,7 @@ end if texconfig and not texlua then - if not luatex then luatex = { } end + luatex = luatex or { } luatex.variablenames = { 'main_memory', 'extra_mem_bot', 'extra_mem_top', @@ -429,7 +503,7 @@ if node then for i=1,nofboxes do local l = tb[i] if l then - flush(l) + -- flush(l) tb[i] = nil nl = nl + 1 end @@ -439,9 +513,6 @@ if node then return nr, nl, nofboxes end - -- nodes.register = function() end - -- nodes.cleanup_reserved = function() end - end do @@ -498,3 +569,17 @@ if node then end end + +if tex then + + function tex.node_mem_status() + -- todo: lpeg + local s = status.node_mem_usage + local t = { } + for n, tag in s:gmatch("(%d+) ([a-z_]+)") do + t[tag] = n + end + return t + end + +end diff --git a/tex/context/base/lxml-ini.lua b/tex/context/base/lxml-ini.lua index 69d828d3d..19c3b0db9 100644 --- a/tex/context/base/lxml-ini.lua +++ b/tex/context/base/lxml-ini.lua @@ -466,3 +466,23 @@ end lxml.set_verbatim("\\xmlcdatabefore", "\\xmlcdataafter", "\\xmlcdataobeyedline", "\\xmlcdataobeyedspace") lxml.set_cdata() + + +do + + local traced = { } + + function lxml.trace_text_entities(str) + return str:gsub("&(.-);",function(s) + traced[s] = (traced[s] or 0) + 1 + return "["..s.."]" + end) + end + + function lxml.show_text_entities() + for k,v in ipairs(table.sortedkeys(traced)) do + texio.write_nl(string.format("entity: %s (n=%s)",v,traced[v])) + end + end + +end diff --git a/tex/context/base/lxml-ini.tex b/tex/context/base/lxml-ini.tex index 8f25a2d4a..019916499 100644 --- a/tex/context/base/lxml-ini.tex +++ b/tex/context/base/lxml-ini.tex @@ -168,6 +168,15 @@ \def\inlinemessage #1{\dontleavehmode{\tttf#1}} \def\displaymessage#1{\blank\inlinemessage{#1}\blank} +% entities + +\def\xmlresolveentities + {\ctxlua{xml.set_text_cleanup(xml.set_text_cleanup(xml.resolve_text_entities))}} + +\def\xmltraceentities + {\ctxlua{xml.set_text_cleanup(lxml.trace_text_entities)}% + \appendtoks\ctxlua{lxml.show_text_entities()}\to\everygoodbye} + \protect \endinput % \xmlload{main}{normreader.xml} diff --git a/tex/context/base/m-timing.tex b/tex/context/base/m-timing.tex new file mode 100644 index 000000000..24c2d1e9a --- /dev/null +++ b/tex/context/base/m-timing.tex @@ -0,0 +1,247 @@ +%D \module +%D [ file=m-timing, +%D version=2007.12.23, +%D title=\CONTEXT\ Modules, +%D subtitle=Timing, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright=Hans Hagen] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D Written at the end of 2007, this module is dedicated to Taco. Reaching this +%D point in \LUATEX\ was a non trivial effort. By visualizing a bit what happens +%D when pages come out of \LUATEX, you may get an idea what is involved. It took +%D much time an dedication to reach this point in the development. Add to that +%D those daily Skype intense discussion, testing and debugging moments. Time flies +%D but progress is impressive. The motto of this module could be: what you see +%D is what you get. An there is much more to come \unknown. + +% \usemodule[timing] +% \setupcolors[state=start] +% \starttext +% \dorecurse{200}{\input tufte \par} \ShowUsage{} +% \stoptext + +\definecolor[usage:line] [darkred] +\definecolor[usage:time] [darkblue] +\definecolor[usage:frame][darkgray] + +\startluacode +do + + document = document or { } + document.progress = document.progress or { } + + local defaultfilename = tex.jobname .. "-luatex-progress" + + local params = { + "cs_count", + "dyn_used", + "elapsed_time", + "luabytecode_bytes", + "luastate_bytes", + "max_buf_stack", + "obj_ptr", + "pdf_mem_ptr", + "pdf_mem_size", + "pdf_os_cntr", + "pool_ptr", + "str_ptr", + } + + -- storage + + local last = os.clock() + local data = { } + + function document.progress.save() + local f = io.open((name or defaultfilename) .. ".lut","w") + if f then + f:write(table.serialize(data,true)) + f:close() + data = { } + end + end + + function document.progress.store() + local c = os.clock() + local t = { + elapsed_time = c - last, + node_memory = tex.node_mem_status(), + } + for k, v in pairs(params) do + if status[v] then t[v] = status[v] end + end + data[#data+1] = t + last = c + end + + -- conversion + + local processed = { } + + function document.progress.bot(name,tag) + local d = document.progress.convert(name) + return d.bot[tag] or 0 + end + function document.progress.top(name,tag) + local d = document.progress.convert(name) + return d.top[tag] or 0 + end + function document.progress.pages(name,tag) + local d = document.progress.convert(name) + return d.pages or 0 + end + function document.progress.path(name,tag) + local d = document.progress.convert(name) + return d.paths[tag] or "origin" + end + function document.progress.nodes(name) + local d = document.progress.convert(name) + return d.names or { } + end + function document.progress.parameters(name) + local d = document.progress.convert(name) + return params -- shared + end + + function document.progress.convert(name) + name = ((name ~= "") and name) or defaultfilename + if not processed[name] then + local names, top, bot, pages, paths, keys = { }, { }, { }, 0, { }, { } + local data = io.loaddata(name .. ".lut") + if data then data = loadstring(data) end + if data then data = data() end + if data then + pages = #data + if pages > 1 then + local factor = 100 + for k,v in ipairs(data) do + for k,v in pairs(v.node_memory) do + keys[k] = true + end + end + for k,v in ipairs(data) do + local m = v.node_memory + for k, _ in pairs(keys) do + if not m[k] then m[k] = 0 end + end + end + local function path(tag,subtag) + local b, t, s = nil, nil, { } + for k,v in ipairs(data) do + local v = (subtag and v[tag][subtag]) or v[tag] + if v then + v = tonumber(v) + if b then + if v > t then t = v end + if v < b then b = v end + else + t = v + b = v + end + s[k] = v + else + s[k] = 0 + end + end + local tagname = subtag or tag + top[tagname] = (string.format("%.3f",t)):gsub("%.000$","") + bot[tagname] = (string.format("%.3f",b)):gsub("%.000$","") + local delta = t-b + if delta == 0 then + delta = 1 + else + delta = factor/delta + end + for k, v in ipairs(s) do + s[k] = "(" .. k .. "," .. (v-b)*delta .. ")" + end + paths[tagname] = table.concat(s,"--") + end + for _, tag in pairs(params) do + path(tag) + end + for tag, _ in pairs(keys) do + path("node_memory",tag) + names[#names+1] = tag + end + pages = pages - 1 + end + end + table.sort(names) + processed[name] = { + names = names, + top = top, + bot = bot, + pages = pages, + paths = paths, + } + end + return processed[name] + end + + function document.progress.show(filename,parameters,nodes,other) + for n, name in pairs(parameters or document.progress.parameters(filename)) do + tex.sprint(tex.ctxcatcodes,string.format("\\ShowNamedUsage{%s}{%s}{%s}",filename or defaultfilename,name,other or "")) + end + for n, name in pairs(nodes or document.progress.nodes(filename)) do + tex.sprint(tex.ctxcatcodes,string.format("\\ShowNamedUsage{%s}{%s}{%s}",filename or defaultfilename,name,other or "")) + end + end + +end +\stopluacode + +% \everyfirstshipout + +\appendtoks\ctxlua{document.progress.store()}\to\everystarttext +\appendtoks\ctxlua{document.progress.store()}\to\everyshipout + +\ctxlua{table.insert(input.stop_actions, function() document.progress.save() end)} + +\def\ShowNamedUsage#1#2#3% + {\setbox\scratchbox\vbox\bgroup\startMPcode + begingroup ; save p, q, b, h, w ; + path p, q, b ; numeric h, w ; + p := \ctxlua{tex.sprint(document.progress.path("#1","#2"))} ; + if bbwidth(p) > 1 : + h := 100 ; w := 2 * h ; + w := \the\textwidth ; + p := p xstretched w ; + b := boundingbox (llcorner p -- llcorner p shifted (w,h)) ; + pickup pencircle scaled 3pt ; linecap := butt ; + draw b withcolor \MPcolor{usage:frame} ; + draw p withcolor \MPcolor{usage:line} ; + if ("#3" <> "") and ("#3" <> "#2") : + q := \ctxlua{tex.sprint(document.progress.path("#1","#3"))} ; + if bbwidth(q) > 1 : + q := q xstretched w ; + pickup pencircle scaled 1.5pt ; linecap := butt ; + draw q withcolor \MPcolor{usage:time} ; + fi ; + fi ; + fi ; + endgroup ; + \stopMPcode\egroup + \scratchdimen\wd\scratchbox + \ifdim\scratchdimen>\zeropoint + \startlinecorrection + \box\scratchbox \endgraf + \hbox to \scratchdimen{\tttf\strut\detokenize{#2}\hss + min:\ctxlua{tex.sprint(document.progress.bot("#1","\detokenize{#2}"))}, % + max:\ctxlua{tex.sprint(document.progress.top("#1","\detokenize{#2}"))}, % + pages:\ctxlua{tex.sprint(document.progress.pages("#1"))}% + }% + \stoplinecorrection + \fi} + +\def\LoadUsage #1{\ctxlua{document.progress.convert("#1")}} +\def\ShowUsage #1{\ctxlua{document.progress.show("#1",nil,nil,"elapsed_time")}} +\def\ShowMemoryUsage#1{\ctxlua{document.progress.show("#1",nil,{}, "elapsed_time")}} +\def\ShowNodeUsage #1{\ctxlua{document.progress.show("#1",{},nil, "elapsed_time")}} + +\endinput diff --git a/tex/context/base/m-visual.tex b/tex/context/base/m-visual.tex index b9ff6cb4c..c35e8a1a4 100644 --- a/tex/context/base/m-visual.tex +++ b/tex/context/base/m-visual.tex @@ -46,7 +46,7 @@ \def\fakerule#1% {\strut -% \startcolor[fakerulecolor]% + \startcolor[fakerulecolor]% \iffakebaseline \vrule\!!height1.25ex\!!depth-.05ex\!!width#1% \kern-#1% diff --git a/tex/context/base/node-ini.lua b/tex/context/base/node-ini.lua index 5750a5ef9..3ca07c16c 100644 --- a/tex/context/base/node-ini.lua +++ b/tex/context/base/node-ini.lua @@ -69,6 +69,52 @@ do local remove, free = node.remove, node.free + --~ function nodes.remove(head, current, free_too) + --~ if head == current then + --~ local cn = current.next + --~ if cn then + --~ cn.prev = nil + --~ if free_too then + --~ node.free(current) + --~ return cn, cn, nil + --~ else + --~ current.prev = nil + --~ current.next = nil + --~ return cn, cn, current + --~ end + --~ else + --~ if free_too then + --~ node.free(current) + --~ return nil, nil, nil + --~ else + --~ return head,current,current + --~ end + --~ end + --~ else + --~ local cp = current.prev + --~ local cn = current.next + --~ if not cp and head.next == current then + --~ cp = head + --~ end + --~ if cn then + --~ cn.prev = cp + --~ if cp then + --~ cp.next = cn + --~ end + --~ elseif cp then + --~ cp.next = nil + --~ end + --~ if free_too then + --~ node.free(current) + --~ return head, cn, nil + --~ else + --~ current.prev = nil + --~ current.next = nil + --~ return head, cn, current + --~ end + --~ end + --~ end + function nodes.remove(head, current, free_too) local t = current head, current = remove(head,current) @@ -87,9 +133,46 @@ do return nodes.remove(head,current,true) end - nodes.before = node.insert_before + nodes.before = node.insert_before -- broken nodes.after = node.insert_after +function nodes.before(h,c,n) + if c then + if c == h then + n.next = h + n.prev = nil + h.prev = n + else + local cp = c.prev + n.next = c + n.prev = cp + if cp then + cp.next = n + end + c.prev = n + return h, n + end + end + return n, n +end +function nodes.after(h,c,n) + if c then + local cn = c.next + if cn then + n.next = cn + cn.prev = n + else + n.next = nil + end + c.next = n + n.prev = c + if c ~= h then + return h, n + end + end + return n, n +end + function nodes.show_list(head, message) if message then texio.write_nl(message) diff --git a/tex/context/base/page-imp.tex b/tex/context/base/page-imp.tex index 039f36f4c..4c8a334bf 100644 --- a/tex/context/base/page-imp.tex +++ b/tex/context/base/page-imp.tex @@ -125,11 +125,21 @@ \newbox\postponedcontent +% \def\flushatshipout +% {\dowithnextbox +% {\global\setbox\postponedcontent\hbox to \zeropoint +% {%\hskip-\maxdimen % niet hier, gaat mis in acrobat (clipt) +% \box\postponedcontent\flushnextbox}% +% \global\ht\postponedcontent\zeropoint +% \global\dp\postponedcontent\zeropoint +% \global\wd\postponedcontent\zeropoint}% +% \hbox} + \def\flushatshipout {\dowithnextbox {\global\setbox\postponedcontent\hbox to \zeropoint {%\hskip-\maxdimen % niet hier, gaat mis in acrobat (clipt) - \box\postponedcontent\flushnextbox}% + \unhbox\postponedcontent\unhbox\nextbox}% \global\ht\postponedcontent\zeropoint \global\dp\postponedcontent\zeropoint \global\wd\postponedcontent\zeropoint}% diff --git a/tex/context/base/page-lin.lua b/tex/context/base/page-lin.lua index 91412d84f..a8d868f36 100644 --- a/tex/context/base/page-lin.lua +++ b/tex/context/base/page-lin.lua @@ -88,8 +88,12 @@ do if d then local s = d.start current_list[#current_list+1] = { n, s } - sprint(tex.ctxcatcodes, format("\\makenumber{%s}{%s}{%s}{%s}{%s}\\endgraf", d.tag or "", s, n.shift, n.width, leftskip(n.list))) - d.start = s + (d.step or 1) + if d.start % d.step == 0 then + sprint(tex.ctxcatcodes, format("\\makenumber{%s}{%s}{%s}{%s}{%s}\\endgraf", d.tag or "", s, n.shift, n.width, leftskip(n.list))) + else + sprint(tex.ctxcatcodes, "\\skipnumber\\endgraf") + end + d.start = s + 1 -- (d.step or 1) end end for n in traverse_id(hlist,head) do -- attr test here and quit as soon as zero found diff --git a/tex/context/base/page-lin.mkiv b/tex/context/base/page-lin.mkiv index d442bbfeb..4b805e0a3 100644 --- a/tex/context/base/page-lin.mkiv +++ b/tex/context/base/page-lin.mkiv @@ -11,6 +11,8 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +% generic or not ... maybe not bother too much and simplify to mkiv only + \writestatus{loading}{Context Core Macros / Line Numbering} \unprotect @@ -34,6 +36,7 @@ \def\mkaddtextlinenumbers#1#2#3% box col max {\bgroup + \def\skipnumber{\hbox{}}% \ifcase#3\relax \let\makenumber\mkskiplinenumber \or @@ -195,13 +198,19 @@ \def\dostartlinenumbering[#1][#2]% todo: c!continue {\begingroup \chardef\linenumbermode\plusone - \let\currentlinenumbering\empty \ifsecondargument - \doif{#2}\v!continue{\chardef\linenumbermode\zerocount}% + \def\currentlinenumbering{#1}% + \doifnumberelse{#2}% downward compatible + {\setvalue{\??rn#1\c!start}{#2}}% + {\doif{#2}\v!continue{\chardef\linenumbermode\zerocount}}% \else\iffirstargument - \doifelse{#1}\v!continue - {\chardef\linenumbermode\zerocount} - {\def\currentlinenumbering{#1}}% + \doifnumberelse{#1}% downward compatible + {\let\currentlinenumbering\empty + \setvalue{\??rn\c!start}{#1}}% + {\doifelse{#1}\v!continue + {\let\currentlinenumbering\empty + \chardef\linenumbermode\zerocount} + {\def\currentlinenumbering{#1}}}% \fi\fi \doifelse{\linenumberparameter\c!continue}\v!yes {\chardef\linenumbermode\zerocount}% @@ -249,6 +258,7 @@ \def\mkaddtextlinenumbers#1#2#3% box col max {\bgroup + \def\skipnumber{\hbox{}}% \ifcase#3\relax \let\makenumber\mkskiplinenumber \or diff --git a/tex/context/base/s-cdr-01.tex b/tex/context/base/s-cdr-01.tex new file mode 100644 index 000000000..80103936d --- /dev/null +++ b/tex/context/base/s-cdr-01.tex @@ -0,0 +1,131 @@ +%D \module +%D [ file=s-cdr-01, +%D version=2001.2.07, % maybe earlier +%D title=\CONTEXT\ Style File, +%D subtitle=CDROM Cover, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright=Hans Hagen] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\def\PDFMPformoffset{20cm} + +\definepapersize + [CDcover] + [width=12.5cm, + height=12.4cm] + +\definelayout + [CDcover] + [topspace=5mm, + backspace=5mm, + header=0pt, + footer=0pt, + width=middle, + height=middle] + +\setuparranging + [2SIDE] + +\setuppapersize + [CDcover] + [A4,landscape] + +\setuplayout + [CDcover] + +\setuplayout + [location=middle] + +\setupcolors + [state=start] + +\setupbackgrounds + [leftpage] + [background=leftcover] + +\setupbackgrounds + [rightpage] + [background=rightcover] + +\setuppagenumbering + [alternative=doublesided] + +\defineoverlay[leftcover] [\useMPgraphic{leftcover}] +\defineoverlay[rightcover][\useMPgraphic{rightcover}] + +\startuseMPgraphic{leftcover} + StartPage ; + pickup pencircle scaled .5pt ; + draw + bottomboundary Page & + rightboundary Page & + topboundary Page ; + draw + bottomboundary (Page enlarged 3mm) & + rightboundary (Page enlarged 3mm) & + topboundary (Page enlarged 3mm) dashed evenly ; + StopPage ; +\stopuseMPgraphic + +\startuseMPgraphic{rightcover} + StartPage ; + pickup pencircle scaled .5pt ; + draw + topboundary Page & + leftboundary Page & + bottomboundary Page ; + draw + topboundary (Page enlarged 3mm) & + leftboundary (Page enlarged 3mm) & + bottomboundary (Page enlarged 3mm) dashed evenly ; + draw + bottomboundary Page -- + lrcorner Page shifted (-5mm,-1cm) -- + llcorner Page shifted ( 5mm,-1cm) -- cycle ; + draw + topboundary Page -- + ulcorner Page shifted ( 5mm, 1cm) -- + urcorner Page shifted (-5mm, 1cm) -- cycle ; + StopPage ; + setbounds currentpicture to Page ; +\stopuseMPgraphic + +\setupmakeup + [standard] + [doublesided=no,page=] + +\setuplayout + [topspace=5mm, + backspace=5mm, + header=0pt, + footer=0pt, + width=middle, + height=middle] + +\defineframedtext + [maintext] + [background={foreground,color}, + backgroundcolor=a-bit-white, + frame=off, + before=, + after=, + align=right, + strut=no, + height=fit, + width=\textheight] + +\doifnotmode{demo}{\endinput} + +\starttext + \startstandardmakeup + page 1 + \stopstandardmakeup + + \startstandardmakeup + page 2 + \stopstandardmakeup +\stoptext diff --git a/tex/context/base/sort-ini.lua b/tex/context/base/sort-ini.lua index 11d1e8c79..6f4d7701b 100644 --- a/tex/context/base/sort-ini.lua +++ b/tex/context/base/sort-ini.lua @@ -35,7 +35,7 @@ function sorters.comparers.basic(a,b,i) -- [2] has entry, key, cmp return -1 end end - return -1 + return 1 end elseif #sort_a < #sort_b then if #sort_a == 0 then @@ -49,7 +49,7 @@ function sorters.comparers.basic(a,b,i) -- [2] has entry, key, cmp return -1 end end - return 1 + return -1 end elseif #sort_a == 0 then return 0 @@ -105,9 +105,11 @@ function sorters.strip(str) -- todo: only letters and such utf.gsub("([^%w%d])", return str end +sorters.defaultlanguage = 'en' + function sorters.splitters.utf(str) - local r = sorters.replacements[sorters.language] or { } - local m = sorters.mappings[sorters.language] or { } + local r = sorters.replacements[sorters.language] or sorters.replacements[sorters.defaultlanguage] or { } + local m = sorters.mappings [sorters.language] or sorters.mappings [sorters.defaultlanguage] or { } local u = characters.uncompose local t = { } for _,v in pairs(r) do diff --git a/tex/context/base/sort-ini.mkii b/tex/context/base/sort-ini.mkii index 6c904e8cc..3c79ef5f9 100644 --- a/tex/context/base/sort-ini.mkii +++ b/tex/context/base/sort-ini.mkii @@ -111,18 +111,26 @@ {\dowalkregime\characterencoding}}% {\dowalkregime\characterencoding}}% \egroup + \startnointerference +% \startreadingfile +\setcatcodetable\ctxcatcodes \readsysfile{\f!sortprefix def}\donothing\donothing % default +% \stopreadingfile + \stopnointerference \global\let\savesortdefinitions\relax} \def\savesortlanguage#1% language specifics {\doifsomething{#1} {\doifundefined{\f!sortprefix::#1}% - {\bgroup + {\startnointerference \global\letvalue{\f!sortprefix::#1}\empty \def\currentexportclass{#1}% \enablemode[sortorder-#1]% +% \startreadingfile +\setcatcodetable\ctxcatcodes \readsysfile{\f!sortprefix lan}\donothing\donothing - \egroup}}} +% \stopreadingfile + \stopnointerference}}} \prependtoks \savesortdefinitions diff --git a/tex/context/base/sort-ini.tex b/tex/context/base/sort-ini.tex index 75e3f2e73..2baa609fb 100644 --- a/tex/context/base/sort-ini.tex +++ b/tex/context/base/sort-ini.tex @@ -20,10 +20,12 @@ \newevery \everysavesortkeys \relax \def\savesortkeys - {\the\everysavesortkeys - \global\everysavesortkeys\emptytoks} + {\ifproductionrun + \the\everysavesortkeys + \global\everysavesortkeys\emptytoks + \fi} -\prependtoks \savesortkeys \to \everystarttext +\appendtoks \savesortkeys \to \everyshipout \loadmarkfile{sort-ini} diff --git a/tex/context/base/supp-pdf.tex b/tex/context/base/supp-pdf.tex index 61f7b32e2..248b2ce92 100644 --- a/tex/context/base/supp-pdf.tex +++ b/tex/context/base/supp-pdf.tex @@ -912,7 +912,7 @@ \def\doflushMPtext#1% {\edef\!!stringa{#1}% - \@EA\dodoflushMPtext\!!stringa\relax} + \expandafter\dodoflushMPtext\!!stringa\relax} \def\dodoflushMPtext {\afterassignment\dododoflushMPtext\let\nexttoken=} @@ -921,10 +921,10 @@ {\ifx\nexttoken\relax % done \else\ifx\nexttoken\char - \@EA\@EA\@EA\dodododoflushMPtext + \expandafter\expandafter\expandafter\dodododoflushMPtext \else {\nexttoken}% - \@EA\@EA\@EA\dodoflushMPtext + \expandafter\expandafter\expandafter\dodoflushMPtext \fi\fi} \def\dodododoflushMPtext diff --git a/tex/context/base/unic-ini.mkii b/tex/context/base/unic-ini.mkii index f78e09905..000d7f948 100644 --- a/tex/context/base/unic-ini.mkii +++ b/tex/context/base/unic-ini.mkii @@ -166,7 +166,7 @@ \def\utfdiv#1{\the\numexpr (#1-\utf@g)/\utf@h \relax} \def\utfmod#1{\the\numexpr#1-\utf@h*((#1-\utf@g)/\utf@h)\relax} -%D The next one also handles the zero case well: +%D The next one also handles the zero case well: (not really utf specific btw) \def\utfdiv#1{\the\numexpr\ifcase\numexpr#1\relax0\else (#1-\utf@g)/\utf@h \fi\relax} \def\utfmod#1{\the\numexpr\ifcase\numexpr#1\relax0\else#1-\utf@h*((#1-\utf@g)/\utf@h)\fi\relax} @@ -741,12 +741,14 @@ \endETEX +\def\numbertohexstring#1{0x\uchexnumbers{\utfdiv{#1}}\uchexnumbers{\utfmod{#1}}} + \beginXETEX - \def\numbertoutf#1{[\number#1]} % xetex has no way to output 8 bit (i.e. \rawcharacter) + \let\numbertoutf\numbertohexstring \endXETEX \beginTEX - \def\numbertoutf#1{[\number#1]} + \let\numbertoutf\numbertohexstring \endTEX \def\uchartoutf#1#2% diff --git a/tex/context/interface/keys-cz.xml b/tex/context/interface/keys-cz.xml index a426bac95..edc586842 100644 --- a/tex/context/interface/keys-cz.xml +++ b/tex/context/interface/keys-cz.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> -<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="cz" version="2007.12.18 19:11"> +<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="cz" version="2007.12.31 11:54"> <cd:variables> <cd:variable name="lesshyphenation" value="lesshyphenation"/> diff --git a/tex/context/interface/keys-de.xml b/tex/context/interface/keys-de.xml index 108de8230..2306404e7 100644 --- a/tex/context/interface/keys-de.xml +++ b/tex/context/interface/keys-de.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> -<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="de" version="2007.12.18 19:11"> +<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="de" version="2007.12.31 11:54"> <cd:variables> <cd:variable name="lesshyphenation" value="lesshyphenation"/> diff --git a/tex/context/interface/keys-en.xml b/tex/context/interface/keys-en.xml index 9462d5205..2b5c4149c 100644 --- a/tex/context/interface/keys-en.xml +++ b/tex/context/interface/keys-en.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> -<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="en" version="2007.12.18 19:11"> +<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="en" version="2007.12.31 11:54"> <cd:variables> <cd:variable name="lesshyphenation" value="lesshyphenation"/> diff --git a/tex/context/interface/keys-fr.xml b/tex/context/interface/keys-fr.xml index c2b1fa2eb..081b65034 100644 --- a/tex/context/interface/keys-fr.xml +++ b/tex/context/interface/keys-fr.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> -<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="fr" version="2007.12.18 19:11"> +<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="fr" version="2007.12.31 11:54"> <cd:variables> <cd:variable name="lesshyphenation" value="lesshyphenation"/> diff --git a/tex/context/interface/keys-it.xml b/tex/context/interface/keys-it.xml index cc225ca1e..af115a3b6 100644 --- a/tex/context/interface/keys-it.xml +++ b/tex/context/interface/keys-it.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> -<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="it" version="2007.12.18 19:11"> +<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="it" version="2007.12.31 11:54"> <cd:variables> <cd:variable name="lesshyphenation" value="lesshyphenation"/> diff --git a/tex/context/interface/keys-nl.xml b/tex/context/interface/keys-nl.xml index 9ceaa0b23..1bf5979c0 100644 --- a/tex/context/interface/keys-nl.xml +++ b/tex/context/interface/keys-nl.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> -<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="nl" version="2007.12.18 19:11"> +<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="nl" version="2007.12.31 11:54"> <cd:variables> <cd:variable name="lesshyphenation" value="lesshyphenation"/> diff --git a/tex/context/interface/keys-ro.xml b/tex/context/interface/keys-ro.xml index 18ee23dbe..9be2de966 100644 --- a/tex/context/interface/keys-ro.xml +++ b/tex/context/interface/keys-ro.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> -<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="ro" version="2007.12.18 19:11"> +<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="ro" version="2007.12.31 11:54"> <cd:variables> <cd:variable name="lesshyphenation" value="lesshyphenation"/> diff --git a/tex/generic/context/ppchtex.noc b/tex/generic/context/ppchtex.noc index 37e217599..3ab92d8f3 100644 --- a/tex/generic/context/ppchtex.noc +++ b/tex/generic/context/ppchtex.noc @@ -30,14 +30,10 @@ %D First we load some auxiliary macro's: -\let\normalunexpanded\unexpanded - \input supp-mis.tex \let\writestatus\undefined \input syst-gen.tex \input syst-fnt.tex -\let\unexpanded\normalunexpanded - %D after which we can go on with: \unprotect @@ -211,4 +207,6 @@ \setupchemical[\c!resolution=\outputresolution] \fi +\let\unexpanded\normalunexpanded + \protect \endinput |