From 95100142e8341d8bd582e16a17a26118dfc8975c Mon Sep 17 00:00:00 2001 From: Marius Date: Tue, 4 Dec 2012 18:40:14 +0200 Subject: beta 2012.12.04 16:56 --- tex/context/base/chem-str.mkiv | 4 +- tex/context/base/colo-ini.mkiv | 19 +++ tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4143 -> 4147 bytes tex/context/base/context-version.png | Bin 40394 -> 40505 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 2 +- tex/context/base/font-fbk.lua | 42 ++++--- tex/context/base/l-unicode.lua | 55 ++++++++- tex/context/base/status-files.pdf | Bin 24488 -> 24528 bytes tex/context/base/status-lua.pdf | Bin 199225 -> 199308 bytes tex/context/base/strc-lst.lua | 129 +++++++++++++++++---- tex/context/base/typo-krn.mkiv | 2 +- tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 15 files changed, 206 insertions(+), 55 deletions(-) (limited to 'tex') diff --git a/tex/context/base/chem-str.mkiv b/tex/context/base/chem-str.mkiv index a2b0f135f..3b50396d1 100644 --- a/tex/context/base/chem-str.mkiv +++ b/tex/context/base/chem-str.mkiv @@ -258,7 +258,7 @@ \global\setfalse\c_chem_some_text \to \everystructurechemical -\def\doaddchemicaltexts +\def\chem_add_texts {\setbox2\hbox to \d_chem_width{\strut\hss\hbox{\strut\m_chem_mid_text}\hss}% \setbox4\hbox to \d_chem_width{\strut\hss\hbox{\strut\m_chem_top_text}\hss}% \setbox6\hbox to \d_chem_width{\strut\hss\hbox{\strut\m_chem_bot_text}\hss}% @@ -275,7 +275,7 @@ \appendtoks \ifconditional\c_chem_some_text - \doaddchemicaltexts + \chem_add_texts \d_chem_width \wd\b_chem_result \d_chem_height\ht\b_chem_result \d_chem_depth \dp\b_chem_result diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv index 629f2b96a..ed550987f 100644 --- a/tex/context/base/colo-ini.mkiv +++ b/tex/context/base/colo-ini.mkiv @@ -698,6 +698,25 @@ % test {\mycolord OEPS} test % test {\mycolorx OEPS} test % \stoptext +% +% Beware: if we say: +% +% \definecolor[one][two] +% +% only color one is actually defined and two is not seen at the +% \LUA\ end. This means that this doesn't work: +% +% \definecolor[ColorA][red] +% \definecolor[ColorB][.5(ColorA)] +% \definecolor[ColorC][.5(ColorB,white)] +% +% But this does work: +% +% \definecolor[ColorA][1.0(red)] +% \definecolor[ColorB][0.5(ColorA)] +% \definecolor[ColorC][0.5(ColorB,white)] +% +% because the fractional definition results in a new definition. \unexpanded\def\defineintermediatecolor {\dotripleempty\colo_basics_define_intermediate} diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 35dbc92d2..0390fc66a 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.12.03 20:57} +\newcontextversion{2012.12.04 16:56} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index e294d9e0a..d68658d27 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.12.03 20:57} +\newcontextversion{2012.12.04 16:56} %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/context-version.pdf b/tex/context/base/context-version.pdf index 92465ce97..aaf6549c1 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/context-version.png b/tex/context/base/context-version.png index 86464708b..d53e5f80e 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index a5fcad1af..93cdc7cd9 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2012.12.03 20:57} +\edef\contextversion{2012.12.04 16:56} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index c1480397d..6cd27d3e7 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -25,7 +25,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.12.03 20:57} +\edef\contextversion{2012.12.04 16:56} %D For those who want to use this: diff --git a/tex/context/base/font-fbk.lua b/tex/context/base/font-fbk.lua index 69b45811a..c7a13775a 100644 --- a/tex/context/base/font-fbk.lua +++ b/tex/context/base/font-fbk.lua @@ -13,13 +13,11 @@ local utfbyte, utfchar = utf.byte, utf.char

This is very experimental code!

--ldx]]-- -local trace_combining = false trackers.register("fonts.combining", function(v) trace_combining = v end) -local trace_combining_all = false trackers.register("fonts.combining.all", function(v) trace_combining = v - trace_combining_all = v end) +local trace_combining_visualize = false trackers.register("fonts.composing.visualize", function(v) trace_combining_visualize = v end) +local trace_combining_define = false trackers.register("fonts.composing.define", function(v) trace_combining_define = v end) - -trackers.register("fonts.composing", "fonts.combining") -trackers.register("fonts.composing.all", "fonts.combining.all") +trackers.register("fonts.combining", "fonts.composing.define") -- for old times sake (and manuals) +trackers.register("fonts.combining.all", "fonts.composing.*") -- for old times sake (and manuals) local report_combining = logs.reporter("fonts","combining") @@ -61,14 +59,14 @@ local function composecharacters(tfmdata) local italicfactor = parameters.italicfactor or 0 local vfspecials = backends.tables.vfspecials --brr local red, green, blue, black - if trace_combining then + if trace_combining_visualize then red = vfspecials.red green = vfspecials.green blue = vfspecials.blue black = vfspecials.black end local compose = fonts.goodies.getcompositions(tfmdata) - if compose and trace_combining then + if compose and trace_combining_visualize then report_combining("using compose information from goodies file") end local done = false @@ -107,7 +105,7 @@ local function composecharacters(tfmdata) cache[chr] = chr_t end if charsacc then - if trace_combining_all then + if trace_combining_define then report_combining("%s (U+%05X) = %s (U+%05X) + %s (U+%05X)",utfchar(i),i,utfchar(chr),chr,utfchar(acc),acc) end local acc_t = cache[acc] @@ -140,7 +138,7 @@ local function composecharacters(tfmdata) local ay = a_anchor.y or 0 local dx = cx - ax local dy = cy - ay - if trace_combining_all then + if trace_combining_define then report_combining("building U+%05X (%s) from U+%05X (%s) and U+%05X (%s)",i,utfchar(i),chr,utfchar(chr),acc,utfchar(acc)) report_combining(" boundingbox:") report_combining(" chr: %3i %3i %3i %3i",unpack(cb)) @@ -151,7 +149,7 @@ local function composecharacters(tfmdata) report_combining(" delta:") report_combining(" %s: %3i %3i",i_anchored,dx,dy) end - if trace_combining then + if trace_combining_visualize then t.commands = { push, {"right", scale*dx}, {"down",-scale*dy}, green, acc_t, black, pop, chr_t } -- t.commands = { -- push, {"right", scale*cx}, {"down", -scale*cy}, red, {"rule",10000,10000,10000}, pop, @@ -171,7 +169,7 @@ local function composecharacters(tfmdata) local dx = (c_urx - a_urx - a_llx + c_llx)/2 local dd = (c_urx - c_llx)*italicfactor if a_ury < 0 then - if trace_combining then + if trace_combining_visualize then t.commands = { push, {"right", dx-dd}, red, acc_t, black, pop, chr_t } else t.commands = { push, {"right", dx-dd}, acc_t, pop, chr_t } @@ -183,16 +181,16 @@ local function composecharacters(tfmdata) -- takes time and code dy = compose[i] if dy then - dy = dy.DY + dy = dy.dy end if not dy then dy = compose[acc] if dy then - dy = dy and dy.DY + dy = dy and dy.dy end end if not dy then - dy = compose.DY + dy = compose.dy end if not dy then dy = - deltaxheight + extraxheight @@ -206,13 +204,13 @@ local function composecharacters(tfmdata) else dy = - deltaxheight + extraxheight end - if trace_combining then + if trace_combining_visualize then t.commands = { push, {"right", dx+dd}, {"down", dy}, green, acc_t, black, pop, chr_t } else t.commands = { push, {"right", dx+dd}, {"down", dy}, acc_t, pop, chr_t } end else - if trace_combining then + if trace_combining_visualize then t.commands = { push, {"right", dx+dd}, blue, acc_t, black, pop, chr_t } else t.commands = { push, {"right", dx+dd}, acc_t, pop, chr_t } @@ -223,7 +221,7 @@ local function composecharacters(tfmdata) t.commands = { chr_t } -- else index mess end else - if trace_combining_all then + if trace_combining_define then report_combining("%s (U+%05X) = %s (U+%05X) (simplified)",utfchar(i),i,utfchar(chr),chr) end t.commands = { chr_t } -- else index mess @@ -270,11 +268,11 @@ vf.helpers.composecharacters = composecharacters -- which only makes sense as demo. commands["compose.trace.enable"] = function() - trace_combining = true + trace_combining_visualize = true end commands["compose.trace.disable"] = function() - trace_combining = false + trace_combining_visualize = false end commands["compose.force.enable"] = function() @@ -287,9 +285,9 @@ end commands["compose.trace.set"] = function(g,v) if v[2] == nil then - trace_combining = true + trace_combining_visualize = true else - trace_combining = v[2] + trace_combining_visualize = v[2] end end diff --git a/tex/context/base/l-unicode.lua b/tex/context/base/l-unicode.lua index 630c34960..7fd380b88 100644 --- a/tex/context/base/l-unicode.lua +++ b/tex/context/base/l-unicode.lua @@ -12,10 +12,10 @@ if not modules then modules = { } end modules ['l-unicode'] = { local concat = table.concat local type = type -local P, C, R, Cs, Ct = lpeg.P, lpeg.C, lpeg.R, lpeg.Cs, lpeg.Ct +local P, C, R, Cs, Ct, Cmt = lpeg.P, lpeg.C, lpeg.R, lpeg.Cs, lpeg.Ct, lpeg.Cmt local lpegmatch, patterns = lpeg.match, lpeg.patterns local utftype = patterns.utftype -local char, byte, find, bytepairs, utfvalues, format = string.char, string.byte, string.find, string.bytepairs, string.utfvalues, string.format +local char, byte, find, bytepairs, utfvalues, format, sub = string.char, string.byte, string.find, string.bytepairs, string.utfvalues, string.format, string.sub local utfsplitlines = string.utfsplitlines if not unicode then @@ -89,6 +89,57 @@ if not utf.byte then end +if not utf.sub then + + local utf8char = patterns.utf8char + + -- inefficient as lpeg just copies ^n + + -- local function sub(str,start,stop) + -- local pattern = utf8char^-(start-1) * C(utf8char^-(stop-start+1)) + -- inspect(pattern) + -- return lpegmatch(pattern,str) or "" + -- end + + local b, e, n, first, last = 0, 0, 0, 0, 0 + + local function slide(s,p) + n = n + 1 + if n == first then + b = p + if not last then + return nil + end + end + if n == last then + e = p + return nil + else + return p + end + end + + local pattern = Cmt(utf8char,slide)^0 + + function utf.sub(str,start,stop) -- todo: from the end + if not start then + return str + end + b, e, n, first, last = 0, 0, 0, start, stop + lpegmatch(pattern,str) + if not stop then + return sub(str,b) + else + return sub(str,b,e) + end + end + + -- print(utf.sub("Hans Hagen is my name")) + -- print(utf.sub("Hans Hagen is my name",5)) + -- print(utf.sub("Hans Hagen is my name",5,10)) + +end + local utfchar, utfbyte = utf.char, utf.byte -- As we want to get rid of the (unmaintained) utf library we implement our own diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 5b7000428..08fccd1d3 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index f7d44e59f..bddcf54a9 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/strc-lst.lua b/tex/context/base/strc-lst.lua index 424e9e05b..0c13e28b2 100644 --- a/tex/context/base/strc-lst.lua +++ b/tex/context/base/strc-lst.lua @@ -122,7 +122,7 @@ function lists.addto(t) end local m = t.metadata local r = t.references - local i = (r and r.internal) or 0 -- brrr + local i = r and r.internal or 0 -- brrr local p = pushed[i] if not p then p = #cached + 1 @@ -130,7 +130,6 @@ function lists.addto(t) pushed[i] = p r.listindex = p end - -- local setcomponent = references.setcomponent if setcomponent then setcomponent(t) -- might move to the tex end @@ -192,26 +191,6 @@ function lists.enhance(n) end end ---~ function lists.enforce(n) ---~ -- todo: symbolic names for counters ---~ local l = cached[n] ---~ if l then ---~ -- ---~ l.directives = nil -- might change ---~ -- save in the right order (happens at shipout) ---~ lists.tobesaved[#lists.tobesaved+1] = l ---~ -- default enhancer (cross referencing) ---~ l.references.realpage = texcount.realpageno ---~ -- specific enhancer (kind of obsolete) ---~ local kind = l.metadata.kind ---~ local enhancer = kind and lists.enhancers[kind] ---~ if enhancer then ---~ enhancer(l) ---~ end ---~ return l ---~ end ---~ end - -- we can use level instead but we can also decide to remove level from the metadata local nesting = { } @@ -730,10 +709,27 @@ function commands.savedlisttitle(name,n,tag) end end +-- function commands.savedlistprefixednumber(name,n) +-- local data = cached[tonumber(n)] +-- if data then +-- local numberdata = data.numberdata +-- if numberdata then +-- helpers.prefix(data,data.prefixdata) +-- sections.typesetnumber(numberdata,"number",numberdata or false) +-- end +-- end +-- end + +if not lists.reordered then + function lists.reordered(data) + return data.numberdata + end +end + function commands.savedlistprefixednumber(name,n) local data = cached[tonumber(n)] if data then - local numberdata = data.numberdata + local numberdata = lists.reordered(data) if numberdata then helpers.prefix(data,data.prefixdata) sections.typesetnumber(numberdata,"number",numberdata or false) @@ -742,3 +738,90 @@ function commands.savedlistprefixednumber(name,n) end commands.discardfromlist = lists.discard + +-- new and experimental and therefore off by default + +local sort, setmetatableindex = table.sort, table.setmetatableindex + +lists.autoreorder = false -- true + +local function addlevel(t,k) + local v = { } + setmetatableindex(v,function(t,k) + local v = { } + t[k] = v + return v + end) + t[k] = v + return v +end + +local internals = setmetatableindex({ }, function(t,k) + + local sublists = setmetatableindex({ },addlevel) + + local collected = lists.collected or { } + + for i=1,#collected do + local entry = collected[i] + local numberdata = entry.numberdata + if numberdata then + local metadata = entry.metadata + if metadata then + local references = entry.references + if references then + local kind = metadata.kind + local name = metadata.name + local internal = references.internal + if kind and name and internal then + local sublist = sublists[kind][name] + sublist[#sublist + 1] = { internal, numberdata } + end + end + end + end + end + + for k, v in next, sublists do + for k, v in next, v do + local tmp = { } + for i=1,#v do + tmp[i] = v[i] + end + sort(v,function(a,b) return a[1] < b[1] end) + for i=1,#v do + t[v[i][1]] = tmp[i][2] + end + end + end + + setmetatableindex(t,nil) + + return t[k] + +end) + +function lists.reordered(entry) + local numberdata = entry.numberdata + if lists.autoreorder then + if numberdata then + local metadata = entry.metadata + if metadata then + local references = entry.references + if references then + local kind = metadata.kind + local name = metadata.name + local internal = references.internal + if kind and name and internal then + return internals[internal] or numberdata + end + end + end + end + else + function lists.reordered(entry) + return entry.numberdata + end + end + return numberdata +end diff --git a/tex/context/base/typo-krn.mkiv b/tex/context/base/typo-krn.mkiv index cb1dcdd18..a47bd2ac5 100644 --- a/tex/context/base/typo-krn.mkiv +++ b/tex/context/base/typo-krn.mkiv @@ -129,7 +129,7 @@ \fi \edef\p_width{\characterkerningparameter\c!width}% \ifx\p_width\empty \else - \hbox to \p_width + \hbox to \p_width \fi \bgroup \usecharacterkerningstyleandcolor\c!style\c!color diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 5ff674552..306747e86 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 : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 12/03/12 20:57:03 +-- merge date : 12/04/12 16:56:37 do -- begin closure to overcome local limits and interference -- cgit v1.2.3