From 4b6314243d4bc44fa3c94f569264fdffd5405e90 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Sat, 12 Mar 2016 17:15:10 +0100 Subject: 2016-03-12 16:45:00 --- tex/context/base/context-version.pdf | Bin 4176 -> 4170 bytes tex/context/base/mkiv/cldf-stp.lua | 69 ++ tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/core-env.mkiv | 4 +- tex/context/base/mkiv/file-ini.mkvi | 2 +- tex/context/base/mkiv/font-ctx.lua | 5 +- tex/context/base/mkiv/font-ext.lua | 43 + tex/context/base/mkiv/font-mis.lua | 2 +- tex/context/base/mkiv/font-otf.lua | 64 +- tex/context/base/mkiv/font-otj.lua | 63 +- tex/context/base/mkiv/font-otl.lua | 4 +- tex/context/base/mkiv/font-otn.lua | 2 +- tex/context/base/mkiv/font-otr.lua | 147 ++- tex/context/base/mkiv/font-oup.lua | 67 +- tex/context/base/mkiv/font-sty.mkvi | 2 +- tex/context/base/mkiv/lpdf-fld.lua | 66 ++ tex/context/base/mkiv/lpdf-xmp.lua | 2 +- tex/context/base/mkiv/luat-cbk.lua | 8 +- tex/context/base/mkiv/luat-cnf.lua | 22 +- tex/context/base/mkiv/luat-cod.lua | 2 +- tex/context/base/mkiv/luat-fio.lua | 4 +- tex/context/base/mkiv/luat-ini.lua | 2 + tex/context/base/mkiv/m-oldotf.mkiv | 2 +- tex/context/base/mkiv/mtx-context-trim.tex | 72 ++ tex/context/base/mkiv/node-ini.lua | 10 +- tex/context/base/mkiv/node-pro.lua | 6 +- tex/context/base/mkiv/page-imp.mkiv | 7 +- tex/context/base/mkiv/page-lay.mkiv | 2 +- tex/context/base/mkiv/page-sel.mkvi | 36 + tex/context/base/mkiv/scrn-fld.mkvi | 12 +- tex/context/base/mkiv/spac-ali.mkiv | 9 + tex/context/base/mkiv/spac-flr.mkiv | 54 +- tex/context/base/mkiv/status-files.pdf | Bin 9060 -> 8980 bytes tex/context/base/mkiv/status-lua.pdf | Bin 265951 -> 266042 bytes tex/context/base/mkiv/strc-itm.mkvi | 12 +- tex/context/base/mkiv/strc-lst.mkvi | 66 +- tex/context/base/mkiv/syst-aux.mkiv | 2 +- tex/context/base/mkiv/tabl-tab.mkiv | 1161 ++++++++++---------- tex/context/base/mkiv/task-ini.lua | 3 + tex/context/base/mkiv/toks-ini.mkiv | 1 + tex/context/base/mkiv/trac-par.lua | 2 + tex/context/base/mkiv/trac-vis.lua | 2 +- tex/context/base/mkiv/typo-bld.lua | 115 +- tex/context/base/mkiv/typo-krn.lua | 10 +- tex/context/base/mkiv/typo-lin.lua | 2 +- tex/context/base/mkiv/util-fil.lua | 6 +- tex/context/interface/common/cont-cs.xml | 3 - tex/context/interface/common/cont-de.xml | 3 - tex/context/interface/common/cont-en.xml | 3 - tex/context/interface/common/cont-fr.xml | 3 - tex/context/interface/common/cont-it.xml | 3 - tex/context/interface/common/cont-nl.xml | 3 - tex/context/interface/common/cont-pe.xml | 3 - tex/context/interface/common/cont-ro.xml | 3 - tex/generic/context/luatex/luatex-fonts-merged.lua | 57 +- 56 files changed, 1407 insertions(+), 850 deletions(-) create mode 100644 tex/context/base/mkiv/cldf-stp.lua create mode 100644 tex/context/base/mkiv/mtx-context-trim.tex (limited to 'tex') diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf index 2aa144111..e54ede916 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/mkiv/cldf-stp.lua b/tex/context/base/mkiv/cldf-stp.lua new file mode 100644 index 000000000..7b5225dd3 --- /dev/null +++ b/tex/context/base/mkiv/cldf-stp.lua @@ -0,0 +1,69 @@ +if not modules then modules = { } end modules ['cldf-stp'] = { + version = 1.001, + comment = "companion to cldf-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- limitation: input levels + +-- context.stepwise (function() +-- ... +-- context.step(nil|...) +-- ... +-- context.step(nil|...) +-- ... +-- context.stepwise (function() +-- ... +-- context.step(nil|...) +-- ... +-- context.step(nil|...) +-- ... +-- end) +-- ... +-- context.step(nil|...) +-- ... +-- context.step(nil|...) +-- ... +-- end) + +local create = coroutine.create +local yield = coroutine.yield +local resume = coroutine.resume +local status = coroutine.status + +local stepper = nil +local stack = { } -- will never be deep so no gc needed +local depth = 0 + +local nextstep = function() + if status(stepper) == "dead" then + stepper = stack[depth] + depth = depth - 1 + stack[depth] = false + end + resume(stepper) +end + +interfaces.implement { + name = "step", + actions = nextstep, +} + +local cldresume = context.constructcsonly("clf_step") + +function context.step(first,...) + if first ~= nil then + context(first,...) + end + cldresume() + yield() +end + +function context.stepwise(f) + depth = depth + 1 + stack[depth] = stepper + stepper = create(f) + resume(stepper) +end diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 5b82eabc2..d63c6f5fd 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2016.03.04 10:39} +\newcontextversion{2016.03.12 16:42} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index f495db59d..6258ec9c3 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2016.03.04 10:39} +\edef\contextversion{2016.03.12 16:42} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/core-env.mkiv b/tex/context/base/mkiv/core-env.mkiv index 47ae35d2e..e876dc80d 100644 --- a/tex/context/base/mkiv/core-env.mkiv +++ b/tex/context/base/mkiv/core-env.mkiv @@ -632,9 +632,9 @@ \unexpanded\def\resetsetups[#1]% see x-fo for usage {\ifcsname\??setup\ifgridsnapping\v!grid\fi:#1\endcsname - \dodoglobal\letbeundefined{\??setup\ifgridsnapping\v!grid\fi:#1}% + \dodoglobal\undefinevalue{\??setup\ifgridsnapping\v!grid\fi:#1}% \else - \dodoglobal\letbeundefined{\??setup:#1}% + \dodoglobal\undefinevalue{\??setup:#1}% \fi} \unexpanded\def\showsetupsdefinition[#1]% diff --git a/tex/context/base/mkiv/file-ini.mkvi b/tex/context/base/mkiv/file-ini.mkvi index cb9f18cf9..9f12e9a3b 100644 --- a/tex/context/base/mkiv/file-ini.mkvi +++ b/tex/context/base/mkiv/file-ini.mkvi @@ -234,6 +234,6 @@ \fi} \unexpanded\def\forgetdoingonce#whatever% - {\global\letbeundefined{\??fileonce#whatever}} + {\global\undefinevalue{\??fileonce#whatever}} \protect \endinput diff --git a/tex/context/base/mkiv/font-ctx.lua b/tex/context/base/mkiv/font-ctx.lua index 8b8934c92..be233e570 100644 --- a/tex/context/base/mkiv/font-ctx.lua +++ b/tex/context/base/mkiv/font-ctx.lua @@ -2212,6 +2212,7 @@ end do + local kerncodes = nodes.kerncodes local copy_node = nuts.copy local kern = nuts.pool.register(nuts.pool.kern()) @@ -2223,7 +2224,9 @@ do return c end) - directives.register("nodes.injections.fontkern", function(v) setsubtype(kern,v and 0 or 1) end) + directives.register("fonts.injections.fontkern", function(v) + setsubtype(kern,v and kerncodes.fontkern or kerncodes.userkern) + end) end diff --git a/tex/context/base/mkiv/font-ext.lua b/tex/context/base/mkiv/font-ext.lua index f153d5624..fc161f59a 100644 --- a/tex/context/base/mkiv/font-ext.lua +++ b/tex/context/base/mkiv/font-ext.lua @@ -7,6 +7,7 @@ if not modules then modules = { } end modules ['font-ext'] = { } local next, type, byte = next, type, string.byte +local utfbyte = utf.byte local context = context local fonts = fonts @@ -855,6 +856,47 @@ registerotffeature { } } +-- -- for notosans but not general +-- +-- do +-- +-- local v_local = interfaces and interfaces.variables and interfaces.variables["local"] or "local" +-- +-- local function initialize(tfmdata,key,value) +-- local characters = tfmdata.characters +-- local parameters = tfmdata.parameters +-- local oldchar = 32 +-- local newchar = 32 +-- if value == "locl" or value == v_local then +-- newchar = fonts.handlers.otf.getsubstitution(tfmdata,oldchar,"locl",true) or oldchar +-- elseif value == true then +-- -- use normal space +-- elseif value then +-- newchar = utfbyte(value) +-- else +-- return +-- end +-- local newchar = newchar and characters[newchar] +-- local newspace = newchar and newchar.width +-- if newspace > 0 then +-- parameters.space = newspace +-- parameters.space_stretch = newspace/2 +-- parameters.space_shrink = newspace/3 +-- parameters.extra_space = parameters.space_shrink +-- end +-- end +-- +-- registerotffeature { +-- name = 'space', -- true|false|locl|character +-- description = 'space settings', +-- manipulators = { +-- base = initialize, +-- node = initialize, +-- } +-- } +-- +-- end + -- -- historic stuff, move from font-ota (handled differently, typo-rep) -- -- local delete_node = nodes.delete @@ -995,3 +1037,4 @@ implement { context(getprivatenode(fontdata[currentfont()],name)) end } + diff --git a/tex/context/base/mkiv/font-mis.lua b/tex/context/base/mkiv/font-mis.lua index d3d733723..7d73b457e 100644 --- a/tex/context/base/mkiv/font-mis.lua +++ b/tex/context/base/mkiv/font-mis.lua @@ -22,7 +22,7 @@ local handlers = fonts.handlers handlers.otf = handlers.otf or { } local otf = handlers.otf -otf.version = otf.version or 2.820 +otf.version = otf.version or 2.823 otf.cache = otf.cache or containers.define("fonts", "otf", otf.version, true) local fontloader = fontloader diff --git a/tex/context/base/mkiv/font-otf.lua b/tex/context/base/mkiv/font-otf.lua index e90ec738f..e71a57cbe 100644 --- a/tex/context/base/mkiv/font-otf.lua +++ b/tex/context/base/mkiv/font-otf.lua @@ -26,7 +26,7 @@ local type, next, tonumber, tostring = type, next, tonumber, tostring local abs = math.abs local reversed, concat, insert, remove, sortedkeys = table.reversed, table.concat, table.insert, table.remove, table.sortedkeys local ioflush = io.flush -local fastcopy, tohash, derivetable = table.fastcopy, table.tohash, table.derive +local fastcopy, tohash, derivetable, copy = table.fastcopy, table.tohash, table.derive, table.copy local formatters = string.formatters local P, R, S, C, Ct, lpegmatch = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Ct, lpeg.match @@ -58,7 +58,7 @@ local otf = fonts.handlers.otf otf.glists = { "gsub", "gpos" } -otf.version = 2.820 -- beware: also sync font-mis.lua and in mtx-fonts +otf.version = 2.823 -- beware: also sync font-mis.lua and in mtx-fonts otf.cache = containers.define("fonts", "otf", otf.version, true) local hashes = fonts.hashes @@ -232,6 +232,7 @@ local valid_fields = table.tohash { -- "lookups", "macstyle", -- "modificationtime", + "notdef_loc", "onlybitmaps", "origname", "os2_version", @@ -259,6 +260,7 @@ local valid_fields = table.tohash { "weight", "weight_width_slope_only", -- "xuid", + -- "truetype", -- maybe as check } local ordered_enhancers = { @@ -645,9 +647,6 @@ actions["add dimensions"] = function(data,filename) report_otf("mark %a with width %b found in %a",d.name or "",wd,basename) -- d.width = -wd end - -- if forcenotdef and not d.name then - -- d.name = ".notdef" - -- end if bb then local ht = bb[4] local dp = -bb[2] @@ -710,7 +709,6 @@ end -- not setting hasitalics and class (when nil) during table construction can save some mem actions["prepare glyphs"] = function(data,filename,raw) - local tableversion = tonumber(raw.table_version) or 0 local rawglyphs = raw.glyphs local rawsubfonts = raw.subfonts local rawcidinfo = raw.cidinfo @@ -724,6 +722,7 @@ actions["prepare glyphs"] = function(data,filename,raw) local indices = resources.indices -- index to unicode local duplicates = resources.duplicates local variants = resources.variants + local notdefindex = -1 if rawsubfonts then @@ -746,16 +745,12 @@ actions["prepare glyphs"] = function(data,filename,raw) if includesubfonts then metadata.subfonts[cidindex] = somecopy(subfont) end - local cidcnt, cidmin, cidmax - if tableversion > 0.3 then - -- we have delayed loading so we cannot use next - cidcnt = subfont.glyphcnt - cidmin = subfont.glyphmin - cidmax = subfont.glyphmax - else - cidcnt = subfont.glyphcnt - cidmin = 0 - cidmax = cidcnt - 1 + local cidcnt = subfont.glyphcnt + local cidmin = subfont.glyphmin + local cidmax = subfont.glyphmax + local notdef = (tonumber(raw.table_version) or 0) > 0.4 and subfont.notdef_loc or -1 + if notdeffound == -1 and notdef >= 0 then + notdeffound = notdef end if trace_subfonts then local cidtot = cidmax - cidmin + 1 @@ -763,10 +758,9 @@ actions["prepare glyphs"] = function(data,filename,raw) report_otf("subfont: %i, min: %i, max: %i, cnt: %i, n: %i",cidindex,cidmin,cidmax,cidtot,cidcnt) end if cidcnt > 0 then - for cidslot=cidmin,cidmax do - local glyph = cidglyphs[cidslot] + for index=cidmin,cidmax do + local glyph = cidglyphs[index] if glyph then - local index = tableversion > 0.3 and glyph.orig_pos or cidslot if trace_subfonts then unique[index] = true end @@ -797,7 +791,7 @@ actions["prepare glyphs"] = function(data,filename,raw) if trace_private then report_otf("glyph %a at index %H is moved to private unicode slot %U",name,index,private) end - private = private + 1 + private = private + 1 nofnames = nofnames + 1 else -- if unicode > criterium then @@ -824,8 +818,8 @@ actions["prepare glyphs"] = function(data,filename,raw) boundingbox = glyph.boundingbox, -- name = glyph.name or name or "unknown", -- uniXXXX name = name or "unknown", -- uniXXXX - cidindex = cidindex, - index = cidslot, + -- cidindex = cidindex, + index = index, glyph = glyph, } descriptions[unicode] = description @@ -880,10 +874,10 @@ actions["prepare glyphs"] = function(data,filename,raw) else local cnt = raw.glyphcnt or 0 - local min = tableversion > 0.3 and raw.glyphmin or 0 - local max = tableversion > 0.3 and raw.glyphmax or (raw.glyphcnt - 1) + local min = raw.glyphmin or 0 + local max = raw.glyphmax or (raw.glyphcnt - 1) + notdeffound = (tonumber(raw.table_version) or 0) > 0.4 and raw.notdef_loc or -1 if cnt > 0 then --- for index=0,cnt-1 do for index=min,max do local glyph = rawglyphs[index] if glyph then @@ -974,6 +968,13 @@ actions["prepare glyphs"] = function(data,filename,raw) end + if notdeffound == -1 then + report_otf("warning: no .notdef found in %a",filename) + elseif notdeffound ~= 0 then + report_otf("warning: .notdef found at position %a in %a",notdeffound,filename) + end + metadata.notdef = notdeffound + resources.private = private end @@ -1071,7 +1072,8 @@ actions["add duplicates"] = function(data,filename,raw) local unicodes = resources.unicodes -- name to unicode local indices = resources.indices -- index to unicodes local duplicates = resources.duplicates - for unicode, d in next, duplicates do + -- for unicode, d in next, duplicates do + for unicode, d in table.sortedhash(duplicates) do -- nicer for log local nofduplicates = #d if nofduplicates > 4 then if trace_loading then @@ -1098,12 +1100,12 @@ actions["add duplicates"] = function(data,filename,raw) -- todo: lookups etc end if u > 0 then -- and - local duplicate = table.copy(description) -- else packing problem + local duplicate = copy(description) -- else packing problem duplicate.comment = formatters["copy of %U"](unicode) descriptions[u] = duplicate -- validduplicates[#validduplicates+1] = u if trace_loading then - report_otf("duplicating %U to %U with index %H (%s kerns)",unicode,u,description.index,n) + report_otf("duplicating %06U to %06U with index %H (%s kerns)",unicode,u,description.index,n) end end end @@ -2131,9 +2133,10 @@ actions["check metadata"] = function(data,filename,raw) end end -- + local state = metadata.validation_state local names = raw.names -- - if metadata.validation_state and table.contains(metadata.validation_state,"bad_ps_fontname") then + if state and table.contains(state,"bad_ps_fontname") then -- the ff library does a bit too much (and wrong) checking ... so we need to catch this -- at least for now local function valid(what) @@ -2196,6 +2199,9 @@ actions["check metadata"] = function(data,filename,raw) metadata.psname = psname end -- + if state and table.contains(state,"bad_cmap_table") then + report_otf("fontfile %a has bad cmap tables",filename) + end end actions["cleanup tables"] = function(data,filename,raw) diff --git a/tex/context/base/mkiv/font-otj.lua b/tex/context/base/mkiv/font-otj.lua index db30ff9cd..1fd12324e 100644 --- a/tex/context/base/mkiv/font-otj.lua +++ b/tex/context/base/mkiv/font-otj.lua @@ -21,15 +21,22 @@ if not modules then modules = { } end modules ['font-otj'] = { -- As we have a rawget on properties we don't need one on injections. +-- The use_advance code is just a test and is meant for testing and manuals. There is no +-- performance (or whatever) gain and using kerns is somewhat cleaner (at least for now). + if not nodes.properties then return end local next, rawget = next, rawget local utfchar = utf.char local fastcopy = table.fastcopy -local trace_injections = false trackers.register("fonts.injections", function(v) trace_injections = v end) -local trace_marks = false trackers.register("fonts.injections.marks", function(v) trace_marks = v end) -local trace_cursive = false trackers.register("fonts.injections.cursive", function(v) trace_cursive = v end) +local trace_injections = false trackers.register("fonts.injections", function(v) trace_injections = v end) +local trace_marks = false trackers.register("fonts.injections.marks", function(v) trace_marks = v end) +local trace_cursive = false trackers.register("fonts.injections.cursive", function(v) trace_cursive = v end) + +-- use_advance is just an experiment: it makes copying glyphs (instead of new_glyph) dangerous + +local use_advance = false directives.register("fonts.injections.advance", function(v) use_advance = v end) local report_injections = logs.reporter("fonts","injections") @@ -553,7 +560,12 @@ local function inject_kerns_only(head,where) -- left|glyph|right local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - insert_node_before(head,current,newkern(leftkern)) + if use_advance then + setfield(current,"xoffset",leftkern) + setfield(current,"xadvance",leftkern) + else + insert_node_before(head,current,newkern(leftkern)) + end end end if prevdisc then @@ -565,8 +577,12 @@ local function inject_kerns_only(head,where) local leftkern = i.leftkern if leftkern and leftkern ~= 0 then local posttail = find_tail(post) - insert_node_after(post,posttail,newkern(leftkern)) - done = true + if use_advance then + setfield(post,"xadvance",leftkern) + else + insert_node_after(post,posttail,newkern(leftkern)) + done = true + end end end end @@ -577,8 +593,12 @@ local function inject_kerns_only(head,where) local leftkern = i.leftkern if leftkern and leftkern ~= 0 then local replacetail = find_tail(replace) - insert_node_after(replace,replacetail,newkern(leftkern)) - done = true + if use_advance then + setfield(replace,"xadvance",leftkern) + else + insert_node_after(replace,replacetail,newkern(leftkern)) + done = true + end end end end @@ -603,8 +623,13 @@ local function inject_kerns_only(head,where) if i then local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - pre = insert_node_before(pre,n,newkern(leftkern)) - done = true + if use_advance then + setfield(pre,"xoffset",leftkern) + setfield(pre,"xadvance",leftkern) + else + pre = insert_node_before(pre,n,newkern(leftkern)) + done = true + end end end end @@ -620,8 +645,13 @@ local function inject_kerns_only(head,where) if i then local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - post = insert_node_before(post,n,newkern(leftkern)) - done = true + if use_advance then + setfield(post,"xoffset",leftkern) + setfield(post,"xadvance",leftkern) + else + post = insert_node_before(post,n,newkern(leftkern)) + done = true + end end end end @@ -637,8 +667,13 @@ local function inject_kerns_only(head,where) if i then local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - replace = insert_node_before(replace,n,newkern(leftkern)) - done = true + if use_advance then + setfield(replace,"xoffset",leftkern) + setfield(replace,"xadvance",leftkern) + else + replace = insert_node_before(replace,n,newkern(leftkern)) + done = true + end end end end diff --git a/tex/context/base/mkiv/font-otl.lua b/tex/context/base/mkiv/font-otl.lua index f4b889b75..99aae33b5 100644 --- a/tex/context/base/mkiv/font-otl.lua +++ b/tex/context/base/mkiv/font-otl.lua @@ -53,7 +53,7 @@ local report_otf = logs.reporter("fonts","otf loading") local fonts = fonts local otf = fonts.handlers.otf -otf.version = 3.013 -- beware: also sync font-mis.lua and in mtx-fonts +otf.version = 3.015 -- beware: also sync font-mis.lua and in mtx-fonts otf.cache = containers.define("fonts", "otl", otf.version, true) local otfreaders = otf.readers @@ -482,7 +482,7 @@ local function copytotfm(data,cache_id) -- parameters.slant = 0 parameters.space = spaceunits -- 3.333 (cmr10) - parameters.space_stretch = units/2 -- 500 -- 1.666 (cmr10) + parameters.space_stretch = 1*units/2 -- 500 -- 1.666 (cmr10) parameters.space_shrink = 1*units/3 -- 333 -- 1.111 (cmr10) parameters.x_height = 2*units/5 -- 400 parameters.quad = units -- 1000 diff --git a/tex/context/base/mkiv/font-otn.lua b/tex/context/base/mkiv/font-otn.lua index e1228d004..1c17e889d 100644 --- a/tex/context/base/mkiv/font-otn.lua +++ b/tex/context/base/mkiv/font-otn.lua @@ -846,7 +846,7 @@ function handlers.gsub_ligature(head,start,kind,lookupname,ligature,sequence) return head, start, false, discfound end -function handlers.gpos_single(head,start,kind,lookupname,kerns,sequence,injection) +function handlers.gpos_single(head,start,kind,lookupname,kerns,sequence,lookuphash,i,injection) local startchar = getchar(start) local dx, dy, w, h = setpair(start,tfmdata.parameters.factor,rlmode,sequence.flags[4],kerns,injection) -- ,characters[startchar]) if trace_kerns then diff --git a/tex/context/base/mkiv/font-otr.lua b/tex/context/base/mkiv/font-otr.lua index 7e5cf56f1..5839cbfb5 100644 --- a/tex/context/base/mkiv/font-otr.lua +++ b/tex/context/base/mkiv/font-otr.lua @@ -72,7 +72,7 @@ end local next, type, unpack = next, type, unpack local byte, lower, char, strip, gsub = string.byte, string.lower, string.char, string.strip, string.gsub local bittest = bit32.btest -local concat, remove = table.concat, table.remove +local concat, remove, unpack = table.concat, table.remov, table.unpack local floor, mod, abs, sqrt, round = math.floor, math.mod, math.abs, math.sqrt, math.round local P, R, S, C, Cs, Cc, Ct, Carg, Cmt = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Cs, lpeg.Cc, lpeg.Ct, lpeg.Carg, lpeg.Cmt local lpegmatch = lpeg.match @@ -133,7 +133,7 @@ local function readlongdatetime(f) return 0x100000000 * d + 0x1000000 * e + 0x10000 * f + 0x100 * g + h end -local tableversion = 0.002 +local tableversion = 0.004 local privateoffset = fonts.constructors and fonts.constructors.privateoffset or 0xF0000 -- 0x10FFFF readers.tableversion = tableversion @@ -909,7 +909,7 @@ readers.head = function(f,fontdata) else fontdata.fontheader = { } end - fontdata.nofglyphs = 0 + fontdata.nofglyphs = 0 end -- This table is a rather simple one. No treatment of values is needed here. Most @@ -1116,6 +1116,47 @@ end local formatreaders = { } local duplicatestoo = true +local sequence = { + { 3, 1, 4 }, + { 3, 10, 12 }, + { 0, 3, 4 }, + { 0, 1, 4 }, + -- { 0, 4, 12 }, + { 0, 0, 6 }, + { 3, 0, 6 }, + -- variants + { 0, 5, 14 }, +} + +-- local sequence = { +-- { 0, 1, 4 }, +-- { 0, 4, 12 }, +-- { 0, 3, 4 }, +-- { 3, 1, 4 }, +-- { 3, 10, 12 }, +-- { 0, 0, 6 }, +-- { 3, 0, 6 }, +-- -- variants +-- { 0, 5, 14 }, +-- } + +local supported = { } + +for i=1,#sequence do + local sp, se, sf = unpack(sequence[i]) + local p = supported[sp] + if not p then + p = { } + supported[sp] = p + end + local e = p[se] + if not e then + e = { } + p[se] = e + end + e[sf] = true +end + formatreaders[4] = function(f,fontdata,offset) setposition(f,offset+2) -- skip format -- @@ -1133,6 +1174,7 @@ formatreaders[4] = function(f,fontdata,offset) local mapping = fontdata.mapping local glyphs = fontdata.glyphs local duplicates = fontdata.duplicates + local nofdone = 0 -- for i=1,nofsegments do endchars[i] = readushort(f) @@ -1159,19 +1201,24 @@ formatreaders[4] = function(f,fontdata,offset) local offset = offsets[segment] local delta = deltas[segment] if startchar == 0xFFFF and endchar == 0xFFFF then - break + -- break + elseif startchar == 0xFFFF and offset == 0 then + -- break + elseif offset == 0xFFFF then + -- bad encoding elseif offset == 0 then if trace_cmap then - report("format 4.%i from %C to %C at index %H",1,startchar,endchar,mod(startchar + delta,65536)) + report("format 4.%i segment %2i from %C upto %C at index %H",1,segment,startchar,endchar,mod(startchar + delta,65536)) end for unicode=startchar,endchar do - index = mod(unicode + delta,65536) + local index = mod(unicode + delta,65536) if index and index > 0 then local glyph = glyphs[index] if glyph then local gu = glyph.unicode if not gu then glyph.unicode = unicode + nofdone = nofdone + 1 elseif gu ~= unicode then if duplicatestoo then local d = duplicates[gu] @@ -1194,7 +1241,7 @@ formatreaders[4] = function(f,fontdata,offset) else local shift = (segment-nofsegments+offset/2) - startchar if trace_cmap then - report("format 4.%i from %C to %C at index %H",2,startchar,endchar,mod(indices[shift+startchar]+delta,65536)) + report("format 4.%i segment %2i from %C upto %C at index %H",0,segment,startchar,endchar,mod(startchar + delta,65536)) end for unicode=startchar,endchar do local slot = shift + unicode @@ -1206,6 +1253,7 @@ formatreaders[4] = function(f,fontdata,offset) local gu = glyph.unicode if not gu then glyph.unicode = unicode + nofdone = nofdone + 1 elseif gu ~= unicode then if duplicatestoo then local d = duplicates[gu] @@ -1227,7 +1275,7 @@ formatreaders[4] = function(f,fontdata,offset) end end end - + return nofdone end formatreaders[6] = function(f,fontdata,offset) @@ -1241,6 +1289,7 @@ formatreaders[6] = function(f,fontdata,offset) local start = readushort(f) local count = readushort(f) local stop = start+count-1 + local nofdone = 0 if trace_cmap then report("format 6 from %C to %C",2,start,stop) end @@ -1252,6 +1301,7 @@ formatreaders[6] = function(f,fontdata,offset) local gu = glyph.unicode if not gu then glyph.unicode = unicode + nofdone = nofdone + 1 elseif gu ~= unicode then -- report("format 6 overloading %C to %C",gu,unicode) -- glyph.unicode = unicode @@ -1263,6 +1313,7 @@ formatreaders[6] = function(f,fontdata,offset) end end end + return nofdone end formatreaders[12] = function(f,fontdata,offset) @@ -1271,6 +1322,7 @@ formatreaders[12] = function(f,fontdata,offset) local glyphs = fontdata.glyphs local duplicates = fontdata.duplicates local nofgroups = readulong(f) + local nofdone = 0 for i=1,nofgroups do local first = readulong(f) local last = readulong(f) @@ -1284,6 +1336,7 @@ formatreaders[12] = function(f,fontdata,offset) local gu = glyph.unicode if not gu then glyph.unicode = unicode + nofdone = nofdone + 1 elseif gu ~= unicode then -- e.g. sourcehan fonts need this local d = duplicates[gu] @@ -1298,8 +1351,9 @@ formatreaders[12] = function(f,fontdata,offset) end end index = index + 1 - end + end end + return nofdone end formatreaders[14] = function(f,fontdata,offset) @@ -1310,6 +1364,7 @@ formatreaders[14] = function(f,fontdata,offset) local nofrecords = readulong(f) local records = { } local variants = { } + local nofdone = 0 fontdata.variants = variants for i=1,nofrecords do records[i] = { @@ -1345,32 +1400,38 @@ formatreaders[14] = function(f,fontdata,offset) for i=1,count do mapping[readuint(f)] = readushort(f) end + nofdone = nofdone + count variants[selector] = mapping end end + return nofdone + else + return 0 end end local function checkcmap(f,fontdata,records,platform,encoding,format) local data = records[platform] if not data then - return + return 0 end data = data[encoding] if not data then - return + return 0 end data = data[format] if not data then - return + return 0 end local reader = formatreaders[format] if not reader then - return + return 0 end - report("checking cmap: platform %a, encoding %a, format %a",platform,encoding,format) - reader(f,fontdata,data) - return true + local p = platforms[platform] + local e = encodings[p] + local n = reader(f,fontdata,data) or 0 + report("cmap checked: platform %i (%s), encoding %i (%s), format %i, new unicodes %i",platform,p,encoding,e and e[encoding] or "?",format,n) + return n end function readers.cmap(f,fontdata,specification) @@ -1412,8 +1473,25 @@ function readers.cmap(f,fontdata,specification) end end end - for platform, record in next, records do - for encoding, subtables in next, record do + report("found cmaps:") + for platform, record in sortedhash(records) do + local p = platforms[platform] + local e = encodings[p] + local sp = supported[platform] + local ps = p or "?" + if sp then + report(" platform %i: %s",platform,ps) + else + report(" platform %i: %s (unsupported)",platform,ps) + end + for encoding, subtables in sortedhash(record) do + local se = sp and sp[encoding] + local es = e and e[encoding] or "?" + if se then + report(" encoding %i: %s",encoding,es) + else + report(" encoding %i: %s (unsupported)",encoding,es) + end local offsets = subtables.offsets local formats = subtables.formats for i=1,#offsets do @@ -1422,31 +1500,26 @@ function readers.cmap(f,fontdata,specification) formats[readushort(f)] = offset end record[encoding] = formats + local list = sortedkeys(formats) + for i=1,#list do + if not (se and se[list[i]]) then + list[i] = list[i] .. " (unsupported)" + end + end + report(" formats: % t",list) end end -- local ok = false - ok = checkcmap(f,fontdata,records,3, 1, 4) or ok - ok = checkcmap(f,fontdata,records,3,10,12) or ok - ok = checkcmap(f,fontdata,records,0, 3, 4) or ok - ok = checkcmap(f,fontdata,records,0, 1, 4) or ok - ok = checkcmap(f,fontdata,records,0, 0, 6) or ok - ok = checkcmap(f,fontdata,records,3, 0, 6) or ok - -- ok = checkcmap(f,fontdata,records,3, 0, 4) or ok -- maybe - -- 1 0 0 - if not ok then - local list = { } - for k1, v1 in next, records do - for k2, v2 in next, v1 do - for k3, v3 in next, v2 do - list[#list+1] = formatters["%s.%s.%s"](k1,k2,k3) - end - end + for i=1,#sequence do + local sp, se, sf = unpack(sequence[i]) + if checkcmap(f,fontdata,records,sp,se,sf) > 0 then + ok = true end - table.sort(list) - report("no unicode cmap record loaded, found tables: % t",list) end - checkcmap(f,fontdata,records,0,5,14) -- variants + if not ok then + report("no useable unicode cmap found") + end -- fontdata.cidmaps = { version = version, diff --git a/tex/context/base/mkiv/font-oup.lua b/tex/context/base/mkiv/font-oup.lua index 004e487c5..b184a7f7f 100644 --- a/tex/context/base/mkiv/font-oup.lua +++ b/tex/context/base/mkiv/font-oup.lua @@ -26,7 +26,8 @@ local privateoffset = fonts.constructors and fonts.constructors.privateoffse local f_private = formatters["P%05X"] local f_unicode = formatters["U%05X"] local f_index = formatters["I%05X"] -local f_character = formatters["%C"] +local f_character_y = formatters["%C"] +local f_character_n = formatters["[ %C ]"] local doduplicates = true -- can become an option (pseudo feature) @@ -137,7 +138,7 @@ local function unifyresources(fontdata,indices) end -- -- the duplicates need checking (probably only in cjk fonts): currently we only check - -- gsub_single, gsub_alternate and gsub_multiple + -- gsub_single, gsub_alternate, gsub_multiple, gpos_single and gpos_cursive -- local function unifythem(sequences) if not sequences then @@ -269,14 +270,56 @@ local function unifyresources(fontdata,indices) done[c] = c end end - elseif kind == "gpos_single" or kind == "gpos_cursive" then + elseif kind == "gpos_single" then local c = step.coverage if c then local t1 = done[c] if not t1 then t1 = { } - for g1, d1 in next, c do - t1[indices[g1]] = d1 + if duplicates then + for g1, d1 in next, c do + local ug1 = indices[g1] + t1[ug1] = d1 + -- + local dg1 = duplicates[ug1] + if dg1 then + for u in next, dg1 do + t1[u] = d1 + end + end + end + else + for g1, d1 in next, c do + t1[indices[g1]] = d1 + end + end + done[c] = t1 + end + step.coverage = t1 + end + elseif kind == "gpos_cursive" then + local c = step.coverage + if c then + local t1 = done[c] + if not t1 then + t1 = { } + if duplicates then + for g1, d1 in next, c do + local ug1 = indices[g1] + t1[ug1] = d1 + -- + local dg1 = duplicates[ug1] + if dg1 then + -- probably needs a bit more + for u in next, dg1 do + t1[u] = copy(d1) + end + end + end + else + for g1, d1 in next, c do + t1[indices[g1]] = d1 + end end done[c] = t1 end @@ -324,10 +367,16 @@ local function copyduplicates(fontdata) for u, d in next, duplicates do local du = descriptions[u] if du then - local t = { f_character(u) } + local t = { f_character_y(u), "@", f_index(du.index), "->" } for u in next, d do - descriptions[u] = copy(du) - t[#t+1] = f_character(u) + if descriptions[u] then + t[#t+1] = f_character_n(u) + else + local c = copy(du) + -- c.unicode = u -- maybe + descriptions[u] = c + t[#t+1] = f_character_y(u) + end end report("duplicates: % t",t) else @@ -600,7 +649,7 @@ local function unifyglyphs(fontdata,usenames) private = private + 1 elseif descriptions[unicode] then -- real weird -report("assigning private unicode %U to glyph indexed %05X (%C)",private,index,unicode) + report("assigning private unicode %U to glyph indexed %05X (%C)",private,index,unicode) unicode = private -- glyph.unicode = -1 if names then diff --git a/tex/context/base/mkiv/font-sty.mkvi b/tex/context/base/mkiv/font-sty.mkvi index 48b81b55a..6b2c072e5 100644 --- a/tex/context/base/mkiv/font-sty.mkvi +++ b/tex/context/base/mkiv/font-sty.mkvi @@ -337,7 +337,7 @@ {\iffirstargument \setuvalue{#name}{\styleinstance[#name]}% \def\font_styles_define_style_collection_a#style% - {\def\font_styles_define_style_collection_b#alternative{\letbeundefined{\??stylecollection#name:#style:#alternative}}% + {\def\font_styles_define_style_collection_b#alternative{\undefinevalue{\??stylecollection#name:#style:#alternative}}% \font_helpers_process_alternative_list\font_styles_define_style_collection_b \font_styles_define_style_collection_b\s!default}% \font_helpers_process_style_list\font_styles_define_style_collection_a diff --git a/tex/context/base/mkiv/lpdf-fld.lua b/tex/context/base/mkiv/lpdf-fld.lua index 7e2cd4bdf..75d0ba98e 100644 --- a/tex/context/base/mkiv/lpdf-fld.lua +++ b/tex/context/base/mkiv/lpdf-fld.lua @@ -105,6 +105,7 @@ local submitoutputformat = 0 -- 0=unknown 1=HTML 2=FDF 3=XML => not yet local pdf_widget = pdfconstant("Widget") local pdf_tx = pdfconstant("Tx") +local pdf_sig = pdfconstant("Sig") local pdf_ch = pdfconstant("Ch") local pdf_btn = pdfconstant("Btn") ----- pdf_yes = pdfconstant("Yes") @@ -1042,6 +1043,71 @@ function methods.text(name,specification) return makelinechild(name,enhance(specification,"MultiLine")) end +-- copy of line ... probably also needs a /Lock + +local function makesignatureparent(field,specification) + local text = pdfunicode(field.default) + local length = tonumber(specification.length or 0) or 0 + local d = pdfdictionary { + Subtype = pdf_widget, + T = pdfunicode(specification.title), + F = fieldplus(specification), + Ff = fieldflag(specification), + OC = fieldlayer(specification), + DA = fieldsurrounding(specification), + AA = fieldactions(specification), + FT = pdf_sig, + Q = fieldalignment(specification), + MaxLen = length == 0 and 1000 or length, + DV = text, + V = text, + } + save_parent(field,specification,d) +end + +local function makesignaturechild(name,specification) + local field, parent = clones[name], nil + if field then + parent = fields[field.parent] + if not parent.pobj then + if trace_fields then + report_fields("forcing parent signature %a",parent.name) + end + makesignatureparent(parent,specification) + end + else + parent = fields[name] + field = parent + if not parent.pobj then + if trace_fields then + report_fields("using parent text %a",name) + end + makesignatureparent(parent,specification) + end + end + if trace_fields then + report_fields("using child text %a",name) + end + -- we could save a little by not setting some key/value when it's the + -- same as parent but it would cost more memory to keep track of it + local d = pdfdictionary { + Subtype = pdf_widget, + Parent = pdfreference(parent.pobj), + F = fieldplus(specification), + OC = fieldlayer(specification), + DA = fieldsurrounding(specification), + AA = fieldactions(specification), + MK = fieldrendering(specification), + Q = fieldalignment(specification), + } + return save_kid(parent,specification,d) +end + +function methods.signature(name,specification) + return makesignaturechild(name,specification) +end +-- + local function makechoiceparent(field,specification) local d = pdfdictionary { Subtype = pdf_widget, diff --git a/tex/context/base/mkiv/lpdf-xmp.lua b/tex/context/base/mkiv/lpdf-xmp.lua index 4526b3738..f372b3461 100644 --- a/tex/context/base/mkiv/lpdf-xmp.lua +++ b/tex/context/base/mkiv/lpdf-xmp.lua @@ -166,7 +166,7 @@ local function flushxmpinfo() local documentid = format("uuid:%s",os.uuid()) local instanceid = format("uuid:%s",os.uuid()) - local producer = format("LuaTeX-%0.2f.%s",tex.luatexversion/100,tex.luatexrevision) + local producer = format("LuaTeX-%0.2f.%s",status.luatex_version/100,status.luatex_revision) local creator = "LuaTeX + ConTeXt MkIV" local time = lpdf.timestamp() local fullbanner = status.banner diff --git a/tex/context/base/mkiv/luat-cbk.lua b/tex/context/base/mkiv/luat-cbk.lua index 5e2d0e0cb..2c3bede72 100644 --- a/tex/context/base/mkiv/luat-cbk.lua +++ b/tex/context/base/mkiv/luat-cbk.lua @@ -137,12 +137,8 @@ local function register_usercall(what,name,func) end end -local function frozen_message(what,name) - report_callbacks("not %s frozen %a",what,name) -end - local function frozen_callback(name) - frozen_message("registering",name) + report_callbacks("not %s frozen %a","registering",name) return nil, format("callback '%s' is frozen",name) -- no formatter yet end @@ -228,7 +224,7 @@ function callbacks.push(name,func) register_callback(name,func) end else - frozen_message("pushing",name) + report_callbacks("not %s frozen %a","pushing",name) end end diff --git a/tex/context/base/mkiv/luat-cnf.lua b/tex/context/base/mkiv/luat-cnf.lua index 3d9889c0b..83622ef53 100644 --- a/tex/context/base/mkiv/luat-cnf.lua +++ b/tex/context/base/mkiv/luat-cnf.lua @@ -19,21 +19,17 @@ texconfig.shell_escape = 't' luatex = luatex or { } local luatex = luatex -texconfig.max_print_line = 100000 -- frozen -texconfig.max_in_open = 127 -- frozen texconfig.error_line = 79 -- frozen +texconfig.expand_depth = 10000 texconfig.half_error_line = 50 -- frozen - -texconfig.expand_depth = 10000 -- 10000 -texconfig.hash_extra = 100000 -- 0 -texconfig.nest_size = 1000 -- 50 -texconfig.max_in_open = 500 -- 15 -- in fact it's limited to 127 -texconfig.max_print_line = 10000 -- 79 -texconfig.max_strings = 500000 -- 15000 -texconfig.param_size = 25000 -- 60 -texconfig.save_size = 50000 -- 4000 -texconfig.save_size = 100000 -- 4000 -texconfig.stack_size = 10000 -- 300 +texconfig.hash_extra = 100000 +texconfig.max_in_open = 1000 -- frozen +texconfig.max_print_line = 100000 -- frozen +texconfig.max_strings = 500000 +texconfig.nest_size = 1000 +texconfig.param_size = 25000 +texconfig.save_size = 100000 +texconfig.stack_size = 10000 local stub = [[ diff --git a/tex/context/base/mkiv/luat-cod.lua b/tex/context/base/mkiv/luat-cod.lua index 51610ee87..f62396a8e 100644 --- a/tex/context/base/mkiv/luat-cod.lua +++ b/tex/context/base/mkiv/luat-cod.lua @@ -16,7 +16,7 @@ local texconfig, lua = texconfig, lua texconfig.kpse_init = false texconfig.shell_escape = 't' texconfig.max_print_line = 100000 -texconfig.max_in_open = 127 +texconfig.max_in_open = 1000 -- registering bytecode chunks diff --git a/tex/context/base/mkiv/luat-fio.lua b/tex/context/base/mkiv/luat-fio.lua index 43f7d6486..2b083b582 100644 --- a/tex/context/base/mkiv/luat-fio.lua +++ b/tex/context/base/mkiv/luat-fio.lua @@ -12,8 +12,8 @@ local sequenced = table.sequenced texconfig.kpse_init = false texconfig.shell_escape = 't' -texconfig.max_in_open = 127 texconfig.max_print_line = 100000 +texconfig.max_in_open = 1000 if not resolvers.instance then @@ -80,7 +80,7 @@ if not resolvers.instance then register('find_data_file' , function(name) return findbinfile(name,"tex") end, true) register('find_enc_file' , function(name) return findbinfile(name,"enc") end, true) register('find_font_file' , function(name) return findbinfile(name,"tfm") end, true) - register('find_format_file' , function(name) return findbinfile(name,"fmt") end, true) + -- register('find_format_file' , function(name) return findbinfile(name,"fmt") end, true) register('find_image_file' , function(name) return findbinfile(name,"tex") end, true) register('find_map_file' , function(name) return findbinfile(name,"map") end, true) register('find_opentype_file' , function(name) return findbinfile(name,"otf") end, true) diff --git a/tex/context/base/mkiv/luat-ini.lua b/tex/context/base/mkiv/luat-ini.lua index 34e83e7bb..cd1f45692 100644 --- a/tex/context/base/mkiv/luat-ini.lua +++ b/tex/context/base/mkiv/luat-ini.lua @@ -24,3 +24,5 @@ table.setmetatableindex(thirddata, table.autokey) if not global then global = _G end + +LUATEXVERSION = status.luatex_version/100 + tonumber(status.luatex_revision)/1000 diff --git a/tex/context/base/mkiv/m-oldotf.mkiv b/tex/context/base/mkiv/m-oldotf.mkiv index 96554a75d..c7c468d93 100644 --- a/tex/context/base/mkiv/m-oldotf.mkiv +++ b/tex/context/base/mkiv/m-oldotf.mkiv @@ -59,7 +59,7 @@ return c end) - directives.register("nodes.injections.fontkern", function(v) setfield(kern,"subtype",v and 0 or 1) end) + directives.register("fonts.injections.fontkern", function(v) setfield(kern,"subtype",v and 0 or 1) end) local fonts = fonts local handlers = fonts.handlers diff --git a/tex/context/base/mkiv/mtx-context-trim.tex b/tex/context/base/mkiv/mtx-context-trim.tex new file mode 100644 index 000000000..46d0c3188 --- /dev/null +++ b/tex/context/base/mkiv/mtx-context-trim.tex @@ -0,0 +1,72 @@ +%D \module +%D [ file=mtx-context-trim, +%D version=2016.03.04, +%D title=\CONTEXT\ Extra Trickry, +%D subtitle=Trimming Files, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D This is a very old module based feature that has been moved to \MKIV. + +% begin help +% +% usage: context --extra=trim [options] filename +% +% --paperwidth : target paperwidth +% --paperheight : target paperheight +% --file : processed file +% --x : page x offset +% --y : page y offset +% --hoffset : horizontal clip offset +% --voffset : vertical clip offset +% --width : clip width +% --height : clip height +% +% example: context --extra=trim --file=trimtest --hoffset=3.50cm --voffset=3.50cm --width=15cm --height=21cm +% +% end help + +\input mtx-context-common.tex + +\setdocumentargumentdefault {paperwidth} {21cm} +\setdocumentargumentdefault {paperheight} {29.7cm} +\setdocumentargumentdefault {file} {\getdocumentfilename{1}} +\setdocumentargumentdefault {hoffset} {0cm} +\setdocumentargumentdefault {voffset} {0cm} +\setdocumentargumentdefault {width} {17cm} +\setdocumentargumentdefault {height} {24cm} +\setdocumentargumentdefault {x} {0cm} +\setdocumentargumentdefault {y} {0cm} + +\doifnothing{\getdocumentargument{file}} {\starttext missing filename \stoptext} +\doif {\getdocumentargument{file}}{\inputfilename.tex}{\starttext missing filename \stoptext} + +\definepapersize + [fuzzy] + [width=\getdocumentargument{paperwidth}, + height=\getdocumentargument{paperheight}] + +\setuppapersize + [fuzzy] + [fuzzy] + +\setuplayout + [page] + +\starttext + + \trimpages + [file=\getdocumentargument{file}, + hoffset=\getdocumentargument{hoffset}, + voffset=\getdocumentargument{voffset}, + width=\getdocumentargument{width}, + height=\getdocumentargument{height}, + x=\getdocumentargument{x}, + y=\getdocumentargument{y}] + +\stoptext diff --git a/tex/context/base/mkiv/node-ini.lua b/tex/context/base/mkiv/node-ini.lua index c705e2c05..9a8337e4e 100644 --- a/tex/context/base/mkiv/node-ini.lua +++ b/tex/context/base/mkiv/node-ini.lua @@ -125,10 +125,12 @@ local disccodes = mark(getsubtypes("disc")) -- [ 13] = "spaceskip", -- [ 14] = "xspaceskip", -- [ 15] = "parfillskip", --- [ 16] = "thinmuskip", --- [ 17] = "medmuskip", --- [ 18] = "thickmuskip", --- [ 19] = "mathskip", -- experiment +-- [ 16] = "mathskip", -- experiment +-- [ 17] = "thinmuskip", +-- [ 18] = "medmuskip", +-- [ 19] = "thickmuskip", +-- [ 98] = "conditionalmathglue", +-- [ 99] = "muskip", -- [100] = "leaders", -- [101] = "cleaders", -- [102] = "xleaders", diff --git a/tex/context/base/mkiv/node-pro.lua b/tex/context/base/mkiv/node-pro.lua index c7f68cf16..d6a8e9fe3 100644 --- a/tex/context/base/mkiv/node-pro.lua +++ b/tex/context/base/mkiv/node-pro.lua @@ -101,13 +101,13 @@ function processors.pre_linebreak_filter(head,groupcode) -- ,size,packtype,direc return true end -local function hpack_filter(head,groupcode,size,packtype,direction) +local function hpack_filter(head,groupcode,size,packtype,direction,attributes) -- local first, found = first_glyph(head) -- they really need to be glyphs local found = force_processors or has_glyph(head) if found then if trace_callbacks then local before = nodes.count(head,true) - local head, done = actions(head,groupcode,size,packtype,direction) + local head, done = actions(head,groupcode,size,packtype,direction,attributes) local after = nodes.count(head,true) if done then tracer("hpack","changed",head,groupcode,before,after,true) @@ -116,7 +116,7 @@ local function hpack_filter(head,groupcode,size,packtype,direction) end return done and head or true else - local head, done = actions(head,groupcode,size,packtype,direction) + local head, done = actions(head,groupcode,size,packtype,direction,attributes) return done and head or true end elseif trace_callbacks then diff --git a/tex/context/base/mkiv/page-imp.mkiv b/tex/context/base/mkiv/page-imp.mkiv index 2382d131a..c08f9856f 100644 --- a/tex/context/base/mkiv/page-imp.mkiv +++ b/tex/context/base/mkiv/page-imp.mkiv @@ -764,7 +764,6 @@ {\dosetuparrangement{2}{4}{8}{3}{5}% X,Y,Total,hcutmarks,vcutmarks \pusharrangedpageSIXTEENZ\poparrangedpagesAB\relax} - \def\pusharrangedpageSIXTEENZ#1% {\advancearrangedpageN \reportarrangedpage\arrangedpageN @@ -1192,7 +1191,7 @@ % % \starttext \dorecurse{30}{test \recurselevel \page} \stoptext -\def\pusharrangedpageXY#1% +\unexpanded\def\pusharrangedpageXY#1% {\advancearrangedpageN \global\advance\arrangedpageM\plusone \reportarrangedpage\arrangedpageN @@ -1228,7 +1227,7 @@ \poparrangedpages \fi} -\def\poparrangedpagesXY +\unexpanded\def\poparrangedpagesXY {\ifnum\arrangedpageN>\zerocount \paperwidth \arrangedpageX\paperwidth \paperheight\arrangedpageY\paperheight @@ -1274,7 +1273,7 @@ \setuppaper [\c!width =\dimexpr\printpaperwidth -2\v_page_target_backspace\relax, \c!height=\dimexpr\printpaperheight-2\v_page_target_topspace \relax] - + % \definepageshift[test][horizontal][10pt,20pt,30pt,40pt,50pt] % \definepageshift[test][vertical] [10pt,20pt,30pt,40pt,50pt] % diff --git a/tex/context/base/mkiv/page-lay.mkiv b/tex/context/base/mkiv/page-lay.mkiv index bc7c9f4bc..1fde9e9c9 100644 --- a/tex/context/base/mkiv/page-lay.mkiv +++ b/tex/context/base/mkiv/page-lay.mkiv @@ -1305,7 +1305,7 @@ \def\outercombitotal {\dimexpr\outermargintotal+\outeredgetotal\relax} \def\innersidetotal {\dimexpr\innermarginwidth+\inneredgetotal\relax} \def\outersidetotal {\dimexpr\outermarginwidth+\outeredgetotal\relax} - + %D \macros %D {startlocallayout} %D diff --git a/tex/context/base/mkiv/page-sel.mkvi b/tex/context/base/mkiv/page-sel.mkvi index 93521d4e6..eb8389032 100644 --- a/tex/context/base/mkiv/page-sel.mkvi +++ b/tex/context/base/mkiv/page-sel.mkvi @@ -366,4 +366,40 @@ % \starttext \slicepages[slice1.pdf][n=3] \stoptext +\unexpanded\def\trimpages[#1]% was for a over decade in p-pdf-51.tex + {\begingroup + \getdummyparameters + [\c!file=dummy, + \c!hoffset=\zeropoint, + \c!voffset=\zeropoint, + \c!width=17cm, + \c!height=24cm, + \c!x=\zeropoint, + \c!y=\zeropoint, + #1] + \getfiguredimensions + [\dummyparameter\c!file] + [\c!object=\v!no] + \dorecurse\noffigurepages + {\scale + [\c!width=\paperwidth, + \c!height=\paperheight] + {\offset + [\c!x=\dummyparameter\c!x, + \c!y=\dummyparameter\c!y] + {\clip + [\c!hoffset=\dummyparameter\c!hoffset, + \c!voffset=\dummyparameter\c!voffset, + \c!width=\dummyparameter\c!width, + \c!height=\dummyparameter\c!height] + {% we correct by default, if not needed, introduce option + \setbox\nextbox\hbox + {\externalfigure[\dummyparameter\c!file][\c!page=##1]}% + \ifdim\wd\nextbox>\ht\nextbox + \rotate[\c!rotation=90]{\box\nextbox}% + \else + \box\nextbox + \fi}}}}% + \endgroup} + \protect \endinput diff --git a/tex/context/base/mkiv/scrn-fld.mkvi b/tex/context/base/mkiv/scrn-fld.mkvi index 5acda1fc6..a92abebc5 100644 --- a/tex/context/base/mkiv/scrn-fld.mkvi +++ b/tex/context/base/mkiv/scrn-fld.mkvi @@ -886,15 +886,15 @@ {\bgroup \global\advance\c_scrn_pushbutton_n\plusone \setupfield - [pushbutton] - [\c!frame=\v!overlay, - \c!offset=\v!overlay, - \c!clickout={#reference}, + [pushbutton]% + [\c!frame=\v!overlay,% + \c!offset=\v!overlay,% + \c!clickout={#reference},% #settings]% \definefield [pushbutton:\number\c_scrn_pushbutton_n]% - [push] - [pushbutton] + [push]% + [pushbutton]% [pushsymbol:#tag:n,pushsymbol:#tag:r,pushsymbol:#tag:d]% \fitfield [pushbutton:\number\c_scrn_pushbutton_n]% diff --git a/tex/context/base/mkiv/spac-ali.mkiv b/tex/context/base/mkiv/spac-ali.mkiv index f2774e680..e896b3910 100644 --- a/tex/context/base/mkiv/spac-ali.mkiv +++ b/tex/context/base/mkiv/spac-ali.mkiv @@ -1140,6 +1140,15 @@ \fi \fi} +\unexpanded\def\simplealignedspreadbox#1#2% + {\hbox \ifdim#1>\zeropoint spread #1 + \ifcsname\??alignsimple#2\endcsname + \doubleexpandafter\lastnamedcs + \else + \doubleexpandafter\spac_align_simple_left + \fi + \fi} + \unexpanded\def\simplealignedboxplus#1#2#3% {\hbox #3 \ifdim#1>\zeropoint to #1 \ifcsname\??alignsimple#2\endcsname diff --git a/tex/context/base/mkiv/spac-flr.mkiv b/tex/context/base/mkiv/spac-flr.mkiv index d09a9cf79..29351a3dd 100644 --- a/tex/context/base/mkiv/spac-flr.mkiv +++ b/tex/context/base/mkiv/spac-flr.mkiv @@ -45,6 +45,7 @@ {\removeunwantedspaces \begingroup \edef\currentfiller{#1}% + \usefillerstyleandcolor\c!style\c!color \scratchdimen\fillerparameter\c!leftmargin\relax \ifdim\scratchdimen=\zeropoint\else \hskip\scratchdimen @@ -64,16 +65,26 @@ \setvalue{\??filleralternative\v!symbol}% {\expandnamespaceparameter\??fillerleadermethod\fillerparameter\c!method\v!local - \simplealignedbox - {\fillerparameter\c!width}% - {\fillerparameter\c!align}% - {\fillerparameter\c!symbol}% + \ifdim\fillerparameter\c!offset>\zeropoint + \simplealignedspreadbox + {2\dimexpr\fillerparameter\c!offset\relax}% + {\fillerparameter\c!align}% + {\fillerparameter\c!symbol}% + \else + \simplealignedbox + {\fillerparameter\c!width}% + {\fillerparameter\c!align}% + {\fillerparameter\c!symbol}% + \fi \hfill} -\setvalue{\??filleralternative\c!stretch}% +\setvalue{\??filleralternative\v!stretch}% {\hfill} -\setvalue{\??filleralternative\c!rule}% +\setvalue{\??filleralternative\v!space}% + {\hskip\fillerparameter\c!distance\relax} + +\setvalue{\??filleralternative\v!rule}% {\expandnamespaceparameter\??fillerleadermethod\fillerparameter\c!method\v!local \hrule \!!height\fillerparameter\c!height @@ -88,6 +99,8 @@ \setupfillers [\c!width=\emwidth, \c!symbol=., + \c!distance=\emwidth, + \c!offset=\zeropoint, \c!align=\v!middle, \c!height=.1\exheight, \c!depth=\zeropoint, @@ -96,6 +109,35 @@ \c!alternative=\v!symbol, \c!method=\s!local] +\definefiller + [\v!sym] + [\c!method=\v!global, + \c!width=.5\emwidth, + \c!leftmargin=.5\emwidth, + \c!rightmargin=.5\emwidth] + +\definefiller + [\v!symbol] + [\c!method=\v!global, + \c!offset=.125\emwidth, + \c!leftmargin=.5\emwidth, + \c!rightmargin=.5\emwidth] + +\definefiller + [\v!rule] + [\c!alternative=\v!rule, + \c!leftmargin=.5\emwidth, + \c!rightmargin=.5\emwidth] + +\definefiller + [\v!width] + [\c!alternative=\v!stretch] + +\definefiller + [\v!space] + [\c!alternative=\v!space, + \c!distance=3\emwidth] + % maybe box -> symbol \protect \endinput diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index 1e54084c3..179738474 100644 Binary files a/tex/context/base/mkiv/status-files.pdf and b/tex/context/base/mkiv/status-files.pdf differ diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf index 9cf850c00..03a298651 100644 Binary files a/tex/context/base/mkiv/status-lua.pdf and b/tex/context/base/mkiv/status-lua.pdf differ diff --git a/tex/context/base/mkiv/strc-itm.mkvi b/tex/context/base/mkiv/strc-itm.mkvi index fc9d31d87..e43aeae45 100644 --- a/tex/context/base/mkiv/strc-itm.mkvi +++ b/tex/context/base/mkiv/strc-itm.mkvi @@ -1589,6 +1589,16 @@ \hbox to \dimexpr\availablehsize/\scratchcounter\relax{\collecteditemgroupitem\hss}% \endgroup} +% \def\strc_itemgroups_collected_flush_indeed +% {\collecteditemgroupitem +% \iftrialtypesetting +% \undefinevalue{\??itemgroupstack\number\c_strc_itemgroups_collected_current}% +% \fi} + +\def\strc_itemgroups_collected_flush_indeed + {\collecteditemgroupitem + \undefinevalue{\??itemgroupstack\number\c_strc_itemgroups_collected_current}} + \def\strc_itemgroups_collected_flush {\ifconditional\c_strc_itemgroups_randomize \getrandomcount\c_strc_itemgroups_collected_current\plusone\c_strc_itemgroups_collected_stored @@ -1600,7 +1610,7 @@ \ifconditional\c_strc_itemgroups_horizontal \strc_itemgroups_collected_flush_horizontal \else - \collecteditemgroupitem + \strc_itemgroups_collected_flush_indeed \fi \advance\c_strc_itemgroups_collected_done\plusone \fi diff --git a/tex/context/base/mkiv/strc-lst.mkvi b/tex/context/base/mkiv/strc-lst.mkvi index 3159374c0..19757aa61 100644 --- a/tex/context/base/mkiv/strc-lst.mkvi +++ b/tex/context/base/mkiv/strc-lst.mkvi @@ -667,8 +667,64 @@ % quite special and don't apply to multiple. So, being strict saves % us resets. -\setuplistalternative - [\c!command=\strictlistparameter\c!command] +% \installcorenamespace{listfiller} +% +% \unexpanded\def\installlistfiller#1#2% +% {\setuvalue{\??listfiller#1}{#2}} +% +% \unexpanded\def\listfiller#1% +% {\begincsname\??listfiller#1\endcsname} +% +% \unexpanded\def\currentlistfiller +% {\begingroup +% \edef\p_filler{\listalternativeparameter\c!filler}% +% \ifcsname\??listfiller\p_filler\endcsname +% \lastnamedcs +% \else +% \p_filler +% \fi +% \endgroup} +% +% \installlistfiller\v!sym % original one +% {\begingroup +% \scratchdimen.5\emwidth +% \hskip\scratchdimen +% \gleaders +% \hbox to \scratchdimen +% {\hss +% \uselistalternativestyleandcolor\c!symstyle\c!symcolor +% \listalternativeparameter\c!symbol +% \hss}% +% \hfill +% \hskip\scratchdimen +% \endgroup} +% +% \installlistfiller\v!symbol % new one (make that default?) +% {\begingroup +% \scratchdimen.5\emwidth +% \hskip\scratchdimen +% \gleaders +% \hbox spread .5\scratchdimen +% {\hss +% \uselistalternativestyleandcolor\c!symstyle\c!symcolor +% \listalternativeparameter\c!symbol +% \hss}% +% \hfill +% \hskip\scratchdimen +% \endgroup} +% +% \installlistfiller\v!width +% {\hfill} +% +% \installlistfiller\v!space +% {\hskip.25\emwidth\relax} +% +% \setuplistalternative +% [\c!command=\strictlistparameter\c!command, +% \c!symbol=.] + +\unexpanded\def\currentlistfiller + {\checkedfiller{\listalternativeparameter\c!filler}} \definelistalternative [a] @@ -1064,7 +1120,7 @@ \endgroup \ifdim\wd\b_strc_lists_page=\zeropoint\else \nobreak - \listalternativeparameter\c!filler + \currentlistfiller \box\b_strc_lists_page \fi } @@ -1269,7 +1325,7 @@ \definelistalternative [\v!paragraph] - [\c!filler=\hskip.25\emwidth, + [\c!filler=\v!space, \c!renderingsetup=\??listrenderings:\v!paragraph] \startsetups[\??listrenderings:\v!paragraph] @@ -1331,7 +1387,7 @@ \ifconditional\c_lists_has_page \ifconditional\c_lists_show_page \nobreak - \listalternativeparameter\c!filler\relax + \currentlistfiller \begingroup \useliststyleandcolor\c!pagestyle\c!pagecolor \currentlistentrypagenumber diff --git a/tex/context/base/mkiv/syst-aux.mkiv b/tex/context/base/mkiv/syst-aux.mkiv index 94e5f468e..8f8ba2024 100644 --- a/tex/context/base/mkiv/syst-aux.mkiv +++ b/tex/context/base/mkiv/syst-aux.mkiv @@ -621,7 +621,7 @@ %D existance is not the same as the one described here. Therefore we introduce: \def\letbeundefined#1% potential stack buildup when used \global - {\expandafter\let\csname#1\endcsname\undefined} + {\expandafter\let\csname#1\endcsname\undefined} % or use \undefinevalue to match \setvalue \def\localundefine#1% conditional {\ifcsname#1\endcsname\expandafter\let\csname#1\endcsname\undefined\fi} diff --git a/tex/context/base/mkiv/tabl-tab.mkiv b/tex/context/base/mkiv/tabl-tab.mkiv index 2fee8a5ab..e238447b9 100644 --- a/tex/context/base/mkiv/tabl-tab.mkiv +++ b/tex/context/base/mkiv/tabl-tab.mkiv @@ -12,30 +12,31 @@ \writestatus{loading}{ConTeXt Table Macros / TaBlE Embedding} -% Todo: consistent namespace and get rid of not used code - -% In \MKIV\ the old table macros are sort of obsolete. The color extensions -% have been removed and some code is stripped. For practical reasons the -% \TABLE\ macros that are used are embedded in this file. +% Todo: a bitmore namespace protection ... although we want to keep some of the +% original flavour. +% +% In \MKIV\ the old table macros are sort of obsolete. The color extensions have +% been removed and some code is stripped. For practical reasons the \TABLE\ macros +% that are used are embedded in this file. % -% The following code is based on TABLE 1.0 by Michael J. Wichura (August 1988. -% We used a patched version with many overloads and extensions. The documented -% (and larger) source can be found in \type {thrd-tab.tex}. +% The following code is based on TABLE 1.0 by Michael J. Wichura (August 1988. We +% used a patched version with many overloads and extensions. The documented (and +% larger) source can be found in \type {thrd-tab.tex}. % -% Some code has been stripped. Some color has been added. Some macros have -% been renamed. Registers have been replaces. And probably much more can be -% cleaned up. We also need to use \tabl_tab_ prefixes here. +% Some code has been stripped. Some color has been added. Some macros have been +% renamed. Registers have been replaces. And probably much more can be cleaned up. +% We also need to use \tabl_tab_ prefixes here. \unprotect -\newconditional\tablehasleftspacing -\newconditional\tablehasrightspacing +\newconditional\c_tabl_table_spacing_left +\newconditional\c_tabl_table_spacing_right -\newdimen\tablelinethicknessunit -\newdimen\tablestrutunit -\newskip \tableintercolumnspaceunit -\newdimen\tablecolumnwidthunit -\newdimen\tablekernunit +\newdimen \d_tabl_table_line_thickness_unit +\newdimen \d_tabl_table_strut_unit +\newskip \s_tabl_table_inter_column_space_unit +\newdimen \d_tabl_table_column_width_unit +\newdimen \d_tabl_table_kern_unit \def\tablestrutheightfactor {8} \def\tablestrutdepthfactor {3} @@ -48,17 +49,17 @@ \newtoks\everytable \newtoks\everytableparbox -\unexpanded\def\dotablebeginparbox#1% +\unexpanded\def\tabl_table_begin_par_box#1% {\setbox\scratchbox\vtop\bgroup % \setbox added \hsize#1\relax \dontcomplain - \dorestoretablelineskips + \tabl_table_restore_lineskips \normalbaselines \let~\fixedspace \inhibitblank % \blank[\v!disable]% % added \the\everytableparbox} -\unexpanded\def\dotableendparbox +\unexpanded\def\tabl_table_end_par_box {\removelastskip % itemize or so \endgraf \ifnum\prevgraf>\zerocount % we want at least @@ -106,8 +107,8 @@ \newif \if!taOnceOnlyTabskip \def\!thToksEdef#1#2% - {\edef\!ttemp{#2}% - #1\expandafter{\!ttemp}% + {\edef\tempstring{#2}% + #1\expandafter{\tempstring}% \ignorespaces} \def\!thLoop#1\repeat @@ -115,10 +116,10 @@ \!thIterate \let\!thIterate\relax} -\def\dobegintableformat +\def\tabl_table_begin_format {\!taPreamble\emptytoks \!taColumnNumber\zerocount - \scratchskip\tableintercolumnspaceunit + \scratchskip\s_tabl_table_inter_column_space_unit \multiply\scratchskip\tableintercolumnspacefactor \divide\scratchskip\plustwo \!taRuleColumnTemplate\expandafter{\expandafter\tabskip\the\scratchskip}% @@ -140,14 +141,14 @@ \aftergroup\omit \!thLoop \ifnum \scratchcounter<\!taColumnNumber - \advance\scratchcounter\plusone - \aftergroup \!tfAOAO + \advance\scratchcounter\plusone + \aftergroup\!tfAOAO \repeat \aftergroup}% \endgroup \fi \fi - \ifx[\!ttemp % \!tgGetValue sets \!ttemp = token after w + \ifx[\tempstring % \!tgGetValue sets \tempstring = token after w \expandafter\!tfSetWidthText \else \expandafter\!tfSetWidthValue @@ -162,7 +163,7 @@ \def\!tfSetWidthValue {\!taMinimumColumnWidth= \ifnum\!tgCode=\plusone - \ifx\!tgValue\empty \tablecolumnwidthfactor \else \!tgValue \fi \tablecolumnwidthunit + \ifx\!tgValue\empty \tablecolumnwidthfactor \else \!tgValue \fi \d_tabl_table_column_width_unit \else \!tgValue \fi @@ -171,7 +172,7 @@ \def\!tfSetTabskip {\ifnum\!tgCode=\plusone - \scratchskip\tableintercolumnspaceunit + \scratchskip\s_tabl_table_inter_column_space_unit \multiply\scratchskip \ifx\!tgValue\empty\tableintercolumnspacefactor\else\!tgValue\fi \else \scratchskip\!tgValue @@ -193,14 +194,14 @@ {\!thToksEdef\!taRuleColumnTemplate {\hfil \vrule - \noexpand\!!width + \noexpand\s!width \ifnum\!tgCode=\plusone \ifx\!tgValue\empty - \tablevrulethicknessfactor + \c_tabl_table_vrule_thickness_factor \else \!tgValue \fi - \tablelinethicknessunit + \d_tabl_table_line_thickness_unit \else \!tgValue \fi @@ -273,23 +274,23 @@ \!taBeginFormatfalse \!ttDoHalign} -\def\dotablereformat[#1]% will become local +\def\tabl_table_reformat[#1]% will become local {\omit \!taDataColumnTemplate{\alignmark\alignmark}% \!taLeftGlue\emptytoks \!taRightGlue\emptytoks \begingroup - \@@useotherbar - \expanded{\endgroup\noexpand\doreadtableformatkeys#1]}}% appear in a \dotablereformat cmd; this is here as a safeguard. + \tabl_table_use_bar + \expanded{\endgroup\noexpand\doreadtableformatkeys#1]}}% appear in a \tabl_table_reformat cmd; this is here as a safeguard. \appendtoks - \let\ReFormat\dotablereformat + \let\ReFormat\tabl_table_reformat \to \everytable \def\!tfEndReFormat {\!tfReFormat} -\appendtoks \dotableparalignment \to \everytableparbox +\appendtoks \tabl_table_paralignment \to \everytableparbox \def\!tfReFormat#1% {\the \!taLeftGlue @@ -299,10 +300,10 @@ \def\!tgGetValue#1% {\def\!tgReturn{#1}% - \futurelet\!ttemp\!tgCheckForParen} + \futurelet\tempstring\!tgCheckForParen} \def\!tgCheckForParen% - {\ifx\!ttemp (% + {\ifx\tempstring (% \expandafter \!tgDoParen \else \expandafter \!tgCheckForSpace @@ -316,7 +317,7 @@ \def\!tgCheckForSpace {\def\!tgCode{1}% \let\!tgValue\empty - \ifx\!ttemp\!thSpaceToken + \ifx\tempstring\!thSpaceToken \expandafter \!tgReturn \else \expandafter \!tgCheckForDigit @@ -324,16 +325,16 @@ % \def\!tgCheckForDigit % {\donefalse -% \ifx 0\!ttemp \donetrue -% \else\ifx 1\!ttemp \donetrue -% \else\ifx 2\!ttemp \donetrue -% \else\ifx 3\!ttemp \donetrue -% \else\ifx 4\!ttemp \donetrue -% \else\ifx 5\!ttemp \donetrue -% \else\ifx 6\!ttemp \donetrue -% \else\ifx 7\!ttemp \donetrue -% \else\ifx 8\!ttemp \donetrue -% \else\ifx 9\!ttemp \donetrue +% \ifx 0\tempstring \donetrue +% \else\ifx 1\tempstring \donetrue +% \else\ifx 2\tempstring \donetrue +% \else\ifx 3\tempstring \donetrue +% \else\ifx 4\tempstring \donetrue +% \else\ifx 5\tempstring \donetrue +% \else\ifx 6\tempstring \donetrue +% \else\ifx 7\tempstring \donetrue +% \else\ifx 8\tempstring \donetrue +% \else\ifx 9\tempstring \donetrue % \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi % \ifdone % \expandafter \!tgGetNumber @@ -341,13 +342,13 @@ % \expandafter \!tgReturn % \fi} -\def\!tgCheckForDigit % less tokens: +\def\!tgCheckForDigit % less tokens: (could be an ifcsname) {\donetrue - \ifx 0\!ttemp \else \ifx 1\!ttemp \else - \ifx 2\!ttemp \else \ifx 3\!ttemp \else - \ifx 4\!ttemp \else \ifx 5\!ttemp \else - \ifx 6\!ttemp \else \ifx 7\!ttemp \else - \ifx 8\!ttemp \else \ifx 9\!ttemp \else + \ifx 0\tempstring \else \ifx 1\tempstring \else + \ifx 2\tempstring \else \ifx 3\tempstring \else + \ifx 4\tempstring \else \ifx 5\tempstring \else + \ifx 6\tempstring \else \ifx 7\tempstring \else + \ifx 8\tempstring \else \ifx 9\tempstring \else \donefalse \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \ifdone @@ -357,7 +358,7 @@ \fi} % \def\!tgCheckForDigit % does not work -% {\relax\doifnumberelse\!ttemp\!tgGetNumber\!tgReturn} +% {\relax\doifnumberelse\tempstring\!tgGetNumber\!tgReturn} \def\!tgGetNumber {\afterassignment\!tgGetNumberA\scratchcounter=} \def\!tgGetNumberA{\edef\!tgValue{\the\scratchcounter}\!tgReturn} @@ -365,21 +366,21 @@ \def\!tgSetUpParBox {\normalexpanded {\noexpand \doreadtableformatkeys - b{\dotablebeginparbox + b{\tabl_table_begin_par_box {\ifnum\!tgCode=\plusone \ifx\!tgValue\empty \tablecolumnwidthfactor \else \!tgValue \fi - \tablecolumnwidthunit + \d_tabl_table_column_width_unit \else \!tgValue \fi}}% - a{\dotableendparbox}}} + a{\tabl_table_end_par_box}}} \def\!tgInsertKern - {\edef\!ttemp + {\edef\tempstring {\kern \ifnum \!tgCode=\plusone \ifx \!tgValue\empty @@ -387,19 +388,19 @@ \else \!tgValue \fi - \tablekernunit + \d_tabl_table_kern_unit \else \!tgValue \fi}% - \edef\!ttemp + \edef\tempstring {\noexpand\doreadtableformatkeys - \ifconditional\tablehasleftspacing - b{\!ttemp} + \ifconditional\c_tabl_table_spacing_left + b{\tempstring} \fi - \ifconditional\tablehasrightspacing - a{\!ttemp} + \ifconditional\c_tabl_table_spacing_right + a{\tempstring} \fi}% - \!ttemp} + \tempstring} \def\newtableformatkey #1{\setvalue{!tk<\string#1>}} \def\doreadtableformatkeys#1{\getvalue{!tk<\string#1>}} @@ -466,29 +467,28 @@ {\prependtoks\notragged\to\!taDataColumnTemplate \doreadtableformatkeys \LeftGlue\hfil \RightGlue\empty} -% Key "k": Adds kerns to left and right of "#" -% This key and the two below use Plain TeX's \if@h as if it were \if@left, -% and \if@v as if it were \if@right. Table making goes on in a group, -% so even in the unlikely circumstance that a \phantom is currently under -% construction, there's no problem. +% Key "k": Adds kerns to left and right of "#" This key and the two below use Plain +% TeX's \if@h as if it were \if@left, and \if@v as if it were \if@right. Table +% making goes on in a group, so even in the unlikely circumstance that a \phantom +% is currently under construction, there's no problem. \newtableformatkey k% - {\settrue\tablehasleftspacing - \settrue\tablehasrightspacing + {\settrue\c_tabl_table_spacing_left + \settrue\c_tabl_table_spacing_right \!tgGetValue{\!tgInsertKern}} % Key "i": Adds a kern to the left of "#" \newtableformatkey i% - {\settrue\tablehasleftspacing - \setfalse\tablehasrightspacing + {\settrue\c_tabl_table_spacing_left + \setfalse\c_tabl_table_spacing_right \!tgGetValue{\!tgInsertKern}} % Key "j": Adds a kern to the right of "#" \newtableformatkey j% - {\setfalse\tablehasleftspacing - \settrue\tablehasrightspacing + {\setfalse\c_tabl_table_spacing_left + \settrue\c_tabl_table_spacing_right \!tgGetValue{\!tgInsertKern}} % Key "n": numeric item , non-math mode. @@ -514,6 +514,7 @@ {\doreadtableformatkeys \{ b{\normalstartimath\displaystyle} a{\normalstopimath}} % Key "\m": Template ${}#\hfil$ + \newtableformatkey \m% {\doreadtableformatkeys l b{{}} m} @@ -544,17 +545,16 @@ \newtableformatkey w% {\!tkTestForBeginFormat w{\!tgGetValue{\!tfSetWidth}}} -% Key "s": Set tabskip for the inter-column space to the right -% of the current column, and all subsequent spaces, until overriden -% by a new "s" or "o" key. +% Key "s": Set tabskip for the inter-column space to the right of the current +% column, and all subsequent spaces, until overriden by a new "s" or "o" key. \newtableformatkey s% {\!taOnceOnlyTabskipfalse % in case same column has a prior "o" key \!tkTestForBeginFormat t{\!tgGetValue{\!tfSetTabskip}}} -% Key "o": Apply the \tabskip stated for this column ONLY to the -% inter-column space just to the right of this column; restore the -% the previous \tabskip for subsequent columns. +% Key "o": Apply the \tabskip stated for this column ONLY to the inter-column space +% just to the right of this column; restore the the previous \tabskip for +% subsequent columns. \newtableformatkey o% {\!taOnceOnlyTabskiptrue @@ -570,7 +570,7 @@ \newtableformatkey \|% {\!tkTestForBeginFormat \|{\!tfSetAlternateVrule}} -% Key ".": PERIOD -- end of \dobegintableformat section. +% Key ".": PERIOD -- end of \tabl_table_begin_format section. \newtableformatkey .% {\!tkTestForBeginFormat.{\!tfFinishFormat}} @@ -580,41 +580,40 @@ \newtableformatkey \doendtableformat {\!tkTestForBeginFormat\doendtableformat{\!tfFinishFormat}} -% Key "]": End of \dotablereformat section +% Key "]": End of \tabl_table_reformat section \newtableformatkey ]% {\!tkTestForReFormat ] \!tfEndReFormat} -% TEST FOR BEGIN FORMAT{}{Intended Action}: This test is run -% on keys that can only be used by \dobegintableformat --- "s", "o", -% "|", "\|", "w", ".", and "\doendtableformat". +% TEST FOR BEGIN FORMAT{}{Intended Action}: This test is run on keys that can +% only be used by \tabl_table_begin_format --- "s", "o", "|", "\|", "w", ".", and +% "\doendtableformat". \def\!tkTestForBeginFormat#1#2% {\if!taBeginFormat - \def\!ttemp{#2}% - \expandafter\!ttemp + \def\tempstring{#2}% + \expandafter\tempstring \else \toks0={#1}% - \toks2=\expandafter{\string\dotablereformat}% + \toks2=\expandafter{\string\tabl_table_reformat}% \expandafter\!tkImproperUse \fi} -% TEST FOR RE FORMAT{}{Intended Action}: This test is run -% on the key "]", which can only be used by \dotablereformat. +% TEST FOR RE FORMAT{}{Intended Action}: This test is run on the key "]", +% which can only be used by \tabl_table_reformat. \def\!tkTestForReFormat#1#2% {\if!taBeginFormat \toks0={#1}% - \toks2=\expandafter{\string\dobegintableformat}% + \toks2=\expandafter{\string\tabl_table_begin_format}% \expandafter\!tkImproperUse \else - \def\!ttemp{#2}% - \expandafter\!ttemp + \def\tempstring{#2}% + \expandafter\tempstring \fi} -% NOTE: THE SPACE BETWEEN A NUMERIC ENTRY AND THE FOLLOWING '|', '"', -% OR '\|' IS MANDATORY. -% EMPTY NUMERIC ENTRIES ARE NOT ALLOWED: USE '{}' OR '\omit' INSTEAD. +% NOTE: THE SPACE BETWEEN A NUMERIC ENTRY AND THE FOLLOWING '|', '"', OR '\|' IS +% MANDATORY. EMPTY NUMERIC ENTRIES ARE NOT ALLOWED: USE '{}' OR '\omit' INSTEAD. \def\!tnTestForBracket {\ifx[\!tnext @@ -628,12 +627,11 @@ \def\!tnGetCode#1 % {\!tnConvertCode #1..!} -% CONVERT CODE: E.g. converts above to [0000], [0000.], [.0000], -% [0000000000.00] +% CONVERT CODE: E.g. converts above to [0000], [0000.], [.0000], [0000000000.00] \def\!tnConvertCode #1.#2.#3!% {\begingroup - \aftergroup\edef \aftergroup\!ttemp \aftergroup{% + \aftergroup\edef \aftergroup\tempstring \aftergroup{% \aftergroup[% \scratchcounter#1\relax \!thLoop @@ -641,8 +639,8 @@ \advance\scratchcounter\minusone \aftergroup0 \repeat - \def\!ttemp{#3}% - \ifx\!ttemp \empty + \def\tempstring{#3}% + \ifx\tempstring \empty \else \aftergroup. \scratchcounter#2\relax @@ -654,7 +652,7 @@ \fi \aftergroup]\aftergroup}% \endgroup\relax - \expandafter\!tnGetArgument\!ttemp} + \expandafter\!tnGetArgument\tempstring} % GET ARGUMENT: [ > @@ -664,8 +662,8 @@ % MAKE NUMERIC TEMPLATE \def\!tnMakeNumericTemplate#1#2.#3.#4!% #1= or $ - {\def\!ttemp{#4}% - \ifx\!ttemp\empty + {\def\tempstring{#4}% + \ifx\tempstring\empty \!taDimenC\zeropoint \else \setbox\scratchbox=\hbox{\mathsurround\zeropoint #1.#3#1}% @@ -683,9 +681,9 @@ {\!tnSetNumericItemA {#1}{#2}{#3}#4..!} \def\!tnSetNumericItemA #1#2#3#4.#5.#6!% - {\def\!ttemp{#6}% + {\def\tempstring{#6}% \hbox to #1{\hss \mathsurround\zeropoint #3#4#3}% - \hbox to #2{\ifx\!ttemp\empty\else\mathsurround\zeropoint #3.#5#3\fi\hss}} + \hbox to #2{\ifx\tempstring\empty\else\mathsurround\zeropoint #3.#5#3\fi\hss}} % extensions @@ -710,7 +708,7 @@ \def\!tqConvertCode #1,#2,#3!% {\begingroup \aftergroup\edef - \aftergroup\!ttemp + \aftergroup\tempstring \aftergroup{% \aftergroup[% \scratchcounter#1\relax @@ -719,8 +717,8 @@ \advance\scratchcounter\minusone \aftergroup0 \repeat - \def\!ttemp{#3}% - \ifx\!ttemp\empty + \def\tempstring{#3}% + \ifx\tempstring\empty \else \aftergroup, \scratchcounter#2\relax @@ -732,14 +730,14 @@ \fi \aftergroup]\aftergroup}% \endgroup\relax - \!thx\!tqGetArgument\!ttemp} + \!thx\!tqGetArgument\tempstring} \def\!tqGetArgument[#1]% {\!tqMakeQuantityTemplate\!tqStyle#1,,!} \def\!tqMakeQuantityTemplate#1#2,#3,#4!% #1= or $ - {\def\!ttemp{#4}% - \ifx\!ttemp\empty + {\def\tempstring{#4}% + \ifx\tempstring\empty \!taDimenC\zeropoint \else \setbox\scratchbox\hbox{\mathsurround\zeropoint #1,#3#1}% @@ -755,14 +753,14 @@ {\!tqSetQuantityItemA{#1}{#2}{#3}#4,,!} \def\!tqSetQuantityItemA #1#2#3#4,#5,#6!% - {\def\!ttemp{#6}% + {\def\tempstring{#6}% \hbox to #1{\hss\mathsurround\zeropoint#3#4#3}% - \hbox to #2{\ifx\!ttemp\empty\else\mathsurround\zeropoint#3,#5#3\fi\hss}} + \hbox to #2{\ifx\tempstring\empty\else\mathsurround\zeropoint#3,#5#3\fi\hss}} % \Enlarge % \enlarge -\def\dotableEnlarge#1#2% +\def\tabl_table_Enlarge#1#2% {% 3rd argument is picked up later % #1=extra height % #2=extra depth @@ -794,35 +792,35 @@ \box\scratchbox \!TsSpaceFactor\relax} -\def\dotableenlarge#1#2% 3rd argument is picked up later - {\dotableEnlarge{#1\tablestrutunit}{#2\tablestrutunit}} +\def\tabl_table_enlarge#1#2% 3rd argument is picked up later + {\tabl_table_Enlarge{#1\d_tabl_table_strut_unit}{#2\d_tabl_table_strut_unit}} \appendtoks - \let\enlarge\dotableenlarge - \let\Enlarge\dotableEnlarge + \let\enlarge\tabl_table_enlarge + \let\Enlarge\tabl_table_Enlarge \to \everytable % BEGIN TABLE -\let\dotablestandardend\relax +\let\tabl_table_standard_end\relax -\def\dotablestandardbegin[#1]% \!ttBeginTable (always argument) +\def\tabl_table_standard_begin[#1]% \!ttBeginTable (always argument) {\if#1u% unboxed table \ifmmode - \let\dotablestandardend\relax % user had better be in display math mode and have only one table at the outer level - \else % user had better be in vertical mode + \let\tabl_table_standard_end\relax % user had better be in display math mode and have only one table at the outer level + \else % user had better be in vertical mode \bgroup - \let\dotablestandardend\egroup + \let\tabl_table_standard_end\egroup \fi \else \hbox\bgroup - \def\dotablestandardend{\egroup\egroup}% + \def\tabl_table_standard_end{\egroup\egroup}% \if#1t% \vtop \else\if#1b% \vbox \else - \def\dotablestandardend{\egroup\normalstopimath\egroup}% + \def\tabl_table_standard_end{\egroup\normalstopimath\egroup}% \scratchtoks\everymath \everymath\emptytoks \normalstartimath @@ -852,8 +850,10 @@ % DO HALIGN: Invoked by END FORMAT (or the key ".") +\let\tabl_table_restore_lineskips\relax + \def\!ttDoHalign - {\edef\dorestoretablelineskips + {\edef\tabl_table_restore_lineskips {\baselineskip \the\baselineskip \lineskiplimit\the\lineskiplimit \lineskip \the\lineskip @@ -875,80 +875,78 @@ % END TABLE -\def\dotablenormalend - {\egroup % finishes the \halign - \dotablestandardend} % closes off the table envirnoment set up by \tablestandardbegin +\def\tabl_table_normal_end + {\egroup % finishes the \halign + \tabl_table_standard_end} % closes off the table envirnoment set up by \tablestandardbegin -\def\donormaltablelineending +\def\tabl_table_normal_line_ending {\cr} -\def\donormaltablelineformat#1#2% +\def\tabl_table_normal_line_format#1#2% {\vrule \s!width \zeropoint - \s!height\dimexpr\tablestrutheightfactor\tablestrutunit+#1\tablestrutunit\relax - \s!depth \dimexpr\tablestrutdepthfactor \tablestrutunit+#2\tablestrutunit\relax + \s!height\dimexpr\tablestrutheightfactor\d_tabl_table_strut_unit+#1\d_tabl_table_strut_unit\relax + \s!depth \dimexpr\tablestrutdepthfactor \d_tabl_table_strut_unit+#2\d_tabl_table_strut_unit\relax \relax \cr} % INSERT VRULE -\newcount\noftablevrules \noftablevrules\plusone +\newcount\c_tabl_table_n_of_vrules \c_tabl_table_n_of_vrules\plusone -\let\tablecurrentvrulecolor\empty -\let\tablecurrenthrulecolor\empty - -\def\@VLd{.125em} +\let\m_tabl_table_vrule_color\empty +\let\m_tabl_table_hrule_color\empty \def\do!ttInsertVrule - {\vrule\!!width + {\vrule\s!width \ifnum\!tgCode=\plusone \ifx\!tgValue\empty - \tablevrulethicknessfactor + \c_tabl_table_vrule_thickness_factor \else \!tgValue \fi - \tablelinethicknessunit + \d_tabl_table_line_thickness_unit \else \!tgValue \fi - \hskip\@VLd} + \hskip.125\emwidth\relax} -\def\donormaltablesimplebar +\def\tabl_table_normal_line_simple_bar {\unskip\!ttRightGlue\aligntab\aligntab} -\def\donormaltablecomplexbar +\def\tabl_table_normal_line_complex_bar {\unskip\!ttRightGlue\aligntab\omit \hfil - \ifx\tablecurrentvrulecolor\empty\else - \switchtocolor[\tablecurrentvrulecolor]% + \ifx\m_tabl_table_vrule_color\empty\else + \switchtocolor[\m_tabl_table_vrule_color]% \fi - \ifcase\noftablevrules\or + \ifcase\c_tabl_table_n_of_vrules\or \do!ttInsertVrule \unskip \else - \dorecurse\noftablevrules\do!ttInsertVrule - \global\noftablevrules\plusone + \dorecurse\c_tabl_table_n_of_vrules\do!ttInsertVrule + \global\c_tabl_table_n_of_vrules\plusone \unskip \fi - \global\let\tablecurrentvrulecolor\empty + \global\let\m_tabl_table_vrule_color\empty \hfil \aligntab} -\def\donormaltablenobar +\def\tabl_table_normal_no_bar {\unskip\!ttRightGlue\aligntab\omit\aligntab} -\def\donormaltablesinglerule - {\aligntab\donormaltablelongrule\aligntab} +\def\tabl_table_normal_single_rule + {\aligntab\tabl_table_normal_long_rule\aligntab} -\def\donormaltablemultirule - {\aligntab\!ttuse\tabledrulespan\donormaltablelongrule\aligntab} +\def\tabl_table_normal_multi_rule + {\aligntab\tabl_table_use\c_tabl_table_drule_span\tabl_table_normal_long_rule\aligntab} % USE -\def\!ttuse#1% +\def\tabl_table_use#1% {\ifnum#1>\plusone \omit - \global\setfalse\istabledivision % added + \global\setfalse\c_tabl_table_is_division % added \scratchcounter\currenttablecolumn % added \advance\scratchcounter #1% % added \advance\scratchcounter \minusone % added @@ -969,47 +967,47 @@ \fi \next} % added -\def\!ttUse#1[% - {\!ttuse{#1}% - \dotablereformat[} +\def\tabl_table_Use#1[% + {\tabl_table_use{#1}% + \tabl_table_reformat[} \appendtoks - \let\use\!ttuse - \let\Use\!ttUse + \let\use\tabl_table_use + \let\Use\tabl_table_Use \to \everytable % rules -\def\donormaltablefullrule +\def\tabl_table_normal_full_rule {\starttablenoalign \!ttGetHalfRuleThickness \hrule\s!height\scratchdimen\s!depth\scratchdimen \stoptablenoalign} -\def\donormaltableshortrule % was: \!ttShortHrule +\def\tabl_table_normal_short_rule % was: \!ttShortHrule {\omit \!ttGetHalfRuleThickness - \ifx\tablecurrenthrulecolor\empty\else - \switchtocolor[\tablecurrenthrulecolor]% see *DL* + \ifx\m_tabl_table_hrule_color\empty\else + \switchtocolor[\m_tabl_table_hrule_color]% see *DL* \fi \leaders\hrule\s!height\scratchdimen\s!depth\scratchdimen\hfill \emptyhbox \ignorespaces} -\def\donormaltablelongrule % was: \!ttLongHrule +\def\tabl_table_normal_long_rule % was: \!ttLongHrule {\omit\span \omit\span - \donormaltableshortrule} + \tabl_table_normal_short_rule} \def\!ttGetHalfRuleThickness {\scratchdimen\dimexpr \ifnum\!tgCode=\plusone \ifx\!tgValue\empty - \tablehrulethicknessfactor + \c_tabl_table_hrule_thickness_factor \else \!tgValue % user-specified integer \fi - \tablelinethicknessunit + \d_tabl_table_line_thickness_unit \else \!tgValue % user-specified dimension \fi @@ -1017,11 +1015,11 @@ % \emptyhbox prevents \unskip -\def\dotableLeft #1{#1\hfill\emptyhbox} -\def\dotableCenter#1{\hfill#1\hfill\emptyhbox} -\def\dotableRight #1{\hfill#1} +\def\tabl_table_Left #1{#1\hfill\emptyhbox} +\def\tabl_table_Center#1{\hfill#1\hfill\emptyhbox} +\def\tabl_table_Right #1{\hfill#1} -\def\dotableOpenUp#1#2% +\def\tabl_table_OpenUp#1#2% {\edef\tablestrutheightfactor{\withoutpt\the\dimexpr\tablestrutheightfactor\points+#1\points}% \edef\tablestrutdepthfactor {\withoutpt\the\dimexpr\tablestrutdepthfactor \points+#2\points}} @@ -1032,11 +1030,11 @@ % \tablerighttabskip\tablelefttabskip % LongLines -> [spread \hsize] -\def\dotableJustLeft {\omit\let\!ttRightGlue\hfill} -\def\dotableJustCenter{\omit\hfill\emptyhbox\let\!ttRightGlue\hfill} -\def\dotableJustRight {\omit\hfill\emptyhbox} +\def\tabl_table_JustLeft {\omit\let\!ttRightGlue\hfill} +\def\tabl_table_JustCenter{\omit\hfill\emptyhbox\let\!ttRightGlue\hfill} +\def\tabl_table_JustRight {\omit\hfill\emptyhbox} -\def\dotableSmash +\def\tabl_table_Smash {\relax \ifmmode \expandafter\mathpalette @@ -1056,22 +1054,22 @@ \def\!thFinishVCS {\vpack to\zeropoint{\vss\box\zerocount\vss}} -\def\dotableRaise +\def\tabl_table_Raise {\def\!thSign{+}% \!tgGetValue\!thSetDimen} -\def\dotableLower +\def\tabl_table_Lower {\def\!thSign{-}% \!tgGetValue\!thSetDimen} \def\!thSetDimen {\ifnum\!tgCode=\plusone \ifx\!tgValue\empty - \!taDimenA\tablestrutheightfactor\tablestrutunit - \advance\!taDimenA\tablestrutdepthfactor\tablestrutunit + \!taDimenA\tablestrutheightfactor\d_tabl_table_strut_unit + \advance\!taDimenA\tablestrutdepthfactor\d_tabl_table_strut_unit \divide\!taDimenA\plustwo \else - \!taDimenA\!tgValue\tablestrutunit + \!taDimenA\!tgValue\d_tabl_table_strut_unit \fi \else \!taDimenA\!tgValue @@ -1097,7 +1095,7 @@ \dp\zerocount\zeropoint \box\zerocount} -\def\dotableBackSpace +\def\tabl_table_BackSpace {\!tgGetValue\!thKernBack} \def\!thKernBack @@ -1108,13 +1106,13 @@ \else \!tgValue % user-specified integer \fi - \tablekernunit + \d_tabl_table_kern_unit \else \!tgValue % user-specified dimension \fi \ignorespaces} -\def\dotableVspace +\def\tabl_table_Vspace {\noalign \bgroup \!tgGetValue\!thVspace} @@ -1127,40 +1125,39 @@ \else \!tgValue % user-specified integer \fi - \tablestrutunit + \d_tabl_table_strut_unit \else \!tgValue % user-specified skip \fi \egroup} % Ends the \noalign \appendtoks - \let\JustLeft \dotableJustLeft - \let\JustCenter \dotableJustCenter - \let\JustRight \dotableJustRight - \let\Smash \dotableSmash - \let\Raise \dotableRaise - \let\Lower \dotableLower - \let\BackSpace \dotableBackSpace - \let\Vspace \dotableVspace - \let\OpenUp \dotableOpenUp - \let\TableLeft \dotableLeft - \let\TableCenter \dotableCenter - \let\TableRight \dotableRight + \let\JustLeft \tabl_table_JustLeft + \let\JustCenter \tabl_table_JustCenter + \let\JustRight \tabl_table_JustRight + \let\Smash \tabl_table_Smash + \let\Raise \tabl_table_Raise + \let\Lower \tabl_table_Lower + \let\BackSpace \tabl_table_BackSpace + \let\Vspace \tabl_table_Vspace + \let\OpenUp \tabl_table_OpenUp + \let\TableLeft \tabl_table_Left + \let\TableCenter \tabl_table_Center + \let\TableRight \tabl_table_Right \to \everytable %D \macros %D {inintable, ifsplittables} %D -%D First we declare some variables. These show a bit what we -%D are dealing with. First we introdoce some booleans that -%D enable us, inside as well as outside this module, to -%D determine in what mode we are. +%D First we declare some variables. These show a bit what we are dealing with. First +%D we introdoce some booleans that enable us, inside as well as outside this module, +%D to determine in what mode we are. \newif\ifintable \newif\ifsplittables -%D We show this feature in an example that also shows some of -%D the basic table typesetting commands. +%D We show this feature in an example that also shows some of the basic table +%D typesetting commands. %D %D \startbuffer %D \starttable[|||] @@ -1182,10 +1179,9 @@ %D %D \typebuffer %D -%D This examples shows about the minimum of commands needed to -%D typeset such a table. In this table, the \type {\AR} is -%D automatically translated into the more primitive (but more -%D verbose) commands \type {\SR}, \type {\FR}, \type {\MR} and +%D This examples shows about the minimum of commands needed to typeset such a table. +%D In this table, the \type {\AR} is automatically translated into the more +%D primitive (but more verbose) commands \type {\SR}, \type {\FR}, \type {\MR} and %D \type {\LR} commands. %D %D \startbuffer @@ -1222,10 +1218,9 @@ \def\m!TABLE{TABLE} -%D We already saw that the table macros report errors and -%D provide automatic spacing. These features can only be -%D implemented by keeping track of the state, often the last -%D command on a row. +%D We already saw that the table macros report errors and provide automatic spacing. +%D These features can only be implemented by keeping track of the state, often the +%D last command on a row. \newconstant\tableforcestate \newconstant\tableactionstate @@ -1250,28 +1245,25 @@ \newconstant\tablerowzero \newconstant\TABLEn -%D We store these states using \type {constants}'s and -%D like most variables, these are global ones. When needed, -%D especially when we flush the backgrounds, we can temporary -%D disable the assignment. +%D We store these states using \type {constants}'s and like most variables, these +%D are global ones. When needed, especially when we flush the backgrounds, we can +%D temporary disable the assignment. \newconditional\tableactionstatepermitted -\def\dosettableaction#1{\ifconditional\tableactionstatepermitted\global\tableactionstate#1\fi} -\def\dosettableforce #1{\ifconditional\tableactionstatepermitted\global\tableforcestate #1\fi} +\def\tabl_table_set_action#1{\ifconditional\tableactionstatepermitted\global\tableactionstate#1\fi} +\def\tabl_table_set_force #1{\ifconditional\tableactionstatepermitted\global\tableforcestate #1\fi} -%D To give an impression of what the (well documented) source -%D of \TABLE\ looks like, we first implement an alternative for -%D the numeric keys. The quantity keys (\type{q} and \type{Q}) -%D support the more european way of writing numbers: +%D To give an impression of what the (well documented) source of \TABLE\ looks like, +%D we first implement an alternative for the numeric keys. The quantity keys +%D (\type{q} and \type{Q}) support the more european way of writing numbers: %D %D \startnarrower %D 100.000.000,00 instead of 100,000,000.00 %D \stopnarrower %D -%D The next table shows how to use these keys. We use braces -%D instead of brackets because we need brackets to specify the -%D format. +%D The next table shows how to use these keys. We use braces instead of brackets because +%D we need brackets to specify the format. %D %D \starttyping %D \starttable{|q[00,000]|Q[00,00]|} @@ -1282,22 +1274,18 @@ %D \stoptable %D \stoptyping %D -%D Although a more efficient implementation is possible |<|we -%D can for instance share common macros|>| we just adapt a copy -%D of the numeric ones. To permit double loading of this -%D module, we check for the existence of one of the macros. - -%D To be compatible with the tabulate environment, we also -%D support the \type {l}, \type {c} and \type {r} keys for -%D paragraph entries. - -%D All commands that are executed between rows are to be put in -%D \type {\noalign}. We can however not verify if we (that is -%D \TABLE) does or did not enter this mode. A moderate dirty -%D but useful trick is using our own alternative:\footnote{Once -%D one has entered the stage of redefining \TEX\ primitives, -%D such hacks become a second nature. However, redefining \type -%D {\omit} and \type{\span} is not that easy.} +%D Although a more efficient implementation is possible |<|we can for instance share +%D common macros|>| we just adapt a copy of the numeric ones. To permit double +%D loading of this module, we check for the existence of one of the macros. +%D +%D To be compatible with the tabulate environment, we also support the \type {l}, +%D \type {c} and \type {r} keys for paragraph entries. +%D +%D All commands that are executed between rows are to be put in \type {\noalign}. We +%D can however not verify if we (that is \TABLE) does or did not enter this mode. A +%D moderate dirty but useful trick is using our own alternative:\footnote{Once one +%D has entered the stage of redefining \TEX\ primitives, such hacks become a second +%D nature. However, redefining \type {\omit} and \type{\span} is not that easy.} \def\tablenoalign {\noalign @@ -1314,8 +1302,8 @@ %D \macros %D {starttable} %D -%D The rest of this module is not easy to comprehend, mainly -%D because we have to take care of: +%D The rest of this module is not easy to comprehend, mainly because we have to take +%D care of: %D %D \startitemize[packed] %D \item \type{\startitemize[template]} @@ -1333,18 +1321,18 @@ %D %D \showsetup{starttable} -\newconditional\tablerepeathead -\newconditional\tablerepeattail +\newconditional\c_tabl_table_repeat_head +\newconditional\c_tabl_table_repeat_tail \unexpanded\def\starttable {\bgroup - \dodoubleempty\dostarttable} + \dodoubleempty\table_table_start} -\unexpanded\def\dostarttable[#1][#2]% preamble optional-settings +\unexpanded\def\table_table_start[#1][#2]% preamble optional-settings {\ifsecondargument \setupcurrenttables[#2]% \fi - \let\stoptable\dostoptable + \let\stoptable\table_table_stop \edef\p_tabl_table_split{\directtablesparameter\c!split}% \edef\p_tabl_table_frame{\directtablesparameter\c!frame}% \ifx\p_tabl_table_split\v!auto @@ -1354,10 +1342,10 @@ \fi \fi \ifx\p_tabl_table_split\v!yes - \def\stoptable{\dostoptables\egroup}% not \unexpanded as we look ahead + \def\stoptable{\table_table_stop_s\egroup}% not \unexpanded as we look ahead \expandafter\starttables \else\ifx\p_tabl_table_split\v!repeat - \def\stoptable{\dostoptables\egroup}% not \unexpanded as we look ahead + \def\stoptable{\table_table_stop_s\egroup}% not \unexpanded as we look ahead \doubleexpandafter\starttables \else \ifx\p_tabl_table_frame\empty @@ -1366,23 +1354,23 @@ \startframedcontent[\p_tabl_table_frame]% \fi \postponenotes - \doubleexpandafter\firststagestarttable + \doubleexpandafter\tabl_table_first_stage \fi\fi [#1]} -% We cannot define \unexpanded\def\dostoptable a ssomehow lookahead -% in alignments fail then, so we relax it and define it locally. +% We cannot define the stopper as \type {\unexpanded} because lookahead in +% alignments fail then, so we relax it and define it locally. \let\stoptable\relax -\def\dostoptable - {\dochucktableautorow % before the tail, else noalign problem - \doinserttabletail +\def\table_table_stop + {\tabl_tables_chuck_auto_row % before the tail, else noalign problem + \tabl_table_insert_tail \starttablenoalign - \global\let\dotablehead\empty - \global\let\dotabletail\empty + \global\let\tabl_table_head\empty + \global\let\tabl_table_tail\empty \stoptablenoalign - \dofinishtable + \tabl_table_finish \ifx\p_tabl_table_frame\empty \ifinsidefloat\else \stopbaselinecorrection @@ -1393,19 +1381,19 @@ \fi \egroup} -%D Before we can grab the argument, we have to make sure that -%D the \CATCODES\ are set. The first stage takes care of that. +%D Before we can grab the argument, we have to make sure that the \CATCODES\ are +%D set. The first stage takes care of that. -\def\firststagestarttable +\def\tabl_table_first_stage {\bgroup \global\intabletrue - \secondstagestarttable} + \tabl_table_second_stage} %D \macros %D {definetabletemplate} %D -%D The complex (and main) start macro first takes care of the -%D predefined case. Such a predefined setup looks like: +%D The complex (and main) start macro first takes care of the predefined case. Such +%D a predefined setup looks like: %D %D \starttyping %D \definetabletemplate[test][|||] @@ -1417,8 +1405,7 @@ %D \stoptable %D \stoptyping %D -%D The implementation of the definition macro is not that -%D complicated: +%D The implementation of the definition macro is not that complicated: \installcorenamespace{tablehead} \installcorenamespace{tabletail} @@ -1426,28 +1413,26 @@ \unexpanded\def\definetabletemplate % to be redone {\bgroup \catcode\barasciicode\othercatcode - \doquadrupleempty\dodefinetabletemplate} + \doquadrupleempty\tabl_table_define_template} -\def\dodefinetabletemplate[#1][#2][#3][#4]% +\def\tabl_table_define_template[#1][#2][#3][#4]% {\ifsecondargument - \setgvalue{\??tabletemplate#1}{\dousetabletemplate{#2}{#3}{#4}}% + \setgvalue{\??tabletemplate#1}{\tabl_table_use_template{#2}{#3}{#4}}% \fi \egroup} -\def\dousetabletemplate#1#2#3% - {\gdef\dotablehead{\begincsname\??tablehead#2\endcsname}% - \gdef\dotabletail{\begincsname\??tabletail#3\endcsname}% - \secondstagestarttable[#1]} +\def\tabl_table_use_template#1#2#3% + {\gdef\tabl_table_head{\begincsname\??tablehead#2\endcsname}% + \gdef\tabl_table_tail{\begincsname\??tabletail#3\endcsname}% + \tabl_table_second_stage[#1]} -%D The optional third and fourth arguments define which table -%D head and tail to use. +%D The optional third and fourth arguments define which table head and tail to use. %D %D \starttyping %D \definetabletemplate[test][|||][before][after] %D \stoptyping %D -%D This also means that one can define table heads and tails -%D by name! +%D This also means that one can define table heads and tails by name! %D %D \starttyping %D \starttablehead[before] @@ -1455,50 +1440,50 @@ %D \stoptablehead %D \stoptyping %D -%D Templates defined this way get protected names, that cannot -%D conflict with existing commands. +%D Templates defined this way get protected names, that cannot conflict with +%D existing commands. %D %D \showsetup{definetabletemplate} %D %D The second half of the next macro prepares table %D splitting. -\def\doinserttablehead +\def\tabl_table_insert_head {\starttablenoalign \global\settrue\preventtablebreak \global\setfalse\hassometablehead \stoptablenoalign - \dotablehead + \tabl_table_head \starttablenoalign \global\setfalse\preventtablebreak \stoptablenoalign} -\def\doinserttabletail +\def\tabl_table_insert_tail {\starttablenoalign \global\settrue\preventtablebreak \global\setfalse\hassometabletail \stoptablenoalign - \dotabletail + \tabl_table_tail \starttablenoalign \global\setfalse\preventtablebreak \stoptablenoalign} % \def\doverysimpletableHL % todo % {\starttablenoalign -% \normalexpanded{\noexpand\donormaltablefullrule\m_tabl_table_HLheight}% +% \normalexpanded{\noexpand\tabl_table_normal_full_rule\m_tabl_table_HLheight}% % \stoptablenoalign} -\def\dorestarttable#1% - {\gdef\restarttable{#1}% - \restarttable +\def\tabl_table_restart_indeed#1% + {\gdef\tabl_table_restart{#1}% + \tabl_table_restart % \starttablenoalign % \globalpushmacro\simpletableHL % \global\let\simpletableHL\doverysimpletableHL % \stoptablenoalign - \doinserttablehead - \ifsplittables \ifconditional \tablerepeattail + \tabl_table_insert_head + \ifsplittables \ifconditional \c_tabl_table_repeat_tail \tablenoalign{\goodbreak}% - \doinserttabletail + \tabl_table_insert_tail \tablenoalign{\goodbreak}% \fi \fi % \starttablenoalign @@ -1508,24 +1493,23 @@ \bgroup \catcode\barasciicode\othercatcode -\gdef\secondstagestarttable[#1]% brr nested mess +\gdef\tabl_table_second_stage[#1]% brr nested mess {\bgroup - \@@useotherbar + \tabl_table_use_bar \global\setfalse\tableactionstatepermitted \global\setfalse\hassometablehead \global\setfalse\hassometabletail \expanded{\doifelseinstring{|}{#1}} - {\xdef\restarttable{\noexpand\dorestarttable{\noexpand\thirdstagestarttable{#1}}}} + {\xdef\tabl_table_restart{\noexpand\tabl_table_restart_indeed{\noexpand\tabl_table_third_stage{#1}}}} {\doifelsedefined{\??tabletemplate#1} - {\gdef\restarttable{\getvalue{\??tabletemplate#1}}} - {\gdef\restarttable{\dorestarttable{\getvalue{#1}}}}}% + {\gdef\tabl_table_restart{\getvalue{\??tabletemplate#1}}} + {\gdef\tabl_table_restart{\tabl_table_restart_indeed{\getvalue{#1}}}}}% \egroup - \restarttable} + \tabl_table_restart} \egroup -%D The third stage involves a lot of (re)sets, which we will -%D explain later. +%D The third stage involves a lot of (re)sets, which we will explain later. \appendtoks \fixedspaces @@ -1534,35 +1518,34 @@ %D Now we can start the table. -\newtoks \localtabledefinitions +\newtoks\localtabledefinitions -\def\thirdstagestarttable#1% +\def\tabl_table_third_stage#1% {\global\settrue\tableactionstatepermitted - \dosettableaction\tableunknownstate - \dosettableforce\tableunknownstate - \dotableresetVLvalues - \appendtoks\dolocaltablesetup\to\everytable - \dotablestandardbegin[\ifsplittables u\else b\fi]% + \tabl_table_set_action\tableunknownstate + \tabl_table_set_force\tableunknownstate + \tabl_table_resetVLvalues + \appendtoks\tabl_table_local_setups\to\everytable + \tabl_table_standard_begin[\ifsplittables u\else b\fi]% \the\localtabledefinitions \forgetall % added \edef\currenttableformat{#1}% \doifsomething\currenttableformat {\dogettablenofcolumns\currenttableformat % more modern is to use catcode tables - \expandafter\dobegintableformat\currenttableformat\doendtableformat}} + \expandafter\tabl_table_begin_format\currenttableformat\doendtableformat}} -\def\dofinishtable - {\dochucktableautorow +\def\tabl_table_finish + {\tabl_tables_chuck_auto_row \unskip\crcr - \dotablenormalend + \tabl_table_normal_end \global\intablefalse \egroup} %D \macros %D {starttables} %D -%D Split tables are specified using the plural form of the -%D start and stop commands. +%D Split tables are specified using the plural form of the start and stop commands. %D %D \showsetup{starttables} %D @@ -1583,45 +1566,45 @@ \unexpanded\def\starttables {\bgroup - \let\stoptables\dostoptables + \let\stoptables\table_table_stop_s \splittablestrue \edef\p_tabl_table_split{\directtablesparameter\c!split}% \ifx\p_tabl_table_split\v!repeat - \settrue\tablerepeathead - \settrue\tablerepeattail + \settrue\c_tabl_table_repeat_head + \settrue\c_tabl_table_repeat_tail \else - \setfalse\tablerepeathead - \setfalse\tablerepeattail + \setfalse\c_tabl_table_repeat_head + \setfalse\c_tabl_table_repeat_tail \fi \flushnotes \setbox\tablecontentbox\vbox\bgroup \forgetall - \firststagestarttable} + \tabl_table_first_stage} \let\stoptables\relax % needed for \noalign -\def\dostoptables % not \unexpanded as we need the lookahead (brrr) - {\dochucktableautorow % AM: before the tail, else noalign problem - \ifconditional\tablerepeattail\else\doinserttabletail\fi - \dofinishtable +\def\table_table_stop_s % not \unexpanded as we need the lookahead (brrr) + {\tabl_tables_chuck_auto_row % AM: before the tail, else noalign problem + \ifconditional\c_tabl_table_repeat_tail\else\tabl_table_insert_tail\fi + \tabl_table_finish \egroup \dontcomplain - \dosplittablebox\tablecontentbox - \global\let\dotablehead\empty % new here - \global\let\dotabletail\empty % new here + \tabl_table_split_box\tablecontentbox + \global\let\tabl_table_head\empty % new here + \global\let\tabl_table_tail\empty % new here \flushnotes \egroup} -\def\dosplittablebox#1% +\def\tabl_table_split_box#1% {\resettsplit \def\tsplitminimumfreelines{2}% \def\tsplitminimumfreespace{\zeropoint}% \setbox\tsplitcontent\box#1% - \ifconditional\tablerepeathead \ifconditional\hassometablehead + \ifconditional\c_tabl_table_repeat_head \ifconditional\hassometablehead \setbox\tsplithead\vsplit\tsplitcontent to \lineheight \setbox\tsplithead\vbox{\unvbox\tsplithead}% \fi \fi - \ifconditional\tablerepeattail \ifconditional\hassometabletail + \ifconditional\c_tabl_table_repeat_tail \ifconditional\hassometabletail \setbox\tsplittail\vsplit\tsplitcontent to \lineheight \setbox\tsplittail\vbox{\unvbox\tsplittail}% \fi \fi @@ -1631,9 +1614,8 @@ \fi \handletsplit} -%D When the table in the previous example is split across -%D pages, only the first gets a head. We could have said -%D something like: +%D When the table in the previous example is split across pages, only the first gets +%D a head. We could have said something like: %D %D \starttyping %D \starttablehead @@ -1652,71 +1634,67 @@ %D \stoptables %D \stoptyping %D -%D This time each split table gets a head line and ends with -%D a rule. Keep in mind that such heads also apply to the -%D unbroken ones and should be defined local (grouped) if -%D needed. The rather complicated definition below is due to -%D the fact that the stopcondition is interface language -%D dependant. +%D This time each split table gets a head line and ends with a rule. Keep in mind +%D that such heads also apply to the unbroken ones and should be defined local +%D (grouped) if needed. The rather complicated definition below is due to the fact +%D that the stopcondition is interface language dependant. -\let\dotablehead\empty % needs checking -\let\dotabletail\empty % needs checking +\let\tabl_table_head\empty % needs checking +\let\tabl_table_tail\empty % needs checking \letvalue{\e!start\v!tablehead}\relax \letvalue{\e!stop \v!tablehead}\relax \letvalue{\e!start\v!tabletail}\relax \letvalue{\e!stop \v!tabletail}\relax -%D The second argument is a dummy one, by scanning for it, we -%D get rid of interfering spaces. +%D The second argument is a dummy one, by scanning for it, we get rid of +%D interfering spaces. \newconditional\preventtablebreak \newconditional\hassometablehead \newconditional\hassometabletail -\unexpanded\def\settablehead{\dodoubleempty\dosettablehead} -\unexpanded\def\settabletail{\dodoubleempty\dosettabletail} +\unexpanded\def\settablehead{\dodoubleempty\tabl_table_set_head} +\unexpanded\def\settabletail{\dodoubleempty\tabl_table_set_tail} -% \def\dosettablehead[#1][#2]#3\end{\setvalue{\??tablehead#1}{\tablenoalign{\global\settrue\hassometablehead}#3}} -% \def\dosettabletail[#1][#2]#3\end{\setvalue{\??tabletail#1}{\tablenoalign{\global\settrue\hassometabletail}#3}} +% \def\tabl_table_set_head[#1][#2]#3\end{\setvalue{\??tablehead#1}{\tablenoalign{\global\settrue\hassometablehead}#3}} +% \def\tabl_table_set_tail[#1][#2]#3\end{\setvalue{\??tabletail#1}{\tablenoalign{\global\settrue\hassometabletail}#3}} -\def\dosettablehead[#1][#2]#3\end - {\gdef\dotablehead{\begincsname\??tablehead#1\endcsname}% new +\def\tabl_table_set_head[#1][#2]#3\end + {\gdef\tabl_table_head{\begincsname\??tablehead#1\endcsname}% new \setvalue{\??tablehead#1}{\tablenoalign{\global\settrue\hassometablehead}#3}} -\def\dosettabletail[#1][#2]#3\end - {\gdef\dotabletail{\begincsname\??tabletail#1\endcsname}% new +\def\tabl_table_set_tail[#1][#2]#3\end + {\gdef\tabl_table_tail{\begincsname\??tabletail#1\endcsname}% new \setvalue{\??tabletail#1}{\tablenoalign{\global\settrue\hassometabletail}#3}} \normalexpanded {\def\csname\e!start\v!tablehead\endcsname#1\csname\e!stop\v!tablehead\endcsname% - {\settablehead#1\noexpand\end}} + {\settablehead#1\noexpand\end}} \normalexpanded {\def\csname\e!start\v!tabletail\endcsname#1\csname\e!stop\v!tabletail\endcsname% {\settabletail#1\noexpand\end}} -%D Redundant \type{\HL}'s are removed automatically, so -%D mid||lines can be used without problems. - -%D The order of the next macros is more or less random. First -%D we implement error recovery. Errors are reported to the -%D screen and log file as well as visualized in the table in -%D teletype. +%D Redundant \type{\HL}'s are removed automatically, so mid||lines can be used +%D without problems. +%D +%D The order of the next macros is more or less random. First we implement error +%D recovery. Errors are reported to the screen and log file as well as visualized in +%D the table in teletype. -\def\dofinishtablerow +\def\tabl_table_finish_row {\crcr \starttablenoalign \nobreak - \dosettableaction\tableunknownstate - \globalletempty\dochecktableautorow - \globalletempty\dochucktableautorow + \tabl_table_set_action\tableunknownstate + \globalletempty\tabl_tables_check_auto_row + \globalletempty\tabl_tables_chuck_auto_row \global\currenttablecolumn\zerocount \stoptablenoalign} -%D Next we enter the more complicated area of column and row -%D switching. I won't go into much detail from now on, but just -%D mention the general principles. +%D Next we enter the more complicated area of column and row switching. I won't go +%D into much detail from now on, but just mention the general principles. %D %D \startitemize[3*ruim] %D \sym{\type{\SR}} end a separate row (between rules) @@ -1731,9 +1709,8 @@ %D \sym{\type{\AR}} end a row with automatic spacing %D \stopitemize %D -%D As far as possible, we report confusing situations. In -%D most cases one can use \type{\AR}, which transfigurates -%D itself into one of the other types. +%D As far as possible, we report confusing situations. In most cases one can use +%D \type{\AR}, which transfigurates itself into one of the other types. %D %D \starttyping %D \starttable[||] @@ -1747,27 +1724,24 @@ %D \stoptable %D \stoptyping %D -%D In this example we could have used \type{\AR} without -%D problems. +%D In this example we could have used \type{\AR} without problems. %D -%D Color or gray scale backgrounds precede the content. They -%D are passed over horizontal (division) lines when needed. -%D Errors in the color template are traced elsewhere. Here we -%D only check for inconsistent spacing. Due to the way \TEX\ -%D handles alignments, we cannot automate spacing for colored -%D rows and columns. +%D Color or gray scale backgrounds precede the content. They are passed over +%D horizontal (division) lines when needed. Errors in the color template are traced +%D elsewhere. Here we only check for inconsistent spacing. Due to the way \TEX\ +%D handles alignments, we cannot automate spacing for colored rows and columns. \setnewconstant\tablerowzero\zerocount \appendtoks - \let\SR\dotableSR - \let\FR\dotableFR - \let\MR\dotableMR - \let\LR\dotableLR - \let\AR\dotableAR + \let\SR\tabl_table_SR + \let\FR\tabl_table_FR + \let\MR\tabl_table_MR + \let\LR\tabl_table_LR + \let\AR\tabl_table_AR \to \localtabledefinitions -\unexpanded\def\dotableSR +\unexpanded\def\tabl_table_SR {\ifnum\tableactionstate=\tablefirstrowstate \writestatus\m!TABLE{change \string\SR\space into \string\MR/\string\LR}% \else\ifnum\tableactionstate=\tablemidrowstate @@ -1775,60 +1749,57 @@ \else\ifnum\tableactionstate=\tablemidrowstate \writestatus\m!TABLE{change \string\SR\space into \string\MR/\string\LR}% \fi\fi\fi - \doendtablerow\tableseparaterowstate\tablerowfactor\tablerowfactor} + \tabl_table_end_row_indeed\tableseparaterowstate\tablerowfactor\tablerowfactor} -\unexpanded\def\dotableFR +\unexpanded\def\tabl_table_FR {\ifnum\tableactionstate=\tablemidrowstate \writestatus\m!TABLE{change \string\FR\space into \string\MR/\string\LR}% \else\ifnum\tableactionstate=\tablelastrowstate \writestatus\m!TABLE{change \string\FR\space into \string\MR/\string\LR}% \fi\fi - \doendtablerow\tablefirstrowstate\tablerowfactor\tablerowzero} + \tabl_table_end_row_indeed\tablefirstrowstate\tablerowfactor\tablerowzero} -\unexpanded\def\dotableMR +\unexpanded\def\tabl_table_MR {\ifnum\tableactionstate=\tablerulestate \writestatus\m!TABLE{change \string\MR\space into \string\FR/\string\SR}% \else\ifnum\tableactionstate=\tablelastrowstate \writestatus\m!TABLE{change \string\MR\space into \string\FR}% \fi\fi - \doendtablerow\tablemidrowstate00} + \tabl_table_end_row_indeed\tablemidrowstate00} -\unexpanded\def\dotableLR +\unexpanded\def\tabl_table_LR {\ifnum\tableactionstate=\tablerulestate \writestatus\m!TABLE{change \string\LR\space into \string\FR/\string\SR}% \fi - \doendtablerow\tablelastrowstate\tablerowzero\tablerowfactor} + \tabl_table_end_row_indeed\tablelastrowstate\tablerowzero\tablerowfactor} %D \macros %D {ifcheckTABLEcolums} %D -%D -%D The next macros handle the actual row ending. This macro -%D also take care of space corrections due to table splitting -%D when \type{\MR} and collegues are used. When tracing is -%D enabled, the corrections as well as the values used to -%D determine the available space are shown (in color). By default -%D checking is off. - -\def\doendtablerow#1#2#3% - {\dosettableaction#1% +%D The next macros handle the actual row ending. This macro also take care of space +%D corrections due to table splitting when \type{\MR} and collegues are used. When +%D tracing is enabled, the corrections as well as the values used to determine the +%D available space are shown (in color). By default checking is off. + +\def\tabl_table_end_row_indeed#1#2#3% + {\tabl_table_set_action#1% \ifcase#1\relax % unknown \or - \doendoftableline\SR\SR\tablerowfactor\tablerowfactor + \tabl_tables_end_line\SR\SR\tablerowfactor\tablerowfactor \or - \doendoftableline\FR\FR\tablerowfactor\tablerowzero + \tabl_tables_end_line\FR\FR\tablerowfactor\tablerowzero \or\ifnum\tableforcestate=\tableforcelastrowstate - \doendoftableline\MR\LR\tablerowzero\tablerowfactor + \tabl_tables_end_line\MR\LR\tablerowzero\tablerowfactor \else\ifnum\tableforcestate=\tableforcefirstrowstate - \doendoftableline\MR\FR\tablerowfactor\tablerowzero + \tabl_tables_end_line\MR\FR\tablerowfactor\tablerowzero \else - \doendoftableline\MR\MR\tablerowzero\tablerowzero + \tabl_tables_end_line\MR\MR\tablerowzero\tablerowzero \fi\fi\or - \doendoftableline\LR\LR\tablerowzero\tablerowfactor + \tabl_tables_end_line\LR\LR\tablerowzero\tablerowfactor \fi \starttablenoalign - \dosettableforce\tableunknownstate + \tabl_table_set_force\tableunknownstate \global\currenttablecolumn\zerocount \ifconditional\preventtablebreak \nobreak @@ -1837,61 +1808,57 @@ \fi \stoptablenoalign} -%D Handling \type{\AR} is postponed till the next row. The -%D check takes care of the first and mid rows, the chuck macro -%D |<|how about that name|>| handles the last row. +%D Handling \type{\AR} is postponed till the next row. The check takes care of +%D the first and mid rows, the chuck macro |<|how about that name|>| handles +%D the last row. -\unexpanded\def\dotableAR - {\globallet\dochecktableautorow\dodochecktableautorow - \globallet\dochucktableautorow\dodochucktableautorow} +\unexpanded\def\tabl_table_AR + {\globallet\tabl_tables_check_auto_row\tabl_tables_check_auto_row_indeed + \globallet\tabl_tables_chuck_auto_row\tabl_tables_chuck_auto_row_indeed} -\let\dochecktableautorow\empty -\let\dochucktableautorow\empty +\let\tabl_tables_check_auto_row\empty +\let\tabl_tables_chuck_auto_row\empty -\def\dodochecktableautorow - {\globallet\dochecktableautorow\empty +\def\tabl_tables_check_auto_row_indeed + {\globallet\tabl_tables_check_auto_row\empty \ifnum\tableactionstate=\tablerulestate \FR\else \ifnum\tableactionstate=\tableunknownstate\FR\else \MR\fi\fi} -\def\dodochucktableautorow - {\globalletempty\dochecktableautorow - \globalletempty\dochucktableautorow +\def\tabl_tables_chuck_auto_row_indeed + {\globalletempty\tabl_tables_check_auto_row + \globalletempty\tabl_tables_chuck_auto_row \ifnum\tableactionstate=\tablerulestate \SR\else \ifnum\tableactionstate=\tableunknownstate\SR\else \LR\fi\fi} -%D When a table is split, we also add a tail and when present -%D we repeat the table head. - -%D When tables are split, the spacing before and after a -%D horizontal rule is corrected according to what we expect. +%D When a table is split, we also add a tail and when present we repeat the table +%D head. If a gets split indeed, the spacing before and after a horizontal rule is +%D corrected according to what we expect. -\def\doendoftableline#1#2#3#4% +\def\tabl_tables_end_line#1#2#3#4% {\ifx#1#2\else \writestatus\m!TABLE{\string#1\space changed into \string#2}% \fi - \expandafter\donormaltablelineformat#3#4\crcr % \crcr nodig ? + \expandafter\tabl_table_normal_line_format#3#4\crcr % \crcr nodig ? \tablenoalign{\nobreak\global\settrue\tableactionstatepermitted}} -%D In order to prevent (as good as possible) alignment overflow -%D and therefore \TEX\ error messages, we check the maximum -%D number of columns. We keep track of the current column and -%D maximum column by means of two \COUNTERS. Keep in mind that -%D the number of \type{|}'s and \type{\VL}'s or alike is always -%D one more than the number of columns. +%D In order to prevent (as good as possible) alignment overflow and therefore \TEX\ +%D error messages, we check the maximum number of columns. We keep track of the +%D current column and maximum column by means of two \COUNTERS. Keep in mind that +%D the number of \type{|}'s and \type{\VL}'s or alike is always one more than the +%D number of columns. \newcount\currenttablecolumn -%D While defining this macro we change the \CATCODE\ of -%D \type{|}. When counting the bars, we use a non active -%D representation of the bar, simply because we cannot be sure -%D if the bar is active or not.\footnote{Normally it is, but -%D \TABLE\ changes the catcode when needed.} +% DWhile defining this macro we change the \CATCODE\ of \type{|}. When counting the +% Dbars, we use a non active representation of the bar, simply because we cannot be +% Dsure if the bar is active or not.\footnote{Normally it is, but \TABLE\ changes +% Dthe catcode when needed.} \bgroup - \catcode\barasciicode\othercatcode \gdef\@@otherbar {|} - \catcode\barasciicode\activecatcode \gdef\@@useotherbar {\let|\@@otherbar} + \catcode\barasciicode\othercatcode \gdef\tabl_table_bar {|} + \catcode\barasciicode\activecatcode \gdef\tabl_table_use_bar{\let|\tabl_table_bar} \egroup \bgroup \catcode\barasciicode\othercatcode @@ -1899,7 +1866,7 @@ \gdef\dogettablenofcolumns#1% todo: also divert this to lua as with tabulate {\bgroup \cleanupfeatures % needed ! - \@@useotherbar + \tabl_table_use_bar \egroup} \egroup @@ -1911,46 +1878,47 @@ %D \sym{\type{\HC}} a horizontal colored line %D \stopitemize -\newcount\tablevrulethicknessfactor -\newcount\tablehrulethicknessfactor -\newcount\tabledrulespan -\let \tablecurrentvrulecolor \empty -\let \tablecurrenthrulecolor \empty +\newcount\c_tabl_table_vrule_thickness_factor +\newcount\c_tabl_table_hrule_thickness_factor +\newcount\c_tabl_table_drule_span + +\let\m_tabl_table_vrule_color\empty +\let\m_tabl_table_hrule_color\empty \appendtoks - \let\VL\dotableVL - \let\VC\dotableVC - \let\HL\dotableHL - \let\HC\dotableHC - \let\VS\dotableVS - \let\VD\dotableVD - \let\VT\dotableVT - \let\VN\dotableVN + \let\VL\tabl_table_VL + \let\VC\tabl_table_VC + \let\HL\tabl_table_HL + \let\HC\tabl_table_HC + \let\VS\tabl_table_VS + \let\VD\tabl_table_VD + \let\VT\tabl_table_VT + \let\VN\tabl_table_VN \to \localtabledefinitions -\def\dotableresetVLvalues +\def\tabl_table_resetVLvalues {\global\currenttablecolumn\zerocount} -\def\dotablevrulecommand#1% global assignments +\def\tabl_table_vrulecommand#1% global assignments {\doifelsenumber{#1} - {\global\tablevrulethicknessfactor#1\relax - \global\multiply\tablevrulethicknessfactor\m_tabl_table_VLwidth\relax} - {\xdef\tablecurrentvrulecolor{#1}}} + {\global\c_tabl_table_vrule_thickness_factor#1\relax + \global\multiply\c_tabl_table_vrule_thickness_factor\m_tabl_table_VLwidth\relax} + {\xdef\m_tabl_table_vrule_color{#1}}} -\unexpanded\def\dotableVL - {\dochecktableautorow +\unexpanded\def\tabl_table_VL + {\tabl_tables_check_auto_row \global\advance\currenttablecolumn\plusone - \dosingleempty\dodotableVL} + \dosingleempty\table_tabl_VL_indeed} -\def\dodotableVL[#1]% - {\global\let\tablecurrentvrulecolor\empty - \global\tablevrulethicknessfactor\m_tabl_table_VLwidth\relax +\def\table_tabl_VL_indeed[#1]% + {\global\let\m_tabl_table_vrule_color\empty + \global\c_tabl_table_vrule_thickness_factor\m_tabl_table_VLwidth\relax \iffirstargument - \rawprocesscommalist[#1]\dotablevrulecommand + \rawprocesscommalist[#1]\tabl_table_vrulecommand \fi - \donormaltablecomplexbar}% \relax breaks \use + \tabl_table_normal_line_complex_bar}% \relax breaks \use -\let\dotableVC\dotableVL % for mojca +\let\tabl_table_VC\tabl_table_VL % for mojca % \starttable[|||] % \HL @@ -1960,24 +1928,24 @@ % \HL % \stoptable -\unexpanded\def\dotableVS {\VN1} -\unexpanded\def\dotableVD {\VN2} -\unexpanded\def\dotableVT {\VN3} -\unexpanded\def\dotableVN#1{\global\noftablevrules#1\relax\VL} +\unexpanded\def\tabl_table_VS {\VN1} +\unexpanded\def\tabl_table_VD {\VN2} +\unexpanded\def\tabl_table_VT {\VN3} +\unexpanded\def\tabl_table_VN#1{\global\c_tabl_table_n_of_vrules#1\relax\VL} -\def\dotablehrulecommand#1% global assignments +\def\tabl_table_hrulecommand#1% global assignments {\doifelsenumber{#1} - {\global\tablehrulethicknessfactor#1\relax - \global\multiply\tablehrulethicknessfactor\m_tabl_table_HLheight\relax} - {\xdef\tablecurrenthrulecolor{#1}}} + {\global\c_tabl_table_hrule_thickness_factor#1\relax + \global\multiply\c_tabl_table_hrule_thickness_factor\m_tabl_table_HLheight\relax} + {\xdef\m_tabl_table_hrule_color{#1}}} -\unexpanded\def\dotableHL - {\dochucktableautorow - \dofinishtablerow +\unexpanded\def\tabl_table_HL + {\tabl_tables_chuck_auto_row + \tabl_table_finish_row \starttablenoalign - \dosingleempty\dodotableHL} + \dosingleempty\table_tabl_HL_indeed} -\def\dodotableHL[#1]% +\def\table_tabl_HL_indeed[#1]% {\nobreak \ifnum\tableactionstate=\tablerulestate \writestatus\m!TABLE{skipping \string\HL}% \statusmessage @@ -1988,23 +1956,23 @@ \writestatus\m!TABLE{change \string\MR\space into \string\SR}% \fi\fi \bgroup - \global\tablehrulethicknessfactor\m_tabl_table_HLheight\relax + \global\c_tabl_table_hrule_thickness_factor\m_tabl_table_HLheight\relax \iffirstargument - \global\let\tablecurrenthrulecolor\empty - \rawprocesscommalist[#1]\dotablehrulecommand - \ifx\tablecurrenthrulecolor\empty\else - \switchtocolor[\tablecurrenthrulecolor]% + \global\let\m_tabl_table_hrule_color\empty + \rawprocesscommalist[#1]\tabl_table_hrulecommand + \ifx\m_tabl_table_hrule_color\empty\else + \switchtocolor[\m_tabl_table_hrule_color]% \fi \fi - \donormaltablefullrule + \tabl_table_normal_full_rule \egroup - \doaccounttablelinewidth + \tabl_table_account_width \fi - \dosettableaction\tablerulestate + \tabl_table_set_action\tablerulestate \nobreak \stoptablenoalign} -\let\dotableHC\dotableHL % for mojca +\let\tabl_table_HC\tabl_table_HL % for mojca %D \startitemize[3*ruim] %D \sym{\type{\NL}} a vertical skip @@ -2026,41 +1994,41 @@ % n+1 uitleggen \appendtoks - \let\TB\dotableTB - \let\NL\dotableNL % old - \let\NR\dotableNR - \let\NC\dotableNC - \let\FC\dotableNC - \let\MC\dotableNC - \let\LC\dotableNC + \let\TB\tabl_table_TB + \let\NL\tabl_table_NL % old + \let\NR\tabl_table_NR + \let\NC\tabl_table_NC + \let\FC\tabl_table_NC + \let\MC\tabl_table_NC + \let\LC\tabl_table_NC \to \localtabledefinitions -\unexpanded\def\dotableTB - {\dochucktableautorow - \dofinishtablerow +\unexpanded\def\tabl_table_TB + {\tabl_tables_chuck_auto_row + \tabl_table_finish_row \starttablenoalign - \dosingleempty\dodotableTB} + \dosingleempty\table_tabl_TB_indeed} -\def\dodotableTB[#1]% +\def\table_tabl_TB_indeed[#1]% {\blank[\iffirstargument#1\else\directtablesparameter\c!NL\fi]% \nobreak \stoptablenoalign} -\let\dotableNL\dotableTB +\let\tabl_table_NL\tabl_table_TB -\unexpanded\def\dotableNR +\unexpanded\def\tabl_table_NR {\global\currenttablecolumn\zerocount - \donormaltablelineending + \tabl_table_normal_line_ending \starttablenoalign \nobreak - \dosettableaction\tableunknownstate + \tabl_table_set_action\tableunknownstate \stoptablenoalign} -\unexpanded\def\dotableNC - {\dochecktableautorow +\unexpanded\def\tabl_table_NC + {\tabl_tables_check_auto_row \global\advance\currenttablecolumn \plusone - \donormaltablenobar} - + \tabl_table_normal_no_bar} + %D \startitemize[3*broad] %D \sym{\type{\DL}} %D \sym{\type{\DV}} (\type{\VD}) @@ -2068,38 +2036,38 @@ %D \sym{\type{\DR}} %D \stopitemize -\newconditional\istabledivision +\newconditional\c_tabl_table_is_division \appendtoks - \global\setfalse\istabledivision - \let\DL\dotableDL - \let\DC\dotableDC - \let\DV\dotableDV - \let\DR\dotableDR + \global\setfalse\c_tabl_table_is_division + \let\DL\tabl_table_DL + \let\DC\tabl_table_DC + \let\DV\tabl_table_DV + \let\DR\tabl_table_DR \to \localtabledefinitions -\def\dochecktabledivision - {\ifconditional\istabledivision\else - \dochucktableautorow +\def\tabl_table_check_division + {\ifconditional\c_tabl_table_is_division\else + \tabl_tables_chuck_auto_row \global\currenttablecolumn\zerocount - \global\settrue\istabledivision + \global\settrue\c_tabl_table_is_division \fi} -\def\dotabledrulecommand#1% global assignments +\def\tabl_table_drulecommand#1% global assignments {\doifelsenumber{#1} - {\ifcase\tabledrulespan - \global\tabledrulespan#1\relax + {\ifcase\c_tabl_table_drule_span + \global\c_tabl_table_drule_span#1\relax \else - \global\tablehrulethicknessfactor#1\relax - \global\multiply\tablehrulethicknessfactor\m_tabl_table_VLwidth\relax + \global\c_tabl_table_hrule_thickness_factor#1\relax + \global\multiply\c_tabl_table_hrule_thickness_factor\m_tabl_table_VLwidth\relax \fi} - {\xdef\tablecurrenthrulecolor{#1}}} + {\xdef\m_tabl_table_hrule_color{#1}}} -\unexpanded\def\dotableDL - {\dochecktabledivision - \dosingleempty\dodotableDL} +\unexpanded\def\tabl_table_DL + {\tabl_table_check_division + \dosingleempty\table_tabl_DL_indeed} -\def\dodotableDL[#1]% +\def\table_tabl_DL_indeed[#1]% {\ifnum\tableactionstate=\tablerulestate \writestatus\m!TABLE{skipping \string\DL}% \else @@ -2108,67 +2076,67 @@ \else\ifnum\tableactionstate=\tablefirstrowstate \writestatus\m!TABLE{change \string\MR\space into \string\SR}% \fi\fi - \dosettableaction\tableunknownstate - \global\tablehrulethicknessfactor\m_tabl_table_HLheight\relax - \global\tabledrulespan\zerocount + \tabl_table_set_action\tableunknownstate + \global\c_tabl_table_hrule_thickness_factor\m_tabl_table_HLheight\relax + \global\c_tabl_table_drule_span\zerocount \iffirstargument - \global\let\tablecurrenthrulecolor\empty - \rawprocesscommalist[#1]\dotabledrulecommand - % \ifx\tablecurrenthrulecolor\empty\else - % \switchtocolor[\tablecurrenthrulecolor]% see *DL* + \global\let\m_tabl_table_hrule_color\empty + \rawprocesscommalist[#1]\tabl_table_drulecommand + % \ifx\m_tabl_table_hrule_color\empty\else + % \switchtocolor[\m_tabl_table_hrule_color]% see *DL* % \fi \fi - \ifcase\tabledrulespan + \ifcase\c_tabl_table_drule_span \global\advance\currenttablecolumn \plusone - \donormaltablesinglerule + \tabl_table_normal_single_rule \or \global\advance\currenttablecolumn \plustwo - \donormaltablesinglerule + \tabl_table_normal_single_rule \else \global\advance\currenttablecolumn \plusone - \donormaltablemultirule + \tabl_table_normal_multi_rule \fi \fi} -\unexpanded\def\dotableDV - {\dotableDCV\donormaltablesimplebar} +\unexpanded\def\tabl_table_DV + {\tabl_table_DCV\tabl_table_normal_line_simple_bar} -\unexpanded\def\dotableDC - {\dotableDCV\donormaltablenobar} +\unexpanded\def\tabl_table_DC + {\tabl_table_DCV\tabl_table_normal_no_bar} -\unexpanded\def\dotableDCV#1% - {\dochecktabledivision - \dochecktableautorow +\unexpanded\def\tabl_table_DCV#1% + {\tabl_table_check_division + \tabl_tables_check_auto_row \global\advance\currenttablecolumn \plusone #1} -\unexpanded\def\dotableDR +\unexpanded\def\tabl_table_DR {\global\currenttablecolumn\zerocount % nog check - \donormaltablelineending + \tabl_table_normal_line_ending \starttablenoalign \nobreak - \global\setfalse\istabledivision - \doaccounttablelinewidth % temporary solution - \dosettableaction\tablerulestate + \global\setfalse\c_tabl_table_is_division + \tabl_table_account_width % temporary solution + \tabl_table_set_action\tablerulestate \stoptablenoalign} -\def\doaccounttablelinewidth - {\scratchdimen\tablelinethicknessunit} - -\def\dotableTWO {\use\plustwo} -\def\dotableTHREE {\use\plusthree} -\def\dotableFOUR {\use\plusfour} -\def\dotableFIVE {\use\plusfive} -\def\dotableSIX {\use\plussix} +\def\tabl_table_account_width + {\scratchdimen\d_tabl_table_line_thickness_unit} + +\def\tabl_table_TWO {\use\plustwo} +\def\tabl_table_THREE {\use\plusthree} +\def\tabl_table_FOUR {\use\plusfour} +\def\tabl_table_FIVE {\use\plusfive} +\def\tabl_table_SIX {\use\plussix} \appendtoks - \let\TWO \dotableTWO - \let\THREE\dotableTHREE - \let\FOUR \dotableFOUR - \let\FIVE \dotableFIVE - \let\SIX \dotableSIX + \let\TWO \tabl_table_TWO + \let\THREE\tabl_table_THREE + \let\FOUR \tabl_table_FOUR + \let\FIVE \tabl_table_FIVE + \let\SIX \tabl_table_SIX \let\SPAN \use - \let\REF \dotablereformat + \let\REF \tabl_table_reformat \to \localtabledefinitions \installcorenamespace{tables} @@ -2177,19 +2145,19 @@ \installsetuponlycommandhandler \??tables {tables} % some day we can have named tables -\setvalue{\??tabledistance\v!none }{\dotableOpenUp00\def\LOW{\Lower6 }} -\setvalue{\??tabledistance\v!small }{\dotableOpenUp00\def\LOW{\Lower6 }} % == baseline -\setvalue{\??tabledistance\v!medium}{\dotableOpenUp11\def\LOW{\Lower7 }} -\setvalue{\??tabledistance\v!big }{\dotableOpenUp22\def\LOW{\Lower8 }} +\setvalue{\??tabledistance\v!none }{\tabl_table_OpenUp00\def\LOW{\Lower6 }} +\setvalue{\??tabledistance\v!small }{\tabl_table_OpenUp00\def\LOW{\Lower6 }} % == baseline +\setvalue{\??tabledistance\v!medium}{\tabl_table_OpenUp11\def\LOW{\Lower7 }} +\setvalue{\??tabledistance\v!big }{\tabl_table_OpenUp22\def\LOW{\Lower8 }} \appendtoks \expandnamespaceparameter\??tabledistance\directtablesparameter\c!distance\v!medium \to \localtabledefinitions -\setvalue{\??tablealign\v!right }{\def\dotableparalignment{\raggedright}} -\setvalue{\??tablealign\v!left }{\def\dotableparalignment{\raggedleft}} -\setvalue{\??tablealign\v!middle }{\def\dotableparalignment{\raggedcenter}} -\setvalue{\??tablealign\s!unknown}{\def\dotableparalignment{\notragged}} +\setvalue{\??tablealign\v!right }{\def\tabl_table_paralignment{\raggedright}} +\setvalue{\??tablealign\v!left }{\def\tabl_table_paralignment{\raggedleft}} +\setvalue{\??tablealign\v!middle }{\def\tabl_table_paralignment{\raggedcenter}} +\setvalue{\??tablealign\s!unknown}{\def\tabl_table_paralignment{\notragged}} \appendtoks \doifelse{\directtablesparameter\c!distance}\v!none @@ -2199,11 +2167,11 @@ \def\dohandlebar % here ? {\ifmmode - \@EA\domathmodebar + \expandafter\domathmodebar \else\ifintable - \@EAEAEA\domathmodebar + \doubleexpandafter\domathmodebar \else - \@EAEAEA\dotextmodebar + \doubleexpandafter\dotextmodebar \fi\fi} \appendtoks @@ -2212,10 +2180,10 @@ \assignalfadimension{\directtablesparameter\c!HL}\m_tabl_table_HLheight246% \to \everysetuptables -\def\dolocaltablesetup +\def\tabl_table_local_setups {\directtablesparameter\c!commands\relax \usebodyfontparameter\directtablesparameter - \tablelinethicknessunit\dimexpr\directtablesparameter\c!rulethickness/\tablelinethicknessfactor\relax + \d_tabl_table_line_thickness_unit\dimexpr\directtablesparameter\c!rulethickness/\tablelinethicknessfactor\relax \edef\p_tabl_table_height{\directtablesparameter\c!height}% \edef\p_tabl_table_depth{\directtablesparameter\c!depth}% \ifx\p_tabl_table_height\v!strut @@ -2230,13 +2198,13 @@ \fi \edef\tablestrutheightfactor{\withoutpt\the\dimexpr10\dimexpr\tablestrutheightfactor\points}% \edef\tablestrutdepthfactor {\withoutpt\the\dimexpr10\dimexpr\tablestrutdepthfactor \points}% - \tablestrutunit\dimexpr\normalbaselineskip/12\relax % 12 is default bodyfont - \tableintercolumnspaceunit.5em plus 1fil minus .25em\relax - \tablecolumnwidthunit .5em\relax - \tablekernunit .5em\relax} + \d_tabl_table_strut_unit \dimexpr\normalbaselineskip/12\relax % 12 is default bodyfont + \d_tabl_table_kern_unit .5em\relax + \s_tabl_table_inter_column_space_unit.5em plus 1fil minus .25em\relax + \d_tabl_table_column_width_unit \d_tabl_table_kern_unit + \d_tabl_table_kern_unit \d_tabl_table_kern_unit} -%D As one can see, we didn't only add color, but also more -%D control over spacing. +%D As one can see, we didn't only add color, but also more control over spacing. %D %D \startbuffer[a] %D \starttable[|c|] @@ -2268,11 +2236,10 @@ %D %D \typebuffer[b] %D -%D The first table is typeset using the default height and -%D depth factors .8 and .4. The second table has both factors -%D set to \type {strut}, and the third table shows what -%D happens when we set the values to zero. The rightmost table -%D is typeset using the tabulate environment. +%D The first table is typeset using the default height and depth factors .8 and .4. +%D The second table has both factors set to \type {strut}, and the third table shows +%D what happens when we set the values to zero. The rightmost table is typeset using +%D the tabulate environment. %D %D \startcombination[4*1] %D {$\vcenter{\getbuffer[a]}$} diff --git a/tex/context/base/mkiv/task-ini.lua b/tex/context/base/mkiv/task-ini.lua index ebfbbdc26..6039efc03 100644 --- a/tex/context/base/mkiv/task-ini.lua +++ b/tex/context/base/mkiv/task-ini.lua @@ -111,6 +111,9 @@ appendaction("math", "builders", "builders.kernel.mlist_to_hlist") ------------("math", "builders", "noads.handlers.italics", nil, "nohead") -- disabled appendaction("math", "builders", "typesetters.directions.processmath") -- disabled (has to happen pretty late) +if LUATEXVERSION >= 0.895 then + appendaction("finalizers", "lists", "typesetters.paragraphs.normalize") -- moved here +end appendaction("finalizers", "lists", "typesetters.margins.localhandler") -- disabled appendaction("finalizers", "lists", "builders.paragraphs.keeptogether") ------------("finalizers", "lists", "nodes.handlers.graphicvadjust") -- todo diff --git a/tex/context/base/mkiv/toks-ini.mkiv b/tex/context/base/mkiv/toks-ini.mkiv index 49625a939..03ec99742 100644 --- a/tex/context/base/mkiv/toks-ini.mkiv +++ b/tex/context/base/mkiv/toks-ini.mkiv @@ -16,6 +16,7 @@ \registerctxluafile{toks-ini}{1.001} \registerctxluafile{toks-scn}{1.001} \registerctxluafile{cldf-scn}{1.001} +\registerctxluafile{cldf-stp}{1.001} \unprotect diff --git a/tex/context/base/mkiv/trac-par.lua b/tex/context/base/mkiv/trac-par.lua index aab57ce5c..fc3be5b6c 100644 --- a/tex/context/base/mkiv/trac-par.lua +++ b/tex/context/base/mkiv/trac-par.lua @@ -7,6 +7,8 @@ if not modules then modules = { } end modules ['trac-par'] = { comment = "a translation of the built in parbuilder, initial convertsin by Taco Hoekwater", } +-- todo: kern + local utfchar = utf.char local concat = table.concat diff --git a/tex/context/base/mkiv/trac-vis.lua b/tex/context/base/mkiv/trac-vis.lua index 3fc8ebc6d..f77a10364 100644 --- a/tex/context/base/mkiv/trac-vis.lua +++ b/tex/context/base/mkiv/trac-vis.lua @@ -370,7 +370,7 @@ end local f_cache = { } local function fontkern(head,current) - local kern = getfield(current,"kern") + local kern = getfield(current,"kern") + getfield(current,"expansion_factor") local info = f_cache[kern] if info then -- print("hit fontkern") diff --git a/tex/context/base/mkiv/typo-bld.lua b/tex/context/base/mkiv/typo-bld.lua index ade171c5d..ab57a46f7 100644 --- a/tex/context/base/mkiv/typo-bld.lua +++ b/tex/context/base/mkiv/typo-bld.lua @@ -46,15 +46,12 @@ local hpack_node = nodes.hpack local starttiming = statistics.starttiming local stoptiming = statistics.stoptiming -local normalize_global = true -local normalize_local = true - -directives.register("paragraphs.normalize.global", function(v) normalize_global = v end) -- adds 2% runtime -directives.register("paragraphs.normalize.local", function(v) normalize_local = v end) -- adds 2% runtime - storage.register("builders/paragraphs/constructors/names", names, "builders.paragraphs.constructors.names") storage.register("builders/paragraphs/constructors/numbers", numbers, "builders.paragraphs.constructors.numbers") +local trace_page_builder = false trackers.register("builders.page", function(v) trace_page_builder = v end) +local trace_post_builder = false trackers.register("builders.post", function(v) trace_post_builder = v end) + local report_parbuilders = logs.reporter("parbuilders") local mainconstructor = nil -- not stored in format @@ -193,9 +190,6 @@ function builders.vpack_filter(head,groupcode,size,packtype,maxdepth,direction) local done = false if head then starttiming(builders) --- if normalize_local then --- normalize(head,true) -- a bit weird place --- end if trace_vpacking then local before = nodes.count(head) head, done = vboxactions(head,groupcode,size,packtype,maxdepth,direction) @@ -232,48 +226,83 @@ end -- check why box is called before after_linebreak .. maybe make categories and -- call 'm less -local build_par_codes = { - pre_box = true, - box = true, - pre_adjust = true, - adjust = true, -} -function builders.buildpage_filter(groupcode) - -- the next check saves 1% runtime on 1000 tufte pages - local head = texlists.contrib_head - local done = false --- if normalize_global and build_par_codes[groupcode] then - if build_par_codes[groupcode] then - -- also called in vbox .. we really need another callback for these four - normalize(head) -- a bit weird place +-- this will be split into contribute_filter for these 4 so at some point +-- thecheck can go away + +if LUATEXVERSION >= 0.895 then + + function builders.buildpage_filter(groupcode) + -- the next check saves 1% runtime on 1000 tufte pages + local head = texlists.contrib_head + local done = false + if head then + -- called quite often ... maybe time to remove timing + starttiming(builders) + if trace_page_builder then + report(groupcode,head) + end + head, done = pageactions(head,groupcode) + stoptiming(builders) + -- -- doesn't work here (not passed on?) + -- tex.pagegoal = tex.vsize - tex.dimen.d_page_floats_inserted_top - tex.dimen.d_page_floats_inserted_bottom + texlists.contrib_head = head or nil -- needs checking + -- tex.setlist("contrib_head",head,head and nodes.tail(head)) + return done and head or true -- no return value needed + else + -- happens quite often + if trace_page_builder then + report(groupcode) + end + return nil, false -- no return value needed + end end - -- - if head then - -- called quite often ... maybe time to remove timing - starttiming(builders) - if trace_page_builder then - report(groupcode,head) + +else + + local build_par_codes = { + pre_box = true, + box = true, + pre_adjust = true, + adjust = true, + } + + function builders.buildpage_filter(groupcode) + -- the next check saves 1% runtime on 1000 tufte pages + local head = texlists.contrib_head + local done = false + if build_par_codes[groupcode] then + -- also called in vbox .. we really need another callback for these four + normalize(head) -- a bit weird place end - head, done = pageactions(head,groupcode) - stoptiming(builders) - -- -- doesn't work here (not passed on?) - -- tex.pagegoal = tex.vsize - tex.dimen.d_page_floats_inserted_top - tex.dimen.d_page_floats_inserted_bottom - texlists.contrib_head = head or nil -- needs checking - -- tex.setlist("contrib_head",head,head and nodes.tail(head)) - return done and head or true -- no return value needed - else - -- happens quite often - if trace_page_builder then - report(groupcode) + -- + if head then + -- called quite often ... maybe time to remove timing + starttiming(builders) + if trace_page_builder then + report(groupcode,head) + end + head, done = pageactions(head,groupcode) + stoptiming(builders) + -- -- doesn't work here (not passed on?) + -- tex.pagegoal = tex.vsize - tex.dimen.d_page_floats_inserted_top - tex.dimen.d_page_floats_inserted_bottom + texlists.contrib_head = head or nil -- needs checking + -- tex.setlist("contrib_head",head,head and nodes.tail(head)) + return done and head or true -- no return value needed + else + -- happens quite often + if trace_page_builder then + report(groupcode) + end + return nil, false -- no return value needed end - return nil, false -- no return value needed end end -callbacks.register('vpack_filter', builders.vpack_filter, "vertical spacing etc") -callbacks.register('buildpage_filter', builders.buildpage_filter, "vertical spacing etc (mvl)") +callbacks.register('vpack_filter', builders.vpack_filter, "vertical spacing etc") +callbacks.register('buildpage_filter', builders.buildpage_filter, "vertical spacing etc (mvl)") +---------.register('contribute_filter', builders.contribute_filter, "adding content to lists") statistics.register("v-node processing time", function() return statistics.elapsedseconds(builders) diff --git a/tex/context/base/mkiv/typo-krn.lua b/tex/context/base/mkiv/typo-krn.lua index 9bf4a5a3b..ddb7abd86 100644 --- a/tex/context/base/mkiv/typo-krn.lua +++ b/tex/context/base/mkiv/typo-krn.lua @@ -103,6 +103,10 @@ local kerns = typesetters.kerns local report = logs.reporter("kerns") local trace_ligatures = false trackers.register("typesetters.kerns.ligatures",function(v) trace_ligatures = v end) +-- use_advance is just an experiment: it makes copying glyphs (instead of new_glyph) dangerous + +local use_advance = false directives.register("typesetters.kerns.advance", function(v) use_advance = v end) + kerns.mapping = kerns.mapping or { } kerns.factors = kerns.factors or { } local a_kerns = attributes.private("kern") @@ -452,7 +456,11 @@ function kerns.handler(head) local data = chardata[font][prevchar] local kerns = data and data.kerns local kern = (kerns and kerns[char] or 0) + quaddata[font]*krn - insert_node_before(head,start,kern_injector(fillup,kern)) + if not fillup and use_advance then + setfield(prev,"xadvance",getfield(prev,"xadvance") + kern) + else + insert_node_before(head,start,kern_injector(fillup,kern)) + end done = true end else diff --git a/tex/context/base/mkiv/typo-lin.lua b/tex/context/base/mkiv/typo-lin.lua index b94fbf2bf..e405d6c21 100644 --- a/tex/context/base/mkiv/typo-lin.lua +++ b/tex/context/base/mkiv/typo-lin.lua @@ -52,7 +52,7 @@ if not modules then modules = { } end modules ['typo-lin'] = { local type = type -local trace_anchors = false trackers.register("paragraphs.anchors", function(v) trace_anchors = v end) +local trace_anchors = false trackers.register("paragraphs.anchors", function(v) trace_anchors = v end) local report = logs.reporter("anchors") diff --git a/tex/context/base/mkiv/util-fil.lua b/tex/context/base/mkiv/util-fil.lua index 42bbe37b3..28c92c7c3 100644 --- a/tex/context/base/mkiv/util-fil.lua +++ b/tex/context/base/mkiv/util-fil.lua @@ -108,7 +108,7 @@ end function files.readinteger2(f) local a, b = byte(f:read(2),1,2) local n = 0x100 * a + b - if n >= 0x8000 then + if n >= 0x8000 then return n - 0xFFFF - 1 else return n @@ -128,7 +128,7 @@ end function files.readinteger4(f) local a, b, c, d = byte(f:read(4),1,4) local n = 0x1000000 * a + 0x10000 * b + 0x100 * c + d - if n >= 0x8000000 then + if n >= 0x8000000 then return n - 0xFFFFFFFF - 1 else return n @@ -138,7 +138,7 @@ end function files.readfixed4(f) local a, b, c, d = byte(f:read(4),1,4) local n = 0x100 * a + b - if n >= 0x8000 then + if n >= 0x8000 then return n - 0xFFFF - 1 + (0x100 * c + d)/0xFFFF else return n + (0x100 * c + d)/0xFFFF diff --git a/tex/context/interface/common/cont-cs.xml b/tex/context/interface/common/cont-cs.xml index 174a03304..8da159659 100644 --- a/tex/context/interface/common/cont-cs.xml +++ b/tex/context/interface/common/cont-cs.xml @@ -3104,9 +3104,6 @@ - - - diff --git a/tex/context/interface/common/cont-de.xml b/tex/context/interface/common/cont-de.xml index d2144c2e3..b3f9289f8 100644 --- a/tex/context/interface/common/cont-de.xml +++ b/tex/context/interface/common/cont-de.xml @@ -3104,9 +3104,6 @@ - - - diff --git a/tex/context/interface/common/cont-en.xml b/tex/context/interface/common/cont-en.xml index f640f99bc..59a6bf6bb 100644 --- a/tex/context/interface/common/cont-en.xml +++ b/tex/context/interface/common/cont-en.xml @@ -3104,9 +3104,6 @@ - - - diff --git a/tex/context/interface/common/cont-fr.xml b/tex/context/interface/common/cont-fr.xml index 02f00c8d1..e8873393e 100644 --- a/tex/context/interface/common/cont-fr.xml +++ b/tex/context/interface/common/cont-fr.xml @@ -3104,9 +3104,6 @@ - - - diff --git a/tex/context/interface/common/cont-it.xml b/tex/context/interface/common/cont-it.xml index 9e0476b76..9d69dc7b5 100644 --- a/tex/context/interface/common/cont-it.xml +++ b/tex/context/interface/common/cont-it.xml @@ -3104,9 +3104,6 @@ - - - diff --git a/tex/context/interface/common/cont-nl.xml b/tex/context/interface/common/cont-nl.xml index 659e499b5..ac955ae54 100644 --- a/tex/context/interface/common/cont-nl.xml +++ b/tex/context/interface/common/cont-nl.xml @@ -3104,9 +3104,6 @@ - - - diff --git a/tex/context/interface/common/cont-pe.xml b/tex/context/interface/common/cont-pe.xml index 02df71b12..d538f4cfb 100644 --- a/tex/context/interface/common/cont-pe.xml +++ b/tex/context/interface/common/cont-pe.xml @@ -3104,9 +3104,6 @@ - - - diff --git a/tex/context/interface/common/cont-ro.xml b/tex/context/interface/common/cont-ro.xml index 284813b4b..21ffea245 100644 --- a/tex/context/interface/common/cont-ro.xml +++ b/tex/context/interface/common/cont-ro.xml @@ -3104,9 +3104,6 @@ - - - diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 8b411ce15..5ed9f2e36 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 03/04/16 10:39:33 +-- merge date : 03/12/16 16:42:37 do -- begin closure to overcome local limits and interference @@ -7212,7 +7212,7 @@ local type,next,tonumber,tostring=type,next,tonumber,tostring local abs=math.abs local reversed,concat,insert,remove,sortedkeys=table.reversed,table.concat,table.insert,table.remove,table.sortedkeys local ioflush=io.flush -local fastcopy,tohash,derivetable=table.fastcopy,table.tohash,table.derive +local fastcopy,tohash,derivetable,copy=table.fastcopy,table.tohash,table.derive,table.copy local formatters=string.formatters local P,R,S,C,Ct,lpegmatch=lpeg.P,lpeg.R,lpeg.S,lpeg.C,lpeg.Ct,lpeg.match local setmetatableindex=table.setmetatableindex @@ -7237,7 +7237,7 @@ local report_otf=logs.reporter("fonts","otf loading") local fonts=fonts local otf=fonts.handlers.otf otf.glists={ "gsub","gpos" } -otf.version=2.820 +otf.version=2.823 otf.cache=containers.define("fonts","otf",otf.version,true) local hashes=fonts.hashes local definers=fonts.definers @@ -7375,6 +7375,7 @@ local valid_fields=table.tohash { "isserif", "italicangle", "macstyle", + "notdef_loc", "onlybitmaps", "origname", "os2_version", @@ -7773,7 +7774,6 @@ local function somecopy(old) end end actions["prepare glyphs"]=function(data,filename,raw) - local tableversion=tonumber(raw.table_version) or 0 local rawglyphs=raw.glyphs local rawsubfonts=raw.subfonts local rawcidinfo=raw.cidinfo @@ -7787,6 +7787,7 @@ actions["prepare glyphs"]=function(data,filename,raw) local indices=resources.indices local duplicates=resources.duplicates local variants=resources.variants + local notdefindex=-1 if rawsubfonts then metadata.subfonts=includesubfonts and {} properties.cidinfo=rawcidinfo @@ -7806,15 +7807,12 @@ actions["prepare glyphs"]=function(data,filename,raw) if includesubfonts then metadata.subfonts[cidindex]=somecopy(subfont) end - local cidcnt,cidmin,cidmax - if tableversion>0.3 then - cidcnt=subfont.glyphcnt - cidmin=subfont.glyphmin - cidmax=subfont.glyphmax - else - cidcnt=subfont.glyphcnt - cidmin=0 - cidmax=cidcnt-1 + local cidcnt=subfont.glyphcnt + local cidmin=subfont.glyphmin + local cidmax=subfont.glyphmax + local notdef=(tonumber(raw.table_version) or 0)>0.4 and subfont.notdef_loc or -1 + if notdeffound==-1 and notdef>=0 then + notdeffound=notdef end if trace_subfonts then local cidtot=cidmax-cidmin+1 @@ -7822,10 +7820,9 @@ actions["prepare glyphs"]=function(data,filename,raw) report_otf("subfont: %i, min: %i, max: %i, cnt: %i, n: %i",cidindex,cidmin,cidmax,cidtot,cidcnt) end if cidcnt>0 then - for cidslot=cidmin,cidmax do - local glyph=cidglyphs[cidslot] + for index=cidmin,cidmax do + local glyph=cidglyphs[index] if glyph then - local index=tableversion>0.3 and glyph.orig_pos or cidslot if trace_subfonts then unique[index]=true end @@ -7869,8 +7866,7 @@ actions["prepare glyphs"]=function(data,filename,raw) local description={ boundingbox=glyph.boundingbox, name=name or "unknown", - cidindex=cidindex, - index=cidslot, + index=index, glyph=glyph, } descriptions[unicode]=description @@ -7913,8 +7909,9 @@ actions["prepare glyphs"]=function(data,filename,raw) end else local cnt=raw.glyphcnt or 0 - local min=tableversion>0.3 and raw.glyphmin or 0 - local max=tableversion>0.3 and raw.glyphmax or (raw.glyphcnt-1) + local min=raw.glyphmin or 0 + local max=raw.glyphmax or (raw.glyphcnt-1) + notdeffound=(tonumber(raw.table_version) or 0)>0.4 and raw.notdef_loc or -1 if cnt>0 then for index=min,max do local glyph=rawglyphs[index] @@ -7985,6 +7982,12 @@ actions["prepare glyphs"]=function(data,filename,raw) report_otf("potential problem: no glyphs found") end end + if notdeffound==-1 then + report_otf("warning: no .notdef found in %a",filename) + elseif notdeffound~=0 then + report_otf("warning: .notdef found at position %a in %a",notdeffound,filename) + end + metadata.notdef=notdeffound resources.private=private end actions["check encoding"]=function(data,filename,raw) @@ -8052,7 +8055,7 @@ actions["add duplicates"]=function(data,filename,raw) local unicodes=resources.unicodes local indices=resources.indices local duplicates=resources.duplicates - for unicode,d in next,duplicates do + for unicode,d in table.sortedhash(duplicates) do local nofduplicates=#d if nofduplicates>4 then if trace_loading then @@ -8077,11 +8080,11 @@ actions["add duplicates"]=function(data,filename,raw) end end if u>0 then - local duplicate=table.copy(description) + local duplicate=copy(description) duplicate.comment=formatters["copy of %U"](unicode) descriptions[u]=duplicate if trace_loading then - report_otf("duplicating %U to %U with index %H (%s kerns)",unicode,u,description.index,n) + report_otf("duplicating %06U to %06U with index %H (%s kerns)",unicode,u,description.index,n) end end end @@ -8883,8 +8886,9 @@ actions["check metadata"]=function(data,filename,raw) ttftables[i].data="deleted" end end + local state=metadata.validation_state local names=raw.names - if metadata.validation_state and table.contains(metadata.validation_state,"bad_ps_fontname") then + if state and table.contains(state,"bad_ps_fontname") then local function valid(what) if names then for i=1,#names do @@ -8939,6 +8943,9 @@ actions["check metadata"]=function(data,filename,raw) end metadata.psname=psname end + if state and table.contains(state,"bad_cmap_table") then + report_otf("fontfile %a has bad cmap tables",filename) + end end actions["cleanup tables"]=function(data,filename,raw) local duplicates=data.resources.duplicates @@ -12260,7 +12267,7 @@ function handlers.gsub_ligature(head,start,kind,lookupname,ligature,sequence) end return head,start,false,discfound end -function handlers.gpos_single(head,start,kind,lookupname,kerns,sequence,injection) +function handlers.gpos_single(head,start,kind,lookupname,kerns,sequence,lookuphash,i,injection) local startchar=getchar(start) local dx,dy,w,h=setpair(start,tfmdata.parameters.factor,rlmode,sequence.flags[4],kerns,injection) if trace_kerns then -- cgit v1.2.3