diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-08-20 14:47:44 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-08-20 14:47:44 +0200 |
commit | 65ed578259121f17a365b97956d19d67e0be8f60 (patch) | |
tree | 30926c067de8e1b9c1a7894d328d727d05a4bb01 /tex/context/base | |
parent | ed42bd4c79946716033bf5dbedbd54bbe81f49e8 (diff) | |
download | context-65ed578259121f17a365b97956d19d67e0be8f60.tar.gz |
2016-08-20 13:44:00
Diffstat (limited to 'tex/context/base')
-rw-r--r-- | tex/context/base/context-version.pdf | bin | 4254 -> 4259 bytes | |||
-rw-r--r-- | tex/context/base/mkiv/cont-new.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/context.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/font-ext.lua | 32 | ||||
-rw-r--r-- | tex/context/base/mkiv/font-osd.lua | 157 | ||||
-rw-r--r-- | tex/context/base/mkiv/meta-ini.mkiv | 6 | ||||
-rw-r--r-- | tex/context/base/mkiv/mlib-ctx.lua | 14 | ||||
-rw-r--r-- | tex/context/base/mkiv/mlib-pdf.lua | 9 | ||||
-rw-r--r-- | tex/context/base/mkiv/mlib-pps.lua | 53 | ||||
-rw-r--r-- | tex/context/base/mkiv/mlib-pps.mkiv | 13 | ||||
-rw-r--r-- | tex/context/base/mkiv/mlib-run.lua | 56 | ||||
-rw-r--r-- | tex/context/base/mkiv/mult-fun.lua | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/status-files.pdf | bin | 9243 -> 9126 bytes | |||
-rw-r--r-- | tex/context/base/mkiv/status-lua.pdf | bin | 368801 -> 368957 bytes |
14 files changed, 227 insertions, 119 deletions
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 69fc2e6c2..372d2f1cc 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index aaf7f7186..91d6a5598 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.08.19 00:30} +\newcontextversion{2016.08.20 13:39} %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 b49ed822b..8e4dcf8ea 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.08.19 00:30} +\edef\contextversion{2016.08.20 13:39} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/font-ext.lua b/tex/context/base/mkiv/font-ext.lua index cadce625c..2fc85c266 100644 --- a/tex/context/base/mkiv/font-ext.lua +++ b/tex/context/base/mkiv/font-ext.lua @@ -1084,3 +1084,35 @@ implement { end end } + +-- relatively new: + +do + + local extraprivates = { } + + function fonts.helpers.addextraprivate(name,f) + extraprivates[#extraprivates+1] = { name, f } + end + + local function addextraprivates(tfmdata) + for i=1,#extraprivates do + local e = extraprivates[i] + local c = e[2](tfmdata) + if c then + fonts.helpers.addprivate(tfmdata, e[1], c) + end + end + end + + fonts.constructors.newfeatures.otf.register { + name = "extraprivates", + description = "extra privates", + default = true, + manipulators = { + base = addextraprivates, + node = addextraprivates, + } + } + +end diff --git a/tex/context/base/mkiv/font-osd.lua b/tex/context/base/mkiv/font-osd.lua index 26af69187..8ddd9a272 100644 --- a/tex/context/base/mkiv/font-osd.lua +++ b/tex/context/base/mkiv/font-osd.lua @@ -613,13 +613,12 @@ local function initializedevanagi(tfmdata) local steps = sequence.steps local nofsteps = sequence.nofsteps local features = sequence.features - if features["rphf"] then - -- deva + local has_rphf = features.rphf + local has_blwf = features.blwf + if has_rphf and has_rphf.deva then devanagari.reph = true - elseif features["blwf"] then - -- deva + elseif has_blwf and has_blwf.deva then devanagari.vattu = true - -- dev2 for i=1,nofsteps do local step = steps[i] local coverage = step.coverage @@ -632,59 +631,72 @@ local function initializedevanagi(tfmdata) end end end - if valid[kind] then - for i=1,nofsteps do - local step = steps[i] - local coverage = step.coverage - if coverage then - local reph = false - if step.osdstep then - -- rphf acts on consonant + halant - for k, v in next, ra do - local r = coverage[k] - if r then - local h = false - for k, v in next, halant do - local h = r[k] - if h then - reph = h.ligature or false - break + for kind, spec in next, features do -- beware, this is + if spec.dev2 and valid[kind] then + for i=1,nofsteps do + local step = steps[i] + local coverage = step.coverage + if coverage then + local reph = false + if kind == "rphf" then + -- + -- KE: I don't understand the rationale behind osdstep. The original if + -- statement checked whether coverage is contextual chaining. + -- + -- HH: The osdstep signals that we deal with our own feature here, not + -- one in the font itself so it was just a safeguard against us overloading + -- something driven by the font. + -- + -- if step.osdstep then -- selective + if true then -- always + -- rphf acts on consonant + halant + for k, v in next, ra do + local r = coverage[k] + if r then + local h = false + for k, v in next, halant do + local h = r[k] + if h then + reph = h.ligature or false + break + end + end + if reph then + break + end end end - if reph then - break - end + else + -- rphf might be result of other handler/chainproc end end - else - -- rphf might be result of other handler/chainproc + seqsubset[#seqsubset+1] = { kind, coverage, reph } end - seqsubset[#seqsubset+1] = { kind, coverage, reph } end end - end - if kind == "pref" then - local sequence = dataset[3] -- was [5] - local steps = sequence.steps - local nofsteps = sequence.nofsteps - for i=1,nofsteps do - local step = steps[i] - local coverage = step.coverage - if coverage then - for k, v in next, halant do - local h = coverage[k] - if h then - local found = false - for k, v in next, h do - found = v and v.ligature + if kind == "pref" then + local sequence = dataset[3] -- was [5] + local steps = sequence.steps + local nofsteps = sequence.nofsteps + for i=1,nofsteps do + local step = steps[i] + local coverage = step.coverage + if coverage then + for k, v in next, halant do + local h = coverage[k] + if h then + local found = false + for k, v in next, h do + found = v and v.ligature + if found then + pre_base_reordering_consonants[k] = found + break + end + end if found then - pre_base_reordering_consonants[k] = found break end end - if found then - break - end end end end @@ -1132,6 +1144,8 @@ function handlers.devanagari_reorder_matras(head,start) -- no leak start = startnext break end + else + break end current = next end @@ -1171,12 +1185,12 @@ function handlers.devanagari_reorder_reph(head,start) local startfont = getfont(start) local startattr = getprop(start,a_syllabe) while current do - local char = ischar(current,font) + local char = ischar(current,startfont) if char and getprop(current,a_syllabe) == startattr then -- step 2 if halant[char] and not getprop(current,a_state) then local next = getnext(current) if next then - local nextchar = ischar(next,font) + local nextchar = ischar(next,startfont) if nextchar and zw_char[nextchar] and getprop(next,a_syllabe) == startattr then current = next next = getnext(current) @@ -1198,7 +1212,7 @@ function handlers.devanagari_reorder_reph(head,start) if not startnext then current = getnext(start) while current do - local char = ischar(current,font) + local char = ischar(current,startfont) if char and getprop(current,a_syllabe) == startattr then -- step 4 if getprop(current,a_state) == s_pstf then -- post-base startnext = getnext(start) @@ -1223,7 +1237,7 @@ function handlers.devanagari_reorder_reph(head,start) current = getnext(start) local c = nil while current do - local char = ischar(current,font) + local char = ischar(current,startfont) if char and getprop(current,a_syllabe) == startattr then -- step 5 if not c and mark_above_below_post[char] and reorder_class[char] ~= "after subscript" then c = current @@ -1250,7 +1264,7 @@ function handlers.devanagari_reorder_reph(head,start) current = start local next = getnext(current) while next do - local nextchar = ischar(next,font) + local nextchar = ischar(next,startfont) if nextchar and getprop(next,a_syllabe) == startattr then --step 6 current = next next = getnext(current) @@ -1263,7 +1277,7 @@ function handlers.devanagari_reorder_reph(head,start) head = remove_node(head,start) local next = getnext(current) setlink(start,next) - setlink(current,"next",start) + setlink(current,start) start = startnext end end @@ -1290,12 +1304,12 @@ function handlers.devanagari_reorder_pre_base_reordering_consonants(head,start) local startattr = getprop(start,a_syllabe) -- can be fast for loop + caching state while current do - local char = ischar(current,font) + local char = ischar(current,startfont) if char and getprop(current,a_syllabe) == startattr then local next = getnext(current) if halant[char] and not getprop(current,a_state) then if next then - local nextchar = ischar(next,font) + local nextchar = ischar(next,startfont) if nextchar and getprop(next,a_syllabe) == startattr then if nextchar == c_zwnj or nextchar == c_zwj then current = next @@ -1319,13 +1333,13 @@ function handlers.devanagari_reorder_pre_base_reordering_consonants(head,start) current = getnext(start) startattr = getprop(start,a_syllabe) while current do - local char = ischar(current,font) + local char = ischar(current,startfont) if char and getprop(current,a_syllabe) == startattr then if not consonant[char] and getprop(current,a_state) then -- main startnext = getnext(start) removenode(start,start) local prev = getprev(current) - setlink(start,prev) + setlink(prev,start) setlink(start,current) start = startnext break @@ -1426,21 +1440,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa local kind = subset[1] local lookupcache = subset[2] if kind == "rphf" then - for k, v in next, ra do - local r = lookupcache[k] - if r then - for k, v in next, halant do - local h = r[k] - if h then - reph = h.ligature or false - break - end - end - if reph then - break - end - end - end + reph = subset[3] local current = start local last = getnext(stop) while current ~= last do @@ -1473,7 +1473,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa if current ~= stop then local c = locl[current] or getchar(current) local found = lookupcache[c] - if found then + if found then -- pre-base: pref Halant + Consonant local next = getnext(current) local n = locl[next] or getchar(next) if found[n] then @@ -1718,7 +1718,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa local prev = getprev(current) if prev ~= target then local next = getnext(current) - setlink(next,prev) + setlink(prev,next) if current == stop then stop = prev end @@ -1752,7 +1752,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa stop = current end local prev = getprev(c) - setlink(next,prev) + setlink(prev,next) local nextnext = getnext(next) setnext(current,nextnext) local nextnextnext = getnext(nextnext) @@ -1766,6 +1766,9 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa end if getchar(base) == c_nbsp then + if base == stop then + stop = getprev(stop) + end nbspaces = nbspaces - 1 head = remove_node(head, base) flush_node(base) @@ -1815,7 +1818,7 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe elseif (vv == c_zwnj or vv == c_zwj) and halant[vvv] then local nnnn = getnext(nnn) if nnnn then - local vvvv = ischar(nnnn) + local vvvv = ischar(nnnn,font) if vvvv and consonant[vvvv] then c = nnnn end @@ -1838,7 +1841,7 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe local nn = getnext(n) if nn then local vv = ischar(nn,font) - if vv and zw_char[vv] then + if vv and zw_char[v] then n = nn v = vv nn = getnext(nn) diff --git a/tex/context/base/mkiv/meta-ini.mkiv b/tex/context/base/mkiv/meta-ini.mkiv index b07574573..22856ec40 100644 --- a/tex/context/base/mkiv/meta-ini.mkiv +++ b/tex/context/base/mkiv/meta-ini.mkiv @@ -1492,6 +1492,12 @@ \def\MPruntab#1#2{\clf_mpruntab{#1}#2\relax} \let\mpruntab\MPruntab % #2 is number \def\MPrunset#1#2{\clf_mprunset{#1}{#2}} \let\mprunset\MPrunset +\prependtoks \clf_mppushvariables \to \everybeforepagebody +\appendtoks \clf_mppopvariables \to \everyafterpagebody + +\let\MPpushvariables\clf_mppushvariables +\let\MPpopvariables \clf_mppopvariables + %D We also provide an outputless run: \unexpanded\def\startMPcalculation diff --git a/tex/context/base/mkiv/mlib-ctx.lua b/tex/context/base/mkiv/mlib-ctx.lua index 3fe7118b7..7b1584d7e 100644 --- a/tex/context/base/mkiv/mlib-ctx.lua +++ b/tex/context/base/mkiv/mlib-ctx.lua @@ -23,6 +23,8 @@ local mplib = mplib metapost = metapost or {} local metapost = metapost +local context = context + local setters = tokens.setters local setmacro = setters.macro local implement = interfaces.implement @@ -177,6 +179,7 @@ implement { implement { name = "mprunset", + arguments = { "string", "string" }, actions = function(name,connector) local value = metapost.variables[name] if value ~= nil then @@ -282,7 +285,6 @@ end function metapost.theclippath(...) local result = metapost.getclippath(...) if result then -- we could just print the table --- return concat(metapost.flushnormalpath(result),"\n") return concat(metapost.flushnormalpath(result)," ") else return "" @@ -353,6 +355,16 @@ function mptex.reset() end implement { + name = "mppushvariables", + actions = metapost.pushvariables, +} + +implement { + name = "mppopvariables", + actions = metapost.popvariables, +} + +implement { name = "mptexset", arguments = "string", actions = mptex.set diff --git a/tex/context/base/mkiv/mlib-pdf.lua b/tex/context/base/mkiv/mlib-pdf.lua index 5dbb308bc..5989b5b55 100644 --- a/tex/context/base/mkiv/mlib-pdf.lua +++ b/tex/context/base/mkiv/mlib-pdf.lua @@ -340,7 +340,7 @@ local variable = local pattern_lst = (variable * newline^0)^0 -metapost.variables = { } -- to be stacked +metapost.variables = { } -- currently across instances metapost.properties = { } -- to be stacked function metapost.untagvariable(str,variables) -- will be redone @@ -385,12 +385,6 @@ local function setproperties(figure) return properties end -local function setvariables(figure) - local variables = { } - metapost.variables = variables - return variables -end - local function nocomment() end metapost.comment = nocomment @@ -409,7 +403,6 @@ function metapost.flush(result,flusher,askedfig) local flushfigure = flusher.flushfigure local textfigure = flusher.textfigure local processspecial = flusher.processspecial or metapost.processspecial - local variables = setvariables(figure) -- also resets then in case of not found metapost.comment = flusher.comment or nocomment for index=1,#figures do local figure = figures[index] diff --git a/tex/context/base/mkiv/mlib-pps.lua b/tex/context/base/mkiv/mlib-pps.lua index 23091342f..0c0cc6637 100644 --- a/tex/context/base/mkiv/mlib-pps.lua +++ b/tex/context/base/mkiv/mlib-pps.lua @@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['mlib-pps'] = { local format, gmatch, match, split = string.format, string.gmatch, string.match, string.split local tonumber, type, unpack = tonumber, type, unpack -local round, sqrt = math.round, math.sqrt +local round, sqrt, min, max = math.round, math.sqrt, math.min, math.max local insert, remove, concat = table.insert, table.remove, table.concat local Cs, Cf, C, Cg, Ct, P, S, V, Carg = lpeg.Cs, lpeg.Cf, lpeg.C, lpeg.Cg, lpeg.Ct, lpeg.P, lpeg.S, lpeg.V, lpeg.Carg local lpegmatch, tsplitat, tsplitter = lpeg.match, lpeg.tsplitat, lpeg.tsplitter @@ -835,7 +835,15 @@ local function splitprescript(script) local hash = lpegmatch(scriptsplitter,script) for i=#hash,1,-1 do local h = hash[i] +if h == "reset" then + for k, v in next, hash do + if type(k) ~= "number" then + hash[k] = nil + end + end +else hash[h[1]] = h[2] +end end if trace_scripts then report_scripts(table.serialize(hash,"prescript")) @@ -1494,28 +1502,31 @@ local types = { local function gr_process(object,prescript,before,after) local gr_state = prescript.gr_state - if gr_state then - if gr_state == "start" then - local gr_type = utilities.parsers.settings_to_hash(prescript.gr_type) - before[#before+1] = function() - context.MPLIBstartgroup( - gr_type.isolated and 1 or 0, - gr_type.knockout and 1 or 0, - prescript.gr_llx, - prescript.gr_lly, - prescript.gr_urx, - prescript.gr_ury - ) - end - elseif gr_state == "stop" then - after[#after+1] = function() - context.MPLIBstopgroup() - end + if not gr_state then + return + elseif gr_state == "start" then + local gr_type = utilities.parsers.settings_to_set(prescript.gr_type) + local path = object.path + local p1, p2, p3, p4 = path[1], path[2], path[3], path[4] + local llx = min(p1.x_coord,p2.x_coord,p3.x_coord,p4.x_coord) + local lly = min(p1.y_coord,p2.y_coord,p3.y_coord,p4.y_coord) + local urx = max(p1.x_coord,p2.x_coord,p3.x_coord,p4.x_coord) + local ury = max(p1.y_coord,p2.y_coord,p3.y_coord,p4.y_coord) + before[#before+1] = function() + context.MPLIBstartgroup( + gr_type.isolated and 1 or 0, + gr_type.knockout and 1 or 0, + llx, lly, urx, ury + ) + end + elseif gr_state == "stop" then + after[#after+1] = function() + context.MPLIBstopgroup() end - object.path = false - object.color = false - object.grouped = true end + object.path = false + object.color = false + object.grouped = true end -- outlines diff --git a/tex/context/base/mkiv/mlib-pps.mkiv b/tex/context/base/mkiv/mlib-pps.mkiv index 3a3ab2623..a2eb44826 100644 --- a/tex/context/base/mkiv/mlib-pps.mkiv +++ b/tex/context/base/mkiv/mlib-pps.mkiv @@ -161,12 +161,19 @@ \wd\scratchbox \dimexpr#5\onebasepoint-#3\onebasepoint+2\onebasepoint\relax \ht\scratchbox #6\onebasepoint \dp\scratchbox-#4\onebasepoint + \setbox\scratchbox\hpack\bgroup + \kern-#3\onebasepoint + \box\scratchbox + \egroup \saveboxresource - attr {/Group << /S /Transparency /I \ifnum#1=1 true \else false \fi /K \ifnum#1=1 true \else false \fi >>} + attr {/Group << /S /Transparency /I \ifnum#1=1 true \else false \fi /K \ifnum#2=1 true \else false \fi >>} resources {\pdfbackendcurrentresources} \scratchbox - % \setbox\scratchbox\hbox\bgroup\kern-\onebasepoint\useboxresource\lastsavedboxresourceindex\egroup % why twice? - \setbox\scratchbox\hpack\bgroup\kern-\onebasepoint\useboxresource\lastsavedboxresourceindex\egroup + \setbox\scratchbox\hpack\bgroup + \kern#3\onebasepoint + \kern-\onebasepoint + \useboxresource\lastsavedboxresourceindex + \egroup \wd\scratchbox\zeropoint \ht\scratchbox\zeropoint \dp\scratchbox\zeropoint diff --git a/tex/context/base/mkiv/mlib-run.lua b/tex/context/base/mkiv/mlib-run.lua index 42fcdd26b..871889bbb 100644 --- a/tex/context/base/mkiv/mlib-run.lua +++ b/tex/context/base/mkiv/mlib-run.lua @@ -6,12 +6,12 @@ if not modules then modules = { } end modules ['mlib-run'] = { license = "see context related readme files", } ---~ cmyk -> done, native ---~ spot -> done, but needs reworking (simpler) ---~ multitone -> ---~ shade -> partly done, todo: cm ---~ figure -> done ---~ hyperlink -> low priority, easy +-- cmyk -> done, native +-- spot -> done, but needs reworking (simpler) +-- multitone -> +-- shade -> partly done, todo: cm +-- figure -> done +-- hyperlink -> low priority, easy -- new * run -- or @@ -31,7 +31,8 @@ nears zero.</p> local type, tostring, tonumber = type, tostring, tonumber local format, gsub, match, find = string.format, string.gsub, string.match, string.find -local concat = table.concat +local concat, insert, remove = table.concat, table.insert, table.remove + local emptystring = string.is_empty local P = lpeg.P @@ -324,6 +325,46 @@ if not metapost.initializescriptrunner then function metapost.initializescriptrunner() end end +do + + local stack, top = { }, nil + + function metapost.setvariable(k,v) + if top then + top[k] = v + else + metapost.variables[k] = v + end + end + + function metapost.pushvariable(k) + local t = { } + if top then + insert(stack,top) + top[k] = t + else + metapost.variables[k] = t + end + top = t + end + + function metapost.popvariable() + top = remove(stack) + end + + local stack = { } + + function metapost.pushvariables() + insert(stack,metapost.variables) + metapost.variables = { } + end + + function metapost.popvariables() + metapost.variables = remove(stack) or metapost.variables + end + +end + function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass, askedfig) local converted, result = false, { } if type(mpx) == "string" then @@ -332,6 +373,7 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass, if mpx and data then local tra = nil starttiming(metapost) + metapost.variables = { } metapost.initializescriptrunner(mpx,trialrun) if trace_graphics then tra = mp_tra[mpx] diff --git a/tex/context/base/mkiv/mult-fun.lua b/tex/context/base/mkiv/mult-fun.lua index 5996b9ac6..19abe1bcd 100644 --- a/tex/context/base/mkiv/mult-fun.lua +++ b/tex/context/base/mkiv/mult-fun.lua @@ -135,5 +135,7 @@ return { "addbackground", -- "shadedup", "shadeddown", "shadedleft", "shadedright", + -- + "sortlist", "copylist", "shapedlist", "listtocurves", "listtolines", "listsize", }, } diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex eec704b7f..860a4022a 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 390810d51..1579c2465 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf |