diff options
Diffstat (limited to 'tex')
28 files changed, 287 insertions, 228 deletions
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 51bce134d..f2a17f470 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/mkiv/anch-bck.mkvi b/tex/context/base/mkiv/anch-bck.mkvi index ee392f114..953c3440f 100644 --- a/tex/context/base/mkiv/anch-bck.mkvi +++ b/tex/context/base/mkiv/anch-bck.mkvi @@ -228,7 +228,7 @@ \ifgridsnapping \spac_helpers_assign_skip\textbackgroundskip{\textbackgroundparameter\c!topoffset}% \ifdim\textbackgroundskip>\zeropoint - \struttedbox{\hbox{\raise\textbackgroundskip\hbox{\bpos\v_anch_backgrounds_text_current}}}% + \struttedbox{\hpack{\raise\textbackgroundskip\hpack{\bpos\v_anch_backgrounds_text_current}}}% \else \bpos\v_anch_backgrounds_text_current \fi @@ -281,7 +281,7 @@ \spac_helpers_assign_skip\textbackgroundskip{\textbackgroundparameter\c!bottomoffset}% \ifgridsnapping % experimental, pascal (todo: topoffset in same way) \ifdim\textbackgroundskip>\zeropoint - \struttedbox\plusone{\hbox{\lower\textbackgroundskip\hbox{\epos\v_anch_backgrounds_text_current}}}% + \struttedbox\plusone{\hpack{\lower\textbackgroundskip\hpack{\epos\v_anch_backgrounds_text_current}}}% \else \epos\v_anch_backgrounds_text_current \fi diff --git a/tex/context/base/mkiv/anch-pgr.lua b/tex/context/base/mkiv/anch-pgr.lua index b5c2ae628..dc26499bf 100644 --- a/tex/context/base/mkiv/anch-pgr.lua +++ b/tex/context/base/mkiv/anch-pgr.lua @@ -35,7 +35,8 @@ local f_pair = formatters["(%p,%p)"] local f_path = formatters["%--t--cycle"] local function regionarea(r) - local rx, ry = r.x, r.y + local rx = r.x + local ry = r.y local rw = rx + r.w local rh = ry + r.h local rd = ry - r.d @@ -103,7 +104,8 @@ local function finish(t) end local function clip(t,ytop,ybot) - local first, last = 1, #t + local first = 1 + local last = #t for i=first,last do local y = t[i][2] if ytop < y then @@ -125,15 +127,15 @@ end -- todo: mark regions and free paragraphs in collected -local function shapes(r,rx,ry,rw,rh,rd,lytop,lybot,rytop,rybot,obeyhang) +local function shapes(r,rx,ry,rw,rh,rd,lytop,lybot,rytop,rybot,obeyhang,r2l) -- we assume that we only hang per page and not cross pages -- which makes sense as hanging is only uses in special cases -- -- we can remove data as soon as a page is done so we could -- remember per page and discard areas after each shipout - local leftshape, rightshape - leftshape = { { rx, rh } } -- spikes get removed so we can start at the edge - rightshape = { { rw, rh } } -- even if we hang next + local delta = r2l and (rw - rx) or 0 + local leftshape = { { rx + delta, rh } } -- spikes get removed so we can start at the edge + local rightshape = { { rw - delta, rh } } -- even if we hang next local paragraphs = r.paragraphs local extending = false if paragraphs then @@ -151,16 +153,16 @@ local function shapes(r,rx,ry,rw,rh,rd,lytop,lybot,rytop,rybot,obeyhang) -- ha < 0 hi > 0 : left top if ha < 0 then if hi < 0 then -- right - add(rightshape,rw, py_ph,"up") - add(rightshape,rw + hi,py_ph,"up") - add(rightshape,rw + hi,py_ph + hang,"up") - add(rightshape,rw, py_ph + hang,"up") + add(rightshape,rw - delta, py_ph,"up") + add(rightshape,rw - delta + hi,py_ph,"up") + add(rightshape,rw - delta + hi,py_ph + hang,"up") + add(rightshape,rw - delta, py_ph + hang,"up") else -- left - add(leftshape,rx,py_ph,"down") - add(leftshape,rx + hi,py_ph,"down") - add(leftshape,rx + hi,py_ph + hang,"down") - add(leftshape,rx,py_ph + hang,"down") + add(leftshape,rx + delta,py_ph,"down") + add(leftshape,rx + delta + hi,py_ph,"down") + add(leftshape,rx + delta + hi,py_ph + hang,"down") + add(leftshape,rx + delta,py_ph + hang,"down") end else -- maybe some day @@ -181,11 +183,11 @@ local function shapes(r,rx,ry,rw,rh,rd,lytop,lybot,rytop,rybot,obeyhang) local p = ps[i] local l = p[1] local w = p[2] - add(leftshape,rx + l, py_ph,"up") - add(rightshape,rx + l + w, py_ph,"down") + add(leftshape, rx + delta + l, py_ph,"up") + add(rightshape,rx - delta + l + w, py_ph,"down") py_ph = py_ph - step - add(leftshape,rx + l, py_ph,"up") - add(rightshape,rx + l + w, py_ph,"down") + add(leftshape, rx + delta + l, py_ph,"up") + add(rightshape,rx - delta + l + w, py_ph,"down") end extending = true elseif extending then @@ -194,10 +196,10 @@ local function shapes(r,rx,ry,rw,rh,rd,lytop,lybot,rytop,rybot,obeyhang) local pd = p.d local py_ph = py + ph local py_pd = py - pd - add(leftshape,leftshape[#leftshape][1],py_ph,"up") + add(leftshape, leftshape [#leftshape ][1],py_ph,"up") add(rightshape,rightshape[#rightshape][1],py_ph,"down") - add(leftshape,rx,py_ph,"up") -- shouldn't this be py_pd - add(rightshape,rw,py_ph,"down") -- shouldn't this be py_pd + add(leftshape, rx + delta,py_ph,"up") -- shouldn't this be py_pd + add(rightshape,rw - delta,py_ph,"down") -- shouldn't this be py_pd extending = false end end @@ -206,11 +208,11 @@ local function shapes(r,rx,ry,rw,rh,rd,lytop,lybot,rytop,rybot,obeyhang) -- we can have a simple variant when no paragraphs if extending then -- not ok - leftshape[#leftshape][2] = rd - rightshape[#rightshape][2] = rw + leftshape [#leftshape] [2] = rd + rightshape[#rightshape][2] = rd else - add(leftshape,rx,rd,"up") - add(rightshape,rw,rd,"down") + add(leftshape, rx + delta,rd,"up") + add(rightshape,rw - delta,rd,"down") end return clip(leftshape,lytop,lybot), clip(rightshape,rytop,rybot) end @@ -242,6 +244,14 @@ local function singlepart(b,e,r,left,right,obeyhang) -- (at least visually) injected then it's best to stress the issue. ex = rw end +-- if b.r2l then +-- print("BEGIN r2l") +-- bx = b.w - bx +-- end +-- if e.r2l then +-- print("END r2l") +-- ex = e.w - ex +-- end local area if by == ey then area = { @@ -252,7 +262,7 @@ local function singlepart(b,e,r,left,right,obeyhang) } else area = { } - local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,ed,bh,eh,obeyhang) + local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,ed,bh,eh,obeyhang,b.r2l) add(area,bx,bh-ry) for i=1,#rightshapes do local ri = rightshapes[i] @@ -292,7 +302,7 @@ local function firstpart(b,r,left,right,obeyhang) local bh = by + b.h local bd = by - b.d local area = { } - local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,rd,bh,rd,obeyhang) + local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,rd,bh,rd,obeyhang,b.r2l) add(area,bx,bh-ry) for i=1,#rightshapes do local ri = rightshapes[i] @@ -317,7 +327,8 @@ local function firstpart(b,r,left,right,obeyhang) end local function middlepart(r,left,right,obeyhang) - local rx, ry = r.x, r.y + local rx = r.x + local ry = r.y local rw = rx + r.w local rh = ry + r.h local rd = ry - r.d @@ -361,7 +372,7 @@ local function lastpart(e,r,left,right,obeyhang) local ed = ey - e.d local area = { } -- two cases: till end and halfway e line - local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,rh,ed,rh,eh,obeyhang) + local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,rh,ed,rh,eh,obeyhang,e.r2l) for i=1,#rightshapes do local ri = rightshapes[i] add(area,ri[1],ri[2]-ry) diff --git a/tex/context/base/mkiv/anch-pos.lua b/tex/context/base/mkiv/anch-pos.lua index 2cb2e70ee..7d814677a 100644 --- a/tex/context/base/mkiv/anch-pos.lua +++ b/tex/context/base/mkiv/anch-pos.lua @@ -84,20 +84,21 @@ _plib_ = jobpositions -- might go local default = { -- not r and paragraphs etc __index = { - x = 0, -- x position baseline - y = 0, -- y position baseline - w = 0, -- width - h = 0, -- height - d = 0, -- depth - p = 0, -- page - n = 0, -- paragraph - ls = 0, -- leftskip - rs = 0, -- rightskip - hi = 0, -- hangindent - ha = 0, -- hangafter - hs = 0, -- hsize - pi = 0, -- parindent - ps = false, -- parshape + x = 0, -- x position baseline + y = 0, -- y position baseline + w = 0, -- width + h = 0, -- height + d = 0, -- depth + p = 0, -- page + n = 0, -- paragraph + ls = 0, -- leftskip + rs = 0, -- rightskip + hi = 0, -- hangindent + ha = 0, -- hangafter + hs = 0, -- hsize + pi = 0, -- parindent + ps = false, -- parshape + dir = 0, } } @@ -209,20 +210,20 @@ local getpos = function() getpos = backends.codeinjections.getpos return getp local gethpos = function() gethpos = backends.codeinjections.gethpos return gethpos() end local getvpos = function() getvpos = backends.codeinjections.getvpos return getvpos() end -local function setdim(name,w,h,d,extra) -- will be used when we move to sp allover - local x, y = getpos() - tobesaved[name] = { - p = texgetcount("realpageno"), - x = x ~= 0 and x or nil, - y = y ~= 0 and y or nil, - w = w ~= 0 and w or nil, - h = h ~= 0 and h or nil, - d = d ~= 0 and d or nil, - e = extra ~= "" and extra or nil, - r = region, - c = column, - } -end +-- local function setdim(name,w,h,d,extra) -- not used +-- local x, y = getpos() +-- tobesaved[name] = { +-- p = texgetcount("realpageno"), +-- x = x ~= 0 and x or nil, +-- y = y ~= 0 and y or nil, +-- w = w ~= 0 and w or nil, +-- h = h ~= 0 and h or nil, +-- d = d ~= 0 and d or nil, +-- e = extra ~= "" and extra or nil, +-- r = region, +-- c = column, +-- } +-- end local function setall(name,p,x,y,w,h,d,extra) tobesaved[name] = { @@ -235,6 +236,7 @@ local function setall(name,p,x,y,w,h,d,extra) e = extra ~= "" and extra or nil, r = region, c = column, +r2l = texgetcount("inlinelefttoright") == 1 and true or nil, } end @@ -310,7 +312,7 @@ local function get(id,index) end end -jobpositions.setdim = setdim +------------.setdim = setdim jobpositions.setall = setall jobpositions.set = set jobpositions.get = get @@ -538,6 +540,7 @@ scanners.dosetposition = function() -- name x = true, y = true, n = nofparagraphs > 0 and nofparagraphs or nil, +r2l = texgetcount("inlinelefttoright") == 1 or nil, } -- context(new_latelua_node(f_enhance(name))) context(new_latelua_node(function() enhance(tobesaved[name]) end)) @@ -558,6 +561,7 @@ scanners.dosetpositionwhd = function() -- name w h d extra h = h ~= 0 and h or nil, d = d ~= 0 and d or nil, n = nofparagraphs > 0 and nofparagraphs or nil, +r2l = texgetcount("inlinelefttoright") == 1 or nil, } -- context(new_latelua_node(f_enhance(name))) context(new_latelua_node(function() enhance(tobesaved[name]) end)) @@ -579,6 +583,7 @@ scanners.dosetpositionbox = function() -- name box h = h ~= 0 and h or nil, d = d ~= 0 and d or nil, n = nofparagraphs > 0 and nofparagraphs or nil, +r2l = texgetcount("inlinelefttoright") == 1 or nil, } -- context(new_latelua_node(f_enhance(name))) context(new_latelua_node(function() enhance(tobesaved[name]) end)) @@ -600,6 +605,7 @@ scanners.dosetpositionplus = function() -- name w h d extra d = d ~= 0 and d or nil, n = nofparagraphs > 0 and nofparagraphs or nil, e = scanstring(), +r2l = texgetcount("inlinelefttoright") == 1 or nil, } -- context(new_latelua_node(f_enhance(name))) context(new_latelua_node(function() enhance(tobesaved[name]) end)) @@ -619,6 +625,7 @@ scanners.dosetpositionstrut = function() -- name h = h ~= 0 and h or nil, d = d ~= 0 and d or nil, n = nofparagraphs > 0 and nofparagraphs or nil, +r2l = texgetcount("inlinelefttoright") == 1 or nil, } -- context(new_latelua_node(f_enhance(name))) context(new_latelua_node(function() enhance(tobesaved[name]) end)) diff --git a/tex/context/base/mkiv/attr-col.lua b/tex/context/base/mkiv/attr-col.lua index 6b11333a7..4a32884cb 100644 --- a/tex/context/base/mkiv/attr-col.lua +++ b/tex/context/base/mkiv/attr-col.lua @@ -12,8 +12,7 @@ if not modules then modules = { } end modules ['attr-col'] = { -- list could as well refer to the tables (instead of numbers that -- index into another table) .. depends on what we need -local type = type -local format = string.format +local type, tonumber = type, tonumber local concat = table.concat local min, max, floor = math.min, math.max, math.floor @@ -26,6 +25,14 @@ local storage = storage local context = context local tex = tex +local variables = interfaces.variables +local v_yes = variables.yes +local v_no = variables.no + +local p_split_comma = lpeg.tsplitat(",") +local p_split_colon = lpeg.splitat(":") +local lpegmatch = lpeg.match + local allocate = utilities.storage.allocate local setmetatableindex = table.setmetatableindex @@ -145,10 +152,14 @@ end local function rgbtogray(r,g,b) if not r then return 0 - elseif colors.weightgray then + end + local w = colors.weightgray + if w == true then return .30*r + .59*g + .11*b - else + elseif not w then return r/3 + g/3 + b/3 + else + return w[1]*r + w[2]*g + w[3]*b end end @@ -156,17 +167,6 @@ local function cmyktogray(c,m,y,k) return rgbtogray(cmyktorgb(c,m,y,k)) end --- not critical so not needed: --- --- local function cmyktogray(c,m,y,k) --- local r, g, b = 1.0 - min(1.0,c+k), 1.0 - min(1.0,m+k), 1.0 - min(1.0,y+k) --- if colors.weightgray then --- return .30*r + .59*g + .11*b --- else --- return r/3 + g/3 + b/3 --- end --- end - -- http://en.wikipedia.org/wiki/HSI_color_space -- http://nl.wikipedia.org/wiki/HSV_(kleurruimte) @@ -264,9 +264,6 @@ end --~ return { 5, .5, .5, .5, .5, 0, 0, 0, .5, parent, f, d, p } --~ end -local p_split = lpeg.tsplitat(",") -local lpegmatch = lpeg.match - function colors.spot(parent,f,d,p) -- inspect(parent) inspect(f) inspect(d) inspect(p) if type(p) == "number" then @@ -283,8 +280,8 @@ function colors.spot(parent,f,d,p) end else -- todo, multitone (maybe p should be a table) - local ps = lpegmatch(p_split,p) - local ds = lpegmatch(p_split,d) + local ps = lpegmatch(p_split_comma,p) + local ds = lpegmatch(p_split_comma,d) local c, m, y, k = 0, 0, 0, 0 local done = false for i=1,#ps do @@ -364,10 +361,31 @@ function colors.filter(n) return concat(data[n],":",5) end +-- unweighted (flat) gray could be another model but a bit work as we need to check: +-- +-- attr-col colo-ini colo-run +-- grph-inc grph-wnd +-- lpdf-col lpdf-fmt lpdf-fld lpdf-grp +-- meta-pdf meta-pdh mlib-pps +-- +-- but as we never needed it we happily delay that. + function colors.setmodel(name,weightgray) - colors.model = name - colors.default = models[name] or 1 - colors.weightgray = weightgray ~= false + if weightgray == true or weightgray == v_yes then + weightgray = true + elseif weightgray == false or weightgray == v_no then + weightgray = false + else + local r, g, b = lpegmatch(p_split_colon,weightgray) + if r and g and b then + weightgray = { r, g, b } + else + weightgray = true + end + end + colors.model = name -- global, not useful that way + colors.default = models[name] or 1 -- global + colors.weightgray = weightgray -- global return colors.default end diff --git a/tex/context/base/mkiv/colo-ini.lua b/tex/context/base/mkiv/colo-ini.lua index a2e761eae..655176f7e 100644 --- a/tex/context/base/mkiv/colo-ini.lua +++ b/tex/context/base/mkiv/colo-ini.lua @@ -44,7 +44,7 @@ local texgettoks = tex.gettoks local a_color = attributes.private('color') local a_transparency = attributes.private('transparency') -local a_colorspace = attributes.private('colormodel') +local a_colormodel = attributes.private('colormodel') local register_color = colors.register local attributes_list = attributes.list @@ -610,74 +610,18 @@ local function mpcolor(model,ca,ta,default) end -- local function mpnamedcolor(name) --- return mpcolor(texgetattribute(a_colorspace),l_color[name] or l_color.black,l_transparency[name] or false) +-- return mpcolor(texgetattribute(a_colormodel),l_color[name] or l_color.black,l_transparency[name] or false) -- end local colornamespace = getnamespace("colornumber") local paletnamespace = getnamespace("colorpalet") --- local function mpnamedcolor(name) --- local prefix = texgettoks("t_colo_prefix") --- local cn --- if prefix ~= "" then --- local v = valid[prefix..name] --- if not v then --- local n = paletnamespace .. prefix .. name --- local p = valid[n] --- if p == true then --- cn = colornamespace .. n --- elseif p then --- cn = colornamespace .. p --- else --- cn = colornamespace .. name --- end --- elseif v == true then --- cn = colornamespace .. paletnamespace .. prefix .. name --- else --- cn = colornamespace .. v --- end --- elseif valid[name] then --- cn = colornamespace .. name --- else --- return mpcolor(texgetattribute(a_colorspace),l_color.black) --- end --- -- return mpcolor(texgetattribute(a_colorspace),l_color[name] or l_color.black) --- return mpcolor(texgetattribute(a_colorspace),texgetcount(cn),l_transparency[name]) --- end - --- local function mpnamedcolor(name) --- local colorspace = texgetattribute(a_colorspace) --- local prefix = texgettoks("t_colo_prefix") --- local cn --- if prefix ~= "" then --- local v = valid[prefix..name] --- if not v then --- local n = paletnamespace .. prefix .. name --- local p = valid[n] --- if p == true then --- cn = n --- elseif p then --- cn = p --- else --- cn = name --- end --- elseif v == true then --- cn = paletnamespace .. prefix .. name --- else --- cn = v --- end --- elseif valid[name] then --- cn = name --- else --- return mpcolor(colorspace,l_color.black) --- end --- cn = counts[cn] --- cn = cn and texgetcount(cn) or l_color[name] or l_color.black -- fall back to old method --- return mpcolor(colorspace,cn,l_transparency[name]) --- end +function colors.currentmodel() + return texgetattribute(a_colormodel) +end -local function mpnamedcolor(name) - local space = texgetattribute(a_colorspace) +local function namedcolorattributes(name) + local space = texgetattribute(a_colormodel) local prefix = texgettoks("t_colo_prefix") local color if prefix ~= "" then @@ -696,7 +640,7 @@ local function mpnamedcolor(name) elseif valid[name] then color = name else - return mpcolor(space,l_color.black) + return space, l_color.black end color = counts[color] if color then @@ -705,17 +649,19 @@ local function mpnamedcolor(name) color = l_color[name] -- fall back on old method end if color then - return mpcolor(space,color,l_transparency[name]) + return space, color, l_transparency[name] else - return mpcolor(space,l_color.black) + return space, l_color.black end end --- mp.NamedColor = function(str) --- mpprint(mpnamedcolor(str)) --- end +colors.namedcolorattributes = namedcolorattributes -- can be used local + +local function mpnamedcolor(name) + return mpcolor(namedcolorattributes(name)) +end -local function mpoptions(model,ca,ta,default) -- will move to mlib-col +local function mpoptions(model,ca,ta,default) -- will move to mlib-col .. not really needed return formatters["withcolor %s"](mpcolor(model,ca,ta,default)) end @@ -723,6 +669,13 @@ colors.mpcolor = mpcolor colors.mpnamedcolor = mpnamedcolor colors.mpoptions = mpoptions +-- elsewhere: +-- +-- mp.NamedColor = function(str) +-- mpprint(mpnamedcolor(str)) +-- end + + -- local function formatcolor(ca,separator) -- local cv = colorvalues[ca] -- if cv then @@ -1014,9 +967,9 @@ implement { implement { name = "setcolormodel", - arguments = { "string", "boolean" }, + arguments = { "string", "string" }, actions = function(model,weight) - texsetattribute(a_colorspace,setcolormodel(model,weight)) + texsetattribute(a_colormodel,setcolormodel(model,weight)) end } @@ -1144,7 +1097,7 @@ do if model and model ~= 0 then model = model else - model = forcedmodel(texgetattribute(a_colorspace)) + model = forcedmodel(texgetattribute(a_colormodel)) if model == 1 then model = cv[1] end diff --git a/tex/context/base/mkiv/colo-ini.mkiv b/tex/context/base/mkiv/colo-ini.mkiv index f85f74c3a..e984128d9 100644 --- a/tex/context/base/mkiv/colo-ini.mkiv +++ b/tex/context/base/mkiv/colo-ini.mkiv @@ -59,11 +59,12 @@ \newconditional\c_colo_rgb_supported \newconditional\c_colo_cmyk_supported \newconditional\c_colo_spot_supported % backend driven -\newconditional\c_colo_weight_gray \settrue\c_colo_weight_gray \newconditional\c_colo_convert_gray \settrue\c_colo_convert_gray \newconditional\c_colo_enabled \newconditional\c_colo_expanded +\let\m_colo_weight_gray\v!yes + \let\currentcolormodel \empty \let\currentcolorname \empty \let\currentcolorpalet \empty @@ -219,7 +220,6 @@ % \newtoks\everysetupcolors \let\v_colo_freeze_state\s!false -\let\v_colo_weight_state\s!false \setvalue{\??colorconversions\v!yes}% {\settrue \c_colo_convert_gray} @@ -233,16 +233,11 @@ % \doifelse{\directcolorsparameter\c!spot }\v!yes \settrue \setfalse\c_colo_spot_supported \doifelse{\directcolorsparameter\c!expansion}\v!yes \settrue \setfalse\c_colo_expanded - \doifelse{\directcolorsparameter\c!factor }\v!no \setfalse\settrue \c_colo_weight_gray \doifelse{\directcolorsparameter\c!rgb }\v!yes \settrue \setfalse\c_colo_rgb_supported \doifelse{\directcolorsparameter\c!cmyk }\v!yes \settrue \setfalse\c_colo_cmyk_supported \doifelse{\directcolorsparameter\c!state }\v!start\settrue \setfalse\c_colo_enabled % - \ifconditional\c_colo_weight_gray - \let\v_colo_weight_state\s!true - \else - \let\v_colo_weight_state\s!false - \fi + \edef\m_colo_weight_gray{\directcolorsparameter\c!factor}% % \ifconditional\c_colo_expanded \let\v_colo_freeze_state\s!true @@ -626,7 +621,7 @@ \def\colo_helpers_set_model#1% direct {\edef\currentcolormodel{#1}% - \clf_setcolormodel{\currentcolormodel}\v_colo_weight_state\relax} % sets attribute at lua end + \clf_setcolormodel{\currentcolormodel}{\m_colo_weight_gray}} % sets attribute at lua end \colo_helpers_set_model\s!all diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index c81429b13..7d7ae8d8c 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.07.01 16:28} +\newcontextversion{2016.07.05 13:02} %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 9264d48ae..d19702d21 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.07.01 16:28} +\edef\contextversion{2016.07.05 13:02} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/file-job.mkvi b/tex/context/base/mkiv/file-job.mkvi index 0958d8433..78ec0d9a4 100644 --- a/tex/context/base/mkiv/file-job.mkvi +++ b/tex/context/base/mkiv/file-job.mkvi @@ -315,6 +315,9 @@ \def\documentvariable#name% {\getvariable\s!document{#name}} +\unexpanded\def\unexpandeddocumentvariable#name% + {\getvariable\s!document{#name}} + \unexpanded\def\setupdocument[#settings]% {\setvariables[\s!document][#settings]% \the\everysetupdocument\relax} diff --git a/tex/context/base/mkiv/font-sol.lua b/tex/context/base/mkiv/font-sol.lua index 858dc5e82..c1cac4fcf 100644 --- a/tex/context/base/mkiv/font-sol.lua +++ b/tex/context/base/mkiv/font-sol.lua @@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['font-sol'] = { -- this was: node license = "see context related readme files" } +-- We can speed this up. + -- This module is dedicated to the oriental tex project and for -- the moment is too experimental to be publicly supported. -- @@ -163,9 +165,10 @@ local dummy = { local function checksettings(r,settings) local s = r.settings - local method = settings_to_hash(settings.method or "") + local method = settings_to_array(settings.method or "") local optimize, preroll, splitwords - for k, v in next, method do + for i=1,#method do + local k = method[i] if k == v_preroll then preroll = true elseif k == v_split then @@ -232,6 +235,7 @@ local function convert(featuresets,name,list) fs = contextsetups[feature] fn = fs and fs.number end +-- inspect(fs) if fn then nofnumbers = nofnumbers + 1 numbers[nofnumbers] = fn @@ -619,7 +623,7 @@ first = tonut(first) local temp, b = repack_hlist(list,width,'exactly',listdir) if b > badness then if trace_optimize then - report_optimizers("line %a, badness before %a, after %a, criterium %a, verdict %a",line,badness,b,criterium,"quit") + report_optimizers("line %a, set %a, badness before %a, after %a, criterium %a, verdict %a",line,set or "?",badness,b,criterium,"quit") end -- remove last insert setlink(prev,h) @@ -632,11 +636,11 @@ first = tonut(first) free_nodelist(first) else if trace_optimize then - report_optimizers("line %a, badness before: %a, after %a, criterium %a, verdict %a",line,badness,b,criterium,"continue") + report_optimizers("line %a, set %a, badness before: %a, after %a, criterium %a, verdict %a",line,set or "?",badness,b,criterium,"continue") end -- free old h->t setnext(t) - free_nodelist(h) -- somhow fails + free_nodelist(h) -- somehow fails if not encapsulate then word[2] = first word[3] = last diff --git a/tex/context/base/mkiv/good-ini.lua b/tex/context/base/mkiv/good-ini.lua index 66f0e29d0..22ca12d28 100644 --- a/tex/context/base/mkiv/good-ini.lua +++ b/tex/context/base/mkiv/good-ini.lua @@ -10,6 +10,7 @@ if not modules then modules = { } end modules ['good-ini'] = { local type, next = type, next local gmatch = string.gmatch +local sortedhash, insert = table.sortedhash, table.insert local fonts = fonts @@ -42,6 +43,8 @@ fontgoodies.list = list -- no allocate as we want to see what is there fontgoodies.suffixes = { "lfg", "lua" } -- lfg is context specific and should not be used elsewhere +local contextsetups = fonts.specifiers.contextsetups + function fontgoodies.report(what,trace,goodies) if trace_goodies or trace then local whatever = goodies[what] @@ -80,11 +83,12 @@ local function loadgoodies(filename) -- maybe a merge is better report_goodies("goodie file %a is loaded",fullname) end goodies.name = goodies.name or "no name" - for name, fnc in next, list do + for i=1,#list do + local g = list[i] if trace_goodies then - report_goodies("handling goodie %a",name) + report_goodies("handling goodie %a",g[1]) end - fnc(goodies) + g[2](goodies) end goodies.initialized = true data[filename] = goodies @@ -93,8 +97,20 @@ local function loadgoodies(filename) -- maybe a merge is better return goodies end -function fontgoodies.register(name,fnc) -- will be a proper sequencer - list[name] = fnc +function fontgoodies.register(name,fnc,prepend) -- will be a proper sequencer + for i=1,#list do + local g = list[i] + if g[1] == name then + g[2] = fnc --overload + return + end + end + local g = { name, fnc } + if prepend then + insert(list,g,prepend == true and 1 or prepend) + else + insert(list,g) + end end fontgoodies.load = loadgoodies @@ -137,8 +153,20 @@ local function flattenedfeatures(t,tt) local tt = tt or { } for i=1,#t do local ti = t[i] - if type(ti) == "table" then + local ty = type(ti) + if ty == "table" then flattenedfeatures(ti,tt) + elseif ty == "string" then + local set = contextsetups[ti] + if set then + for k, v in next, set do + if k ~= "number" then + tt[k] = v or nil + end + end + else + -- bad + end elseif tt[ti] == nil then tt[ti] = true end @@ -214,9 +242,9 @@ function fontgoodies.registerpostprocessor(tfmdata,f,prepend) if not postprocessors then tfmdata.postprocessors = { f } elseif prepend then - table.insert(postprocessors,f,1) + insert(postprocessors,f,prepend == true and 1 or prepend) else - table.insert(postprocessors,f) + insert(postprocessors,f) end end @@ -259,15 +287,32 @@ local function setextrafeatures(tfmdata) local g = goodies[i] local f = g.features if f then - for feature, specification in next, f do - -- not needed but nicer: - specification.name = specification.name or feature - -- - addotffeature(tfmdata.shared.rawdata,feature,specification) - registerotffeature { - name = feature, - description = formatters["extra: %s"](feature) - } + local rawdata = tfmdata.shared.rawdata + local done = { } + -- indexed + for i=1,#f do + local specification = f[i] + local feature = specification.name + if feature then + addotffeature(rawdata,feature,specification) + registerotffeature { + name = feature, + description = formatters["extra: %s"](feature) + } + end + done[i] = true + end + -- hashed + for feature, specification in sortedhash(f) do + if not done[feature] then + feature = specification.name or feature + specification.name = feature + addotffeature(rawdata,feature,specification) + registerotffeature { + name = feature, + description = formatters["extra: %s"](feature) + } + end end end end diff --git a/tex/context/base/mkiv/grph-rul.lua b/tex/context/base/mkiv/grph-rul.lua index 556763812..f3d0bb95c 100644 --- a/tex/context/base/mkiv/grph-rul.lua +++ b/tex/context/base/mkiv/grph-rul.lua @@ -19,7 +19,7 @@ local getattribute = tex.getattribute local a_color = attributes.private('color') local a_transparency = attributes.private('transparency') -local a_colorspace = attributes.private('colormodel') +local a_colormodel = attributes.private('colormodel') local mpcolor = attributes.colors.mpcolor @@ -77,6 +77,8 @@ RuleOption := "%option%" ; RuleWidth := %width% ; RuleHeight := %height% ; RuleDepth := %depth% ; +RuleH := %h% ; +RuleV := %v% ; RuleThickness := %line% ; RuleFactor := %factor% ; RuleOffset := %offset% ; @@ -100,6 +102,8 @@ def RuleColor = %color% enddef ; color = mpcolor(p.ma,p.ca,p.ta), option = p.option or "", direction = p.direction or "TLT", + h = h * bpfactor, + v = v * bpfactor, } if not initialized then @@ -169,7 +173,7 @@ interfaces.implement { } } , actions = function(t) local r = userrule(t) - local ma = getattribute(a_colorspace) or 1 + local ma = getattribute(a_colormodel) or 1 local ca = getattribute(a_color) local ta = getattribute(a_transparency) if t.type == "mp" then @@ -177,7 +181,7 @@ interfaces.implement { t.ca = ca t.ta = ta else - r[a_colorspace] = ma + r[a_colormodel] = ma r[a_color] = ca r[a_transparency] = ta end @@ -201,7 +205,7 @@ interfaces.implement { depth = 0.25*factor, width = floor(random(t.min,t.max)/10000) * 10000, line = 0.10*factor, - ma = getattribute(a_colorspace) or 1, + ma = getattribute(a_colormodel) or 1, ca = getattribute(a_color), ta = getattribute(a_transparency), type = "mp", diff --git a/tex/context/base/mkiv/math-ali.mkiv b/tex/context/base/mkiv/math-ali.mkiv index 209d7a0fd..cd47b95c0 100644 --- a/tex/context/base/mkiv/math-ali.mkiv +++ b/tex/context/base/mkiv/math-ali.mkiv @@ -316,17 +316,21 @@ \dostarttagged\t!mathtablecell\empty} \def\math_left_of_equalign - {\ifcsname\??mathalignmentvariant\number\c_math_eqalign_column\endcsname - \ifcase\csname\??mathalignmentvariant\number\c_math_eqalign_column\endcsname\or - \relax \or \hfill \or \hfill - \fi + {\edef\p_location{\formulaparameter\c!location}% + \ifx\p_location\v!left + \box\b_strc_formulas_number + \fi + \ifcsname\??mathalignmentvariant\number\c_math_eqalign_column\endcsname + \ifcase\lastnamedcs \or \relax \or \hfill \or \hfill \fi \fi} \def\math_right_of_eqalign {\ifcsname\??mathalignmentvariant\number\c_math_eqalign_column\endcsname - \ifcase\csname\??mathalignmentvariant\number\c_math_eqalign_column\endcsname\or - \hfill \or \relax \or \hfill - \fi + \ifcase\lastnamedcs \or \hfill \or \relax \or \hfill \fi + \fi + \edef\p_location{\formulaparameter\c!location}% + \ifx\p_location\v!left\else + \box\b_strc_formulas_number \fi} \def\math_eqalign_set_column#1% we could just add to the preamble (as with other alignments) diff --git a/tex/context/base/mkiv/meta-pdf.lua b/tex/context/base/mkiv/meta-pdf.lua index 3cbff63b1..c17a2a4c7 100644 --- a/tex/context/base/mkiv/meta-pdf.lua +++ b/tex/context/base/mkiv/meta-pdf.lua @@ -541,13 +541,13 @@ end -- main converter -local a_colorspace = attributes.private('colormodel') +local a_colormodel = attributes.private('colormodel') function mptopdf.convertmpstopdf(name) resetall() local ok, m_data, n = resolvers.loadbinfile(name, 'tex') -- we need a binary load ! if ok then - mps.colormodel = texgetattribute(a_colorspace) + mps.colormodel = texgetattribute(a_colormodel) statistics.starttiming(mptopdf) mptopdf.nofconverted = mptopdf.nofconverted + 1 pdfcode(formatters["\\letterpercent\\space mptopdf begin: n=%s, file=%s"](mptopdf.nofconverted,file.basename(name))) diff --git a/tex/context/base/mkiv/mlib-pps.lua b/tex/context/base/mkiv/mlib-pps.lua index 42a2cf12a..74df758d1 100644 --- a/tex/context/base/mkiv/mlib-pps.lua +++ b/tex/context/base/mkiv/mlib-pps.lua @@ -61,6 +61,7 @@ local makempy = metapost.makempy local nooutercolor = "0 g 0 G" local nooutertransparency = "/Tr0 gs" -- only when set local outercolormode = 0 +local outercolormodel = 1 local outercolor = nooutercolor local outertransparency = nooutertransparency local innercolor = nooutercolor @@ -72,7 +73,8 @@ local pdftransparency = lpdf.transparency function metapost.setoutercolor(mode,colormodel,colorattribute,transparencyattribute) -- has always to be called before conversion -- todo: transparency (not in the mood now) - outercolormode = mode + outercolormode = mode + outercolormodel = colormodel if mode == 1 or mode == 3 then -- inherit from outer (registered color) outercolor = pdfcolor(colormodel,colorattribute) or nooutercolor @@ -446,6 +448,11 @@ function models.gray(cr) return checked_color_pair(f_gray,s,s) end +models[1] = models.all +models[2] = models.gray +models[3] = models.rgb +models[4] = models.cmyk + setmetatableindex(models, function(t,k) local v = models.gray t[k] = v @@ -453,7 +460,8 @@ setmetatableindex(models, function(t,k) end) local function colorconverter(cs) - return models[colors.model](cs) + -- return models[colors.model](cs) + return models[outercolormodel](cs) end local btex = P("btex") @@ -868,6 +876,9 @@ end function metapost.resetplugins(t) -- intialize plugins, before figure if top.plugmode then + + outercolormodel = colors.currentmodel() -- currently overloads the one set at the tex end + -- plugins can have been added resetter = resetteractions.runner analyzer = analyzeractions.runner diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index 07d6ce70b..ed0e672d4 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -100,7 +100,7 @@ return { "startcomponent", "stopcomponent", "component", "startproduct", "stopproduct", "product", "startproject", "stopproject", "project", - "starttext", "stoptext", "startnotext", "stopnotext","startdocument", "stopdocument", "documentvariable", "setupdocument", "presetdocument", + "starttext", "stoptext", "startnotext", "stopnotext","startdocument", "stopdocument", "documentvariable", "unexpandeddocumentvariable", "setupdocument", "presetdocument", "startmodule", "stopmodule", "usemodule", "usetexmodule", "useluamodule","setupmodule","currentmoduleparameter","moduleparameter", "everystarttext", "everystoptext", -- diff --git a/tex/context/base/mkiv/node-bck.lua b/tex/context/base/mkiv/node-bck.lua index 326987586..2ee08a80e 100644 --- a/tex/context/base/mkiv/node-bck.lua +++ b/tex/context/base/mkiv/node-bck.lua @@ -47,7 +47,7 @@ local new_glue = nodepool.glue local a_color = attributes.private('color') local a_transparency = attributes.private('transparency') -local a_colorspace = attributes.private('colormodel') +local a_colormodel = attributes.private('colormodel') local a_background = attributes.private('background') local a_alignbackground = attributes.private('alignbackground') @@ -70,7 +70,7 @@ local function add_backgrounds(head) -- rather old code .. to be redone if background then -- direct to hbox -- colorspace is already set so we can omit that and stick to color - local mode = getattr(current,a_colorspace) + local mode = getattr(current,a_colormodel) if mode then local height = getfield(current,"height") local depth = getfield(current,"depth") @@ -79,7 +79,7 @@ local function add_backgrounds(head) -- rather old code .. to be redone local rule = new_rule(width,height,depth) local color = getattr(current,a_color) local transparency = getattr(current,a_transparency) - setattr(rule,a_colorspace,mode) + setattr(rule,a_colormodel,mode) if color then setattr(rule,a_color,color) end @@ -132,13 +132,13 @@ local function add_alignbackgrounds(head) -- current has subtype 5 (cell) local width = getfield(current,"width") if width > 0 then - local mode = getattr(found,a_colorspace) + local mode = getattr(found,a_colormodel) if mode then local glue = new_glue(-width) local rule = new_rule(width,getfield(current,"height"),getfield(current,"depth")) local color = getattr(found,a_color) local transparency = getattr(found,a_transparency) - setattr(rule,a_colorspace,mode) + setattr(rule,a_colormodel,mode) if color then setattr(rule,a_color,color) end diff --git a/tex/context/base/mkiv/node-rul.lua b/tex/context/base/mkiv/node-rul.lua index 63d5da853..216dc0967 100644 --- a/tex/context/base/mkiv/node-rul.lua +++ b/tex/context/base/mkiv/node-rul.lua @@ -102,7 +102,7 @@ local a_ruled = attributes.private('ruled') local a_runningtext = attributes.private('runningtext') local a_color = attributes.private('color') local a_transparency = attributes.private('transparency') -local a_colorspace = attributes.private('colormodel') +local a_colormodel = attributes.private('colormodel') local insert_node_before = nuts.insert_before local insert_node_after = nuts.insert_after @@ -368,7 +368,7 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a local ma = d.ma local ca = d.ca local ta = d.ta - local colorspace = ma > 0 and ma or getattr(f,a_colorspace) or 1 + local colorspace = ma > 0 and ma or getattr(f,a_colormodel) or 1 local color = ca > 0 and ca or getattr(f,a_color) local transparency = ta > 0 and ta or getattr(f,a_transparency) local foreground = order == v_foreground @@ -436,7 +436,7 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a local dp = -(offset+(i-1)*dy)*e + rulethickness + m local r = new_rule(w,ht,dp) if color then - setattr(r,a_colorspace,colorspace) + setattr(r,a_colormodel,colorspace) setattr(r,a_color,color) end if transparency then diff --git a/tex/context/base/mkiv/spac-ali.mkiv b/tex/context/base/mkiv/spac-ali.mkiv index fef4c0f19..bfd4d5426 100644 --- a/tex/context/base/mkiv/spac-ali.mkiv +++ b/tex/context/base/mkiv/spac-ali.mkiv @@ -130,11 +130,11 @@ \unexpanded\def\spac_directions_lefttoright_hmode {\ifconditional\c_spac_auto_line_dir \ifzeropt\lastskip - \linedir TLT\relax + \textdir TLT\relax \else \scratchskip\lastskip \unskip - \linedir TLT\relax + \textdir TLT\relax \hskip\scratchskip \fi \else @@ -145,11 +145,11 @@ \unexpanded\def\spac_directions_righttoleft_hmode {\ifconditional\c_spac_auto_line_dir \ifzeropt\lastskip - \linedir TRT\relax + \textdir TRT\relax \else \scratchskip\lastskip \unskip - \linedir TRT\relax + \textdir TRT\relax \hskip\scratchskip \fi \else diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 75e1b5aff..c0cf6d6ee 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 0526d8fe5..9e254b013 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/strc-mat.mkiv b/tex/context/base/mkiv/strc-mat.mkiv index 272b5d9b5..8bf04e511 100644 --- a/tex/context/base/mkiv/strc-mat.mkiv +++ b/tex/context/base/mkiv/strc-mat.mkiv @@ -462,7 +462,7 @@ \strc_formulas_handle_sub_numbering \fi \fi - \strc_formulas_reference_trace + \strc_formulas_reference_trace \egroup \fi} @@ -1035,7 +1035,8 @@ \unexpanded\def\strc_formulas_number_again[#1]% {\def\currentformulareference{#1}% - \strc_formulas_number_indeed} + %\glet\strc_formulas_place_number\relax + \strc_formulas_place_number_in_box} \unexpanded\def\placeformula {\global\settrue\c_strc_formulas_inside_place @@ -1135,16 +1136,19 @@ \ifcase\c_strc_formulas_nested_number_mode % nothing \or - \strc_formulas_number % hm, looks ahead for [] + \expandafter\strc_formulas_number % hm, looks ahead for [] \or % nothing \or - \strc_formulas_number % hm, looks ahead for [] + \expandafter\strc_formulas_number % hm, looks ahead for [] \fi} \def\strc_formulas_place_number_indeed + {\glet\strc_formulas_place_number\relax + \strc_formulas_place_number_in_box} + +\def\strc_formulas_place_number_in_box {\dostarttagged\t!formulacaption\empty - \glet\strc_formulas_place_number\relax \global\setbox\b_strc_formulas_number\hbox{\strc_formulas_number_indeed}% \dostoptagged} diff --git a/tex/context/base/mkiv/typo-drp.lua b/tex/context/base/mkiv/typo-drp.lua index fa3081485..f31bb6a4e 100644 --- a/tex/context/base/mkiv/typo-drp.lua +++ b/tex/context/base/mkiv/typo-drp.lua @@ -79,7 +79,7 @@ initials.actions = actions local a_initial = attributes.private("initial") local a_color = attributes.private('color') local a_transparency = attributes.private('transparency') -local a_colorspace = attributes.private('colormodel') +local a_colormodel = attributes.private('colormodel') local category = characters.category @@ -267,7 +267,7 @@ actions[v_default] = function(head,setting) -- can be a helper if ca and ca > 0 then - setattr(current,a_colorspace,ma == 0 and 1 or ma) + setattr(current,a_colormodel,ma == 0 and 1 or ma) setattr(current,a_color,ca) end if ta and ta > 0 then diff --git a/tex/context/base/mkiv/typo-fln.lua b/tex/context/base/mkiv/typo-fln.lua index c45836437..711d095bb 100644 --- a/tex/context/base/mkiv/typo-fln.lua +++ b/tex/context/base/mkiv/typo-fln.lua @@ -70,7 +70,7 @@ firstlines.actions = actions local a_firstline = attributes.private('firstline') local a_color = attributes.private('color') local a_transparency = attributes.private('transparency') -local a_colorspace = attributes.private('colormodel') +local a_colormodel = attributes.private('colormodel') local texsetattribute = tex.setattribute local unsetvalue = attributes.unsetvalue @@ -209,7 +209,7 @@ actions[v_line] = function(head,setting) end setfield(start,"font",font) if ca and ca > 0 then - setattr(start,a_colorspace,ma == 0 and 1 or ma) + setattr(start,a_colormodel,ma == 0 and 1 or ma) setattr(start,a_color,ca) end if ta and ta > 0 then @@ -302,7 +302,7 @@ actions[v_word] = function(head,setting) ok = true end if ca and ca > 0 then - setattr(start,a_colorspace,ma == 0 and 1 or ma) + setattr(start,a_colormodel,ma == 0 and 1 or ma) setattr(start,a_color,ca) end if ta and ta > 0 then diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex f6fe251b0..43e672cda 100644 --- a/tex/context/interface/mkiv/i-context.pdf +++ b/tex/context/interface/mkiv/i-context.pdf diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex 437fc541c..754c377b4 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 59e985d64..48b828e01 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 : 07/01/16 16:28:20 +-- merge date : 07/05/16 13:02:59 do -- begin closure to overcome local limits and interference |