diff options
Diffstat (limited to 'tex')
23 files changed, 358 insertions, 133 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 08e2176a8..bcfd567ac 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2019.10.05 14:45} +\newcontextversion{2019.10.08 19:15} %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/mkii/context.mkii b/tex/context/base/mkii/context.mkii index e1b15ce6a..cf799ddf2 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2019.10.05 14:45} +\edef\contextversion{2019.10.08 19:15} %D For those who want to use this: diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 07821ba93..eab60bbf9 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2019.10.05 14:45} +\newcontextversion{2019.10.08 19:15} %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 ae52ed885..035353db2 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2019.10.05 14:45} +\edef\contextversion{2019.10.08 19:15} \edef\contextkind {beta} %D Kind of special: diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkiv/context.mkxl index 538735850..1867e3df4 100644 --- a/tex/context/base/mkiv/context.mkxl +++ b/tex/context/base/mkiv/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2019.10.05 14:45} +\edef\contextversion{2019.10.08 19:15} \edef\contextkind {beta} %D Kind of special: diff --git a/tex/context/base/mkiv/file-lib.lua b/tex/context/base/mkiv/file-lib.lua index 62cf938ba..8ef1a48d3 100644 --- a/tex/context/base/mkiv/file-lib.lua +++ b/tex/context/base/mkiv/file-lib.lua @@ -61,13 +61,18 @@ function resolvers.uselibrary(specification) -- todo: reporter if not foundname then -- pattern based search for i=1,#patterns do - local wanted = format(patterns[i],barename) - foundname = found(wanted) - if trace_libraries then - report_library("checking %a as %a: %s",filename,wanted,foundname or "not found") - end - if foundname then - break + local pattern = patterns[i] + if pattern and pattern ~= "" then + local wanted = format(pattern,barename) + foundname = found(wanted) + if trace_libraries then + report_library("checking %a as %a: %s",filename,wanted,foundname or "not found") + end + if foundname then + break + end + else + -- can be a bogus path (coming from a test) end end end diff --git a/tex/context/base/mkiv/font-ogr.lua b/tex/context/base/mkiv/font-ogr.lua index 5d45c3c5b..5fc946f42 100644 --- a/tex/context/base/mkiv/font-ogr.lua +++ b/tex/context/base/mkiv/font-ogr.lua @@ -17,6 +17,7 @@ end local tostring, tonumber, next, type = tostring, tonumber, next, type local round, max, mod, div = math.round, math.max, math.mod, math.div +local find = string.find local concat, setmetatableindex, sortedhash = table.concat, table.setmetatableindex, table.sortedhash local utfbyte = utf.byte local formatters = string.formatters @@ -96,13 +97,7 @@ do if shape then if idx >= 255 then idx = 1 - colrshapes = { -- or use metatable - filename = shapes.filename, - fixdepth = shapes.fixdepth, - units = shapes.units, - usecolor = shapes.usecolor, - -- instance = shapes.instance, - } + colrshapes = setmetatableindex({ },shapes) slot, droppedin, tfmdrop = dropins.provide(method,tfmdata,colrshapes) dropchars = tfmdrop.characters dropdescs = tfmdrop.descriptions @@ -143,13 +138,7 @@ do if shape then if idx >= 255 then idx = 1 - colrshapes = { -- or use metatable - filename = shapes.filename, - fixdepth = shapes.fixdepth, - units = shapes.units, - usecolor = shapes.usecolor, - -- instance = shapes.instance, - } + colrshapes = setmetatableindex({ },shapes) slot, droppedin, tfmdrop = dropins.provide(method,tfmdata,colrshapes) dropchars = tfmdrop.characters dropdescs = tfmdrop.descriptions @@ -225,20 +214,46 @@ do shapes[category].glyphs[unicode] = parameters end + -- local function hascolorspec(t) + -- if (t.color or "") ~= "" then + -- return true + -- elseif (t.fillcolor or "") ~= "" then + -- return true + -- elseif (t.drawcolor or "") ~= "" then + -- return true + -- elseif (t.linecolor or "") ~= "" then + -- return true + -- else + -- return false + -- end + -- end + + local function hascolorspec(t) + for k, v in next, t do + if find(k,"color") then + return true + end + end + return false + end + local function initializemps(tfmdata,kind,value) if value then - local spec = settings_to_hash_strict(value) - if not spec or not next(spec) then - spec = { category = value } + local specification = settings_to_hash_strict(value) + if not specification or not next(specification) then + specification = { category = value } end -- todo: multiple categories but then mayb also different - -- clones because of the units .. fot now we assume the same + -- clones because of the units .. for now we assume the same -- units - local category = spec.category + local category = specification.category if category and category ~= "" then local categories = settings_to_array(category) local usedshapes = nil local index = 0 + local spread = tonumber(specification.spread or 0) + local hascolor = hascolorspec(specification) + specification.spread = spread -- now a number for i=1,#categories do local category = categories[i] local mpsshapes = shapes[category] @@ -252,23 +267,37 @@ do local defaultwidth = mpsparameters.width or 0 local defaultheight = mpsparameters.height or 0 local defaultdepth = mpsparameters.depth or 0 - local defaultcode = mpsparameters.code or "" + local usecolor = mpsparameters.usecolor + local spread = spread * units + local defaultcode = mpsparameters.code or "" local scale = parameters.size / units + if hascolor then + -- the graphic has color + usecolor = false + else + -- do whatever is specified + end usedshapes = usedshapes or { - instance = "simplefun", - units = units, - usecolor = mpsparameters.usecolor, + instance = "simplefun", + units = units, + usecolor = usecolor, + specification = specification, + shapes = mpsshapes, } -- todo: deal with extensibles and more properties for unicode, shape in sortedhash(mpsshapes.glyphs) do -- local oldc = characters[unicode] -- if oldc then - index = index + 1 + index = index + 1 -- todo: somehow we end up with 2 as first entry after 0 + local wd = shape.width or defaultwidth + local ht = shape.height or defaultheight + local dp = shape.depth or defaultdepth local newc = { - index = index, -- into usedshapes - width = scale * (shape.width or defaultwidth), - height = scale * (shape.height or defaultheight), - depth = scale * (shape.depth or defaultdepth), + index = index, -- into usedshapes + width = scale * (wd + spread), + height = scale * ht, + depth = scale * dp, + unicode = unicode, } -- characters [unicode] = newc diff --git a/tex/context/base/mkiv/lpdf-emb.lua b/tex/context/base/mkiv/lpdf-emb.lua index 28ff6ceaf..bb6a421f2 100644 --- a/tex/context/base/mkiv/lpdf-emb.lua +++ b/tex/context/base/mkiv/lpdf-emb.lua @@ -105,7 +105,8 @@ do -- backend). In fact, we can now no longer pass the tounicodes to the frontend but -- pick them up from the descriptions. - local f_mapping = formatters["<%04X> <%s>"] + local f_mapping_2 = formatters["<%02X> <%s>"] + local f_mapping_4 = formatters["<%04X> <%s>"] local tounicode = fonts.mappings.tounicode @@ -130,7 +131,7 @@ local tounicode_template = [[ 2 def 1 begincodespacerange - <0000> <FFFF> + <%s> <%s> endcodespacerange %i beginbfchar %s @@ -142,10 +143,11 @@ end %%%%EndResource %%%%EOF]] - tounicodedictionary = function(details,indices,maxindex,name) + tounicodedictionary = function(details,indices,maxindex,name,wide) local mapping = { } local length = 0 if maxindex > 0 then + local f_mapping = wide and f_mapping_4 or f_mapping_2 for index=1,maxindex do local data = indices[index] if data then @@ -160,8 +162,10 @@ end end end end - local name = gsub(name,"%+","-") -- like luatex does - local blob = format(tounicode_template,name,name,name,name,name,length,concat(mapping,"\n")) + local name = gsub(name,"%+","-") -- like luatex does + local first = wide and "0000" or "00" + local last = wide and "FFFF" or "FF" + local blob = format(tounicode_template,name,name,name,name,name,first,last,length,concat(mapping,"\n")) return blob end @@ -834,7 +838,7 @@ do local basefont = pdfconstant(basefontname) local widths = widtharray(details,indices,maxindex,units) local object = details.objectnumber - local tounicode = tounicodedictionary(details,indices,maxindex,basefontname) + local tounicode = tounicodedictionary(details,indices,maxindex,basefontname,true) local tocidset = tocidsetdictionary(indices,minindex,maxindex) local metabbox = metadata.boundingbox or { 0, 0, 0, 0 } local fontbbox = pdfarray { unpack(metabbox) } @@ -1417,7 +1421,7 @@ do local basefont = pdfconstant(basefontname) local widths = widtharray(details,indices,maxindex,units * correction) local object = details.objectnumber - local tounicode = tounicodedictionary(details,indices,maxindex,basefontname) + local tounicode = tounicodedictionary(details,indices,maxindex,basefontname,true) local tocidset = tocidsetdictionary(indices,minindex,maxindex) local fontbbox = pdfarray { unpack(metabbox) } local ascender = metadata.ascender or 0 @@ -1536,7 +1540,9 @@ do local f_stream_d = formatters["%.6N 0 d0 1 0 0 1 0 %.3N cm %s"] -- A type 3 font has at most 256 characters and Acrobat also wants a zero slot - -- to be filled. We can share a mandate zero slot character. + -- to be filled. We can share a mandate zero slot character. We also need to + -- make sure that we use bytes as index in the page stream as well as in the + -- tounicode vector. local c_notdef = nil local r_notdef = nil @@ -1611,24 +1617,39 @@ do -- mps inclusion - local decompress = gzip.decompress + local decompress = gzip.decompress + local metapost = metapost + local simplemprun = metapost.simple + local setparameterset = metapost.setparameterset function methods.mps(filename,details) local properties = details.properties - local mpshapes = properties.indexdata[1] + local mpshapes = properties.indexdata[1] -- indexdata will change if mpshapes then - local scale = 10 * details.parameters.size/details.parameters.designsize - local units = mpshapes.units or details.parameters.units - local factor = units * bpfactor / scale - local fixdepth = mpshapes.fixdepth - local usecolor = mpshapes.usecolor - -- todo: each mp a table with properties (like using d0 / d1) + local scale = 10 * details.parameters.size/details.parameters.designsize + local units = mpshapes.units or details.parameters.units + local factor = units * bpfactor / scale + local fixdepth = mpshapes.fixdepth + local usecolor = mpshapes.usecolor + local specification = mpshapes.specification + local shapedefinitions = mpshapes.shapes + local instance = mpshapes.instance + -- + simplemprun(instance,"begingroup;",true,true) + setparameterset("mpsfont",specification) + if shapedefinitions then + local preamble = shapedefinitions.parameters.preamble + if preamble then + simplemprun(instance,preamble,true,true) + end + end + -- local function mpstopdf(mp,data) local width = data.width if decompress then mp = decompress(mp) end - local pdf = metapost.simple(mpshapes.instance,mp,true) -- can be sped up, minifun + local pdf = simplemprun(instance,mp,true) -- can be sped up, minifun local width = width * factor if usecolor then return f_stream_c(width,pdf), width @@ -1641,12 +1662,19 @@ do end return f_stream(width,pdf), width end + -- + local function resetmps() + setparameterset("mpsfont") + simplemprun(instance,"endgroup;",true,true) + end + -- local function getresources() return lpdf.collectedresources { serialize = false, } end - return mpshapes, 1/units, mpstopdf, false, getresources + -- + return mpshapes, 1/units, mpstopdf, resetmps, getresources end end @@ -1805,7 +1833,7 @@ do Type = pdfconstant("Encoding"), Differences = differences, } - local tounicode = tounicodedictionary(details,indices,maxindex,basefontname) + local tounicode = tounicodedictionary(details,indices,maxindex,basefontname,false) local resources = getresources and getresources() if not resources or not next(resources) then -- resources = lpdf.procset(true) diff --git a/tex/context/base/mkiv/lpdf-lmt.lua b/tex/context/base/mkiv/lpdf-lmt.lua index 8b40ee15c..b46274b34 100644 --- a/tex/context/base/mkiv/lpdf-lmt.lua +++ b/tex/context/base/mkiv/lpdf-lmt.lua @@ -499,21 +499,27 @@ local flushcharacter do cur_tmrx = tmrx end - local f_hex = formatters["%04X"] + local f_hex_4 = formatters["%04X"] + local f_hex_2 = formatters["%02X"] - local h_hex = setmetatableindex(function(t,k) -- we already have this somewhere + local h_hex_4 = setmetatableindex(function(t,k) -- we already have this somewhere if k < 256 then -- maybe 512 -- not sparse in this range for i=0,255 do - t[i] = f_hex(i) + t[i] = f_hex_4(i) end return t[k] else - local v = f_hex(k) + local v = f_hex_4(k) t[k] = v return v end end) + local h_hex_2 = setmetatableindex(function(t,k) -- we already have this somewhere + local v = k < 256 and f_hex_2(k) or "00" + t[k] = v + return v + end) flushcharacter = function(current,pos_h,pos_v,pos_r,font,char,data,naturalwidth,factor,width,f,e) if need_tf or font ~= f_cur or f_pdf ~= f_pdf_cur or fs ~= fs_cur or mode == "page" then @@ -566,8 +572,9 @@ local flushcharacter do cw = cw - tj_delta end end + if mode == "chararray" then - begin_charmode(font) + begin_charmode() end -- cw = cw + naturalwidth @@ -575,7 +582,7 @@ local flushcharacter do local index = data.index or char - b = b + 1 ; buffer[b] = h_hex[index] + b = b + 1 ; buffer[b] = font > 0 and h_hex_4[index] or h_hex_2[index] if not pdfcharacters[index] then pdfcharacters[index] = true diff --git a/tex/context/base/mkiv/mlib-ctx.lua b/tex/context/base/mkiv/mlib-ctx.lua index 88ef98f58..7641cc6e8 100644 --- a/tex/context/base/mkiv/mlib-ctx.lua +++ b/tex/context/base/mkiv/mlib-ctx.lua @@ -80,6 +80,7 @@ implement { } local patterns = { + CONTEXTLMTXMODE > 0 and "meta-imp-%s.mkxl" or "", "meta-imp-%s.mkiv", "meta-imp-%s.tex", -- obsolete: diff --git a/tex/context/base/mkiv/mlib-run.lua b/tex/context/base/mkiv/mlib-run.lua index e9d460472..cc4a77660 100644 --- a/tex/context/base/mkiv/mlib-run.lua +++ b/tex/context/base/mkiv/mlib-run.lua @@ -852,7 +852,7 @@ do end, } - function metapost.simple(instance,code,useextensions) + function metapost.simple(instance,code,useextensions,dontwrap) -- can we pickup the instance ? local mpx = metapost.pushformat { instance = instance or "simplefun", @@ -864,7 +864,7 @@ do flusher = flusher, askedfig = 1, useplugins = useextensions, - data = { "beginfig(1);", code, "endfig;" }, + data = dontwrap and { code } or { "beginfig(1);", code, "endfig;" }, incontext = false, } metapost.popformat() diff --git a/tex/context/base/mkiv/mlib-scn.lua b/tex/context/base/mkiv/mlib-scn.lua index 8867455b6..1ebe68bdc 100644 --- a/tex/context/base/mkiv/mlib-scn.lua +++ b/tex/context/base/mkiv/mlib-scn.lua @@ -702,6 +702,10 @@ function metapost.getparameterset(namespace) return namespace and namespaces[namespace] or namespaces end +function metapost.setparameterset(namespace,t) + namespaces[namespace] = t +end + -- goodies metapost.registerscript("definecolor", function() diff --git a/tex/context/base/mkiv/mult-aux.mkiv b/tex/context/base/mkiv/mult-aux.mkiv index 929943d7f..99d252c6b 100644 --- a/tex/context/base/mkiv/mult-aux.mkiv +++ b/tex/context/base/mkiv/mult-aux.mkiv @@ -180,22 +180,34 @@ % End of experimental code. -\unexpanded\def\mult_interfaces_let #1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} -\unexpanded\def\mult_interfaces_lete#1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty} -\unexpanded\def\mult_interfaces_def #1#2{\expandafter\def \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} -\unexpanded\def\mult_interfaces_edef#1#2{\expandafter\edef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} -\unexpanded\def\mult_interfaces_gdef#1#2{\expandafter\gdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} -\unexpanded\def\mult_interfaces_xdef#1#2{\expandafter\xdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} - -\startinterface english - +%D This can give wrong results when we pass e.g. \type{\c!format}, so either we need +%D to use the \type {\k!} ones, but these are not defined in the english interface +%D so from now on we assume that the low level ones are used with the symbolic names +%D and that only the high level setup commands are used with language specific +%D interfaces. + +% \unexpanded\def\mult_interfaces_let #1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} +% \unexpanded\def\mult_interfaces_lete#1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty} +% \unexpanded\def\mult_interfaces_def #1#2{\expandafter\def \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} +% \unexpanded\def\mult_interfaces_edef#1#2{\expandafter\edef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} +% \unexpanded\def\mult_interfaces_gdef#1#2{\expandafter\gdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} +% \unexpanded\def\mult_interfaces_xdef#1#2{\expandafter\xdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} + +% \startinterface english \unexpanded\def\mult_interfaces_let #1#2{\expandafter \let\csname#1#2\endcsname} \unexpanded\def\mult_interfaces_lete#1#2{\expandafter \let\csname#1#2\endcsname\empty} \unexpanded\def\mult_interfaces_def #1#2{\expandafter \def\csname#1#2\endcsname} \unexpanded\def\mult_interfaces_edef#1#2{\expandafter\edef\csname#1#2\endcsname} \unexpanded\def\mult_interfaces_gdef#1#2{\expandafter\gdef\csname#1#2\endcsname} \unexpanded\def\mult_interfaces_xdef#1#2{\expandafter\xdef\csname#1#2\endcsname} +% \stopinterface + +%D Do, we only interface the assignment definition: + +\unexpanded\def\mult_interfaces_adef#1#2{\expandafter\def \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} +\startinterface english + \unexpanded\def\mult_interfaces_adef#1#2{\expandafter \def\csname#1#2\endcsname} \stopinterface % the commented detokenized variant that backtracks ... needs testing usage first @@ -279,23 +291,21 @@ % todo: inline the def/let -\unexpanded\def\mult_interfaces_install_parameter_set_handler#1#2#3#4#5#6% - {\ifx#2\relax\let#2\empty\fi - \unexpanded\def#3{\mult_interfaces_def {#1#2:}}% ##1 {##2} (braces are mandate) - \unexpanded\def#4{\mult_interfaces_edef{#1#2:}}% ##1 {##2} (braces are mandate) - \unexpanded\def#5{\mult_interfaces_let {#1#2:}}% ##1 ##2 - \unexpanded\def#6{\mult_interfaces_lete{#1#2:}}}% ##1 - -\startinterface english - +% \unexpanded\def\mult_interfaces_install_parameter_set_handler#1#2#3#4#5#6% +% {\ifx#2\relax\let#2\empty\fi +% \unexpanded\def#3{\mult_interfaces_def {#1#2:}}% ##1 {##2} (braces are mandate) +% \unexpanded\def#4{\mult_interfaces_edef{#1#2:}}% ##1 {##2} (braces are mandate) +% \unexpanded\def#5{\mult_interfaces_let {#1#2:}}% ##1 ##2 +% \unexpanded\def#6{\mult_interfaces_lete{#1#2:}}}% ##1 +% +% \startinterface english \unexpanded\def\mult_interfaces_install_parameter_set_handler#1#2#3#4#5#6% {\ifx#2\relax\let#2\empty\fi \unexpanded\def#3##1{\expandafter \def\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate) \unexpanded\def#4##1{\expandafter\edef\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate) \unexpanded\def#5##1{\expandafter \let\csname#1#2:##1\endcsname}% ##1 ##2 \unexpanded\def#6##1{\expandafter \let\csname#1#2:##1\endcsname\empty}}% ##1 - -\stopinterface +% \stopinterface \unexpanded\def\installparametersethandler#1#2% {\normalexpanded @@ -720,21 +730,19 @@ \expandafter\noexpand\csname setupcurrent#2\endcsname % no \every (we use 'current' for consistency) \expandafter\noexpand\csname everysetup#2\endcsname}} -\unexpanded\def\mult_interfaces_install_direct_parameter_set_handler#1#2#3#4#5% - {\unexpanded\def#2{\mult_interfaces_def #1}% - \unexpanded\def#3{\mult_interfaces_edef#1}% - \unexpanded\def#4{\mult_interfaces_let #1}% - \unexpanded\def#5{\mult_interfaces_let #1\empty}}% - -\startinterface english +% \unexpanded\def\mult_interfaces_install_direct_parameter_set_handler#1#2#3#4#5% +% {\unexpanded\def#2{\mult_interfaces_def #1}% +% \unexpanded\def#3{\mult_interfaces_edef#1}% +% \unexpanded\def#4{\mult_interfaces_let #1}% +% \unexpanded\def#5{\mult_interfaces_let #1\empty}}% +% \startinterface english \unexpanded\def\mult_interfaces_install_direct_parameter_set_handler#1#2#3#4#5% {\unexpanded\def#2##1{\expandafter \def\csname#1##1\endcsname}% \unexpanded\def#3##1{\expandafter\edef\csname#1##1\endcsname}% \unexpanded\def#4##1{\expandafter \let\csname#1##1\endcsname}% \unexpanded\def#5##1{\expandafter \let\csname#1##1\endcsname\empty}}% - -\stopinterface +% \stopinterface \unexpanded\def\installdirectparametersethandler#1#2% {\normalexpanded diff --git a/tex/context/base/mkiv/mult-aux.mkxl b/tex/context/base/mkiv/mult-aux.mkxl index efa44d4dc..3fed8c26e 100644 --- a/tex/context/base/mkiv/mult-aux.mkxl +++ b/tex/context/base/mkiv/mult-aux.mkxl @@ -118,7 +118,7 @@ \orelse\ifx#3\empty \expandafter\mult_interfaces_get_parameters_error \else - \expandafter\mult_interfaces_def + \expandafter\mult_interfaces_adef % assignment def \fi \m_mult_interfaces_namespace{#1}{#2}% \doubleexpandafter\mult_interfaces_get_parameters_item} @@ -160,22 +160,34 @@ % End of experimental code. -\unexpanded\def\mult_interfaces_let #1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} -\unexpanded\def\mult_interfaces_lete#1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty} -\unexpanded\def\mult_interfaces_def #1#2{\expandafter\def \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} -\unexpanded\def\mult_interfaces_edef#1#2{\expandafter\edef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} -\unexpanded\def\mult_interfaces_gdef#1#2{\expandafter\gdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} -\unexpanded\def\mult_interfaces_xdef#1#2{\expandafter\xdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} +%D This can give wrong results when we pass e.g. \type{\c!format}, so either we need +%D to use the \type {\k!} ones, but these are not defined in the english interface +%D so from now on we assume that the low level ones are used with the symbolic names +%D and that only the high level setup commands are used with language specific +%D interfaces. -\startinterface english +% \unexpanded\def\mult_interfaces_let #1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} +% \unexpanded\def\mult_interfaces_lete#1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty} +% \unexpanded\def\mult_interfaces_def #1#2{\expandafter\def \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} +% \unexpanded\def\mult_interfaces_edef#1#2{\expandafter\edef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} +% \unexpanded\def\mult_interfaces_gdef#1#2{\expandafter\gdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} +% \unexpanded\def\mult_interfaces_xdef#1#2{\expandafter\xdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} +% \startinterface english \unexpanded\def\mult_interfaces_let #1#2{\expandafter \let\csname#1#2\endcsname} \unexpanded\def\mult_interfaces_lete#1#2{\expandafter \let\csname#1#2\endcsname\empty} \unexpanded\def\mult_interfaces_def #1#2{\expandafter \def\csname#1#2\endcsname} \unexpanded\def\mult_interfaces_edef#1#2{\expandafter\edef\csname#1#2\endcsname} \unexpanded\def\mult_interfaces_gdef#1#2{\expandafter\gdef\csname#1#2\endcsname} \unexpanded\def\mult_interfaces_xdef#1#2{\expandafter\xdef\csname#1#2\endcsname} +% \stopinterface + +%D Do, we only interface the assignment definition: +\unexpanded\def\mult_interfaces_adef#1#2{\expandafter\def \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} + +\startinterface english + \unexpanded\def\mult_interfaces_adef#1#2{\expandafter \def\csname#1#2\endcsname} \stopinterface % the commented detokenized variant that backtracks ... needs testing usage first @@ -238,7 +250,6 @@ \def#5##1##2{\ifx##1\relax\else#4##1{##2}\fi}% \def#6{#1#2:}% \def#7##1{#1##1:}% -% \def#8{\ifx#2\empty\else\ifcsname#1#2:\s!parent\endcsname\else\expandafter\let\csname#1#2:\s!parent\endcsname#1\fi\fi}% \def#8{\ifx#2\empty\orelse\ifcsname#1#2:\s!parent\endcsname\else\expandafter\let\csname#1#2:\s!parent\endcsname#1\fi}% \unexpanded\def#9##1{\expandafter\edef\csname#1##1:\s!parent\endcsname{#1#2}}} @@ -260,23 +271,21 @@ % todo: inline the def/let -\unexpanded\def\mult_interfaces_install_parameter_set_handler#1#2#3#4#5#6% - {\ifx#2\relax\let#2\empty\fi - \unexpanded\def#3{\mult_interfaces_def {#1#2:}}% ##1 {##2} (braces are mandate) - \unexpanded\def#4{\mult_interfaces_edef{#1#2:}}% ##1 {##2} (braces are mandate) - \unexpanded\def#5{\mult_interfaces_let {#1#2:}}% ##1 ##2 - \unexpanded\def#6{\mult_interfaces_lete{#1#2:}}}% ##1 - -\startinterface english - +% \unexpanded\def\mult_interfaces_install_parameter_set_handler#1#2#3#4#5#6% +% {\ifx#2\relax\let#2\empty\fi +% \unexpanded\def#3{\mult_interfaces_def {#1#2:}}% ##1 {##2} (braces are mandate) +% \unexpanded\def#4{\mult_interfaces_edef{#1#2:}}% ##1 {##2} (braces are mandate) +% \unexpanded\def#5{\mult_interfaces_let {#1#2:}}% ##1 ##2 +% \unexpanded\def#6{\mult_interfaces_lete{#1#2:}}}% ##1 +% +% \startinterface english \unexpanded\def\mult_interfaces_install_parameter_set_handler#1#2#3#4#5#6% {\ifx#2\relax\let#2\empty\fi \unexpanded\def#3##1{\expandafter \def\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate) \unexpanded\def#4##1{\expandafter\edef\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate) \unexpanded\def#5##1{\expandafter \let\csname#1#2:##1\endcsname}% ##1 ##2 \unexpanded\def#6##1{\expandafter \let\csname#1#2:##1\endcsname\empty}}% ##1 - -\stopinterface +% \stopinterface \unexpanded\def\installparametersethandler#1#2% {\normalexpanded @@ -620,21 +629,19 @@ \expandafter\noexpand\csname setupcurrent#2\endcsname % no \every (we use 'current' for consistency) \expandafter\noexpand\csname everysetup#2\endcsname}} -\unexpanded\def\mult_interfaces_install_direct_parameter_set_handler#1#2#3#4#5% - {\unexpanded\def#2{\mult_interfaces_def #1}% - \unexpanded\def#3{\mult_interfaces_edef#1}% - \unexpanded\def#4{\mult_interfaces_let #1}% - \unexpanded\def#5{\mult_interfaces_let #1\empty}}% - -\startinterface english +% \unexpanded\def\mult_interfaces_install_direct_parameter_set_handler#1#2#3#4#5% +% {\unexpanded\def#2{\mult_interfaces_def #1}% +% \unexpanded\def#3{\mult_interfaces_edef#1}% +% \unexpanded\def#4{\mult_interfaces_let #1}% +% \unexpanded\def#5{\mult_interfaces_let #1\empty}}% +% \startinterface english \unexpanded\def\mult_interfaces_install_direct_parameter_set_handler#1#2#3#4#5% {\unexpanded\def#2##1{\expandafter \def\csname#1##1\endcsname}% \unexpanded\def#3##1{\expandafter\edef\csname#1##1\endcsname}% \unexpanded\def#4##1{\expandafter \let\csname#1##1\endcsname}% \unexpanded\def#5##1{\expandafter \let\csname#1##1\endcsname\empty}}% - -\stopinterface +% \stopinterface \unexpanded\def\installdirectparametersethandler#1#2% {\normalexpanded diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 0ee0bd0ce..ef92c2d37 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 215b37f01..236879972 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/supp-box.mkiv b/tex/context/base/mkiv/supp-box.mkiv index 6b6d3f790..d43459c63 100644 --- a/tex/context/base/mkiv/supp-box.mkiv +++ b/tex/context/base/mkiv/supp-box.mkiv @@ -569,7 +569,7 @@ \unexpanded\def\doifelsetext#1% {\begingroup - \setbox\scratchbox\hpack + \setbox\scratchbox\hbox % no \hpack because we can have fallbacks {\settrialtypesetting \ignorespaces#1\removeunwantedspaces}% \ifzeropt\wd\scratchbox @@ -582,7 +582,7 @@ \unexpanded\def\doiftext#1% {\begingroup - \setbox\scratchbox\hpack + \setbox\scratchbox\hbox % no \hpack because we can have fallbacks {\settrialtypesetting \ignorespaces#1\removeunwantedspaces}% \ifzeropt\wd\scratchbox diff --git a/tex/context/base/mkiv/supp-box.mkxl b/tex/context/base/mkiv/supp-box.mkxl index ed0c5f3a3..e6ab96e89 100644 --- a/tex/context/base/mkiv/supp-box.mkxl +++ b/tex/context/base/mkiv/supp-box.mkxl @@ -531,7 +531,7 @@ \unexpanded\def\doifelsetext#1% {\begingroup - \setbox\scratchbox\hpack + \setbox\scratchbox\hbox % no \hpack because we can have fallbacks {\settrialtypesetting \ignorespaces#1\removeunwantedspaces}% \ifzeropt\wd\scratchbox @@ -542,7 +542,7 @@ \unexpanded\def\doiftext#1% {\begingroup - \setbox\scratchbox\hpack + \setbox\scratchbox\hbox % no \hpack because we can have fallbacks {\settrialtypesetting \ignorespaces#1\removeunwantedspaces}% \ifzeropt\wd\scratchbox diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex d28f6d585..344bcbcc1 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 cb957009b..a5cd19671 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/context/modules/mkiv/m-catchword.mkiv b/tex/context/modules/mkiv/m-catchword.mkiv new file mode 100644 index 000000000..70d713e44 --- /dev/null +++ b/tex/context/modules/mkiv/m-catchword.mkiv @@ -0,0 +1,136 @@ +%D \module +%D [ file=m-catchword, +%D version=2019.08.09, +%D title=\CONTEXT\ Extra Modules, +%D subtitle=Catchwords, +%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. + +\startluacode + +-- If someone realy need it there probably is no need for speed, so we do +-- it quick and dirty. + +local nodecodes = nodes.nodecodes +local kerncodes = nodes.kerncodes + +local glyph_code = nodecodes.glyph +local disc_code = nodecodes.disc +local kern_code = nodecodes.kern +local hlist_code = nodecodes.hlist + +local fontkern_code = kerncodes.fontkern + +local function set_catchword(t) + local nextpage = tex.lists.contrib_head + if not nextpage then + return + end + local firstline = nil + for n in nodes.traverse_id(hlist_code,nextpage) do + firstline = n + break + end + if not firstline then + return + end + local list = firstline.list + if not list then + return + end + local first = nil + local last = nil + for n, id, subtype in nodes.traverse(list) do + if id == glyph_code or id == disc_code or (id == kern_code and subtype == fontkern_code) then + if not first then + first = n + end + last = n + elseif first then + break + end + end + if not first then + return + end + local page = tex.getbox(t.box) + local head = nodes.copy_list(first,last.next) + head = nodes.insert_before(head,head,nodes.pool.glue(1,1,1)) + local line = nodes.hpack(head,page.width,"exactly") + if CONTEXTLMTXMODE > 0 then + line.yoffset = -t.voffset + line.xoffset = t.hoffset + else + line.shift = t.hoffset + line = nodes.insert_before(line,line,nodes.pool.kern(t.voffset-line.height)) + line = nodes.vpack(line) + end + line.height = 0 + line.depth = 0 + node.insert_after(page.list,nodes.tail(page.list),line) + logs.report("catchword","appending %a on page %i",nodes.toutf(head),tex.getcount("realpageno")) +end + +interfaces.implement { + name = "set_catchword", + actions = set_catchword, + arguments = { + { + { "box", "integer" }, + { "hoffset", "dimension" }, + { "voffset", "dimension" }, + }, + }, +} + +\stopluacode + +\unprotect + +\installcorenamespace {catchword} + +\installsimplecommandhandler \??catchword {catchword} + +\setupcatchword + [\c!state=\v!stop, + \c!hoffset=\zeropoint, + \c!voffset=\lineheight] + +\def\page_check_catchword_yes#1% + {\clf_set_catchword + box #1 + hoffset \catchwordparameter\c!hoffset + voffset \catchwordparameter\c!voffset + \relax} + +\let\page_check_catchword_nop\gobbleoneargument + +\appendtoks + \doifelse{\catchwordparameter\c!state}\v!start + {\let\page_check_catchword\page_check_catchword_yes}% + {\let\page_check_catchword\page_check_catchword_nop}% +\to \everysetupcatchword + +\appendtoks + \page_check_catchword\b_page_postprocessor +\to \t_page_postprocessors_page + +\protect + +\continueifinputfile{m-catchword.mkiv} + +\setupcatchword + [state=start, + hoffset=.75em, + voffset=1cm] + +\starttext + + \dorecurse{100}{\input ward } + +\stoptext diff --git a/tex/context/modules/mkiv/x-setups-overview.mkiv b/tex/context/modules/mkiv/x-setups-overview.mkiv index f293c13b7..24ee63fe0 100644 --- a/tex/context/modules/mkiv/x-setups-overview.mkiv +++ b/tex/context/modules/mkiv/x-setups-overview.mkiv @@ -53,12 +53,12 @@ } -\startinterface dutch \definecolor[LocalColor][r=.75,g=.25,b=.25] \stopinterface \startinterface english \definecolor[LocalColor][r=.25,g=.75,b=.25] \stopinterface +\startinterface dutch \definecolor[LocalColor][r=.75,g=.25,b=.25] \stopinterface \startinterface german \definecolor[LocalColor][r=.25,g=.25,b=.75] \stopinterface \startinterface french \definecolor[LocalColor][r=.75,g=.75,b=.25] \stopinterface -\startinterface czech \definecolor[LocalColor][r=.75,g=.25,b=.75] \stopinterface \startinterface italian \definecolor[LocalColor][r=.25,g=.75,b=.75] \stopinterface +\startinterface czech \definecolor[LocalColor][r=.75,g=.25,b=.75] \stopinterface \startinterface romanian \definecolor[LocalColor][r=.5,g=.4,b=.3] \stopinterface % \definecolor[LocalColor][r=.5,g=.3,b=.4] % \definecolor[LocalColor][r=.4,g=.3,b=.5] @@ -258,7 +258,7 @@ \stopcolor \vfill \start - \switchtobodyfont[big,15pt] + \switchtobodyfont[15pt] \setuptabulate[before=,after=] \dontleavehmode \hfill \hbox \bgroup \starttabulate[|l|l|] diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index e9b99be70..c388eaca1 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 : 10/05/19 14:45:26 +-- merge date : 10/08/19 19:15:39 do -- begin closure to overcome local limits and interference |