diff options
author | Norbert Preining <preining@logic.at> | 2019-02-24 15:12:57 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2019-02-24 15:12:57 +0000 |
commit | 1314fbe93790c501dc436a5cf99f106b9e5c0f63 (patch) | |
tree | 04dc7734c8be8ffe385d41f4388826ef5857b6f9 /Master/texmf-dist/tex/context/base/mkiv/meta-pdf.lua | |
parent | eb80ce7b34f59896a1dfee5ca422495394d6677f (diff) |
Revert "ConTeXt version 2019.02.22 19:35"
This reverts commit 5c6357cdb820b4f628d036ba7b2248f221d50c0b.
git-svn-id: svn://tug.org/texlive/trunk@50112 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/meta-pdf.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/meta-pdf.lua | 76 |
1 files changed, 29 insertions, 47 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-pdf.lua b/Master/texmf-dist/tex/context/base/mkiv/meta-pdf.lua index 5bcd161c02f..4a185cebd4d 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/meta-pdf.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/meta-pdf.lua @@ -6,9 +6,6 @@ if not modules then modules = { } end modules ['meta-pdf'] = { license = "see context related readme files" } --- This module is not used in practice but we keep it around for historic --- reasons. - -- Finally we used an optimized version. The test code can be found in -- meta-pdh.lua but since we no longer want to overload functione we use -- more locals now. This module keeps changing as it is also a testbed. @@ -38,24 +35,20 @@ local pdfgraycode = lpdf.graycode local pdfspotcode = lpdf.spotcode local pdftransparencycode = lpdf.transparencycode local pdffinishtransparencycode = lpdf.finishtransparencycode +----- pdfpageliteral = nodes.pool.pdfpageliteral metapost.mptopdf = metapost.mptopdf or { } local mptopdf = metapost.mptopdf mptopdf.nofconverted = 0 -local f_translate = formatters["1 0 0 0 1 %.6F %.6F cm"] -local f_concat = formatters["%.6F %.6F %.6F %.6F %.6F %.6F cm"] - -directives.register("pdf.stripzeros",function() - f_translate = formatters["1 0 0 0 1 %.6N %.6N cm"] - f_concat = formatters["%.6N %.6N %.6N %.6N %.6N %.6N cm"] -end) +local f_translate = formatters["1 0 0 0 1 %F %F cm"] -- no %s due to 1e-035 issues +local f_concat = formatters["%F %F %F %F %F %F cm"] -- no %s due to 1e-035 issues local m_path, m_stack, m_texts, m_version, m_date, m_shortcuts = { }, { }, { }, 0, 0, false local m_stack_close, m_stack_path, m_stack_concat = false, { }, nil -local extra_path_data, ignore_path = nil, false +local extra_path_code, ignore_path = nil, false local specials = { } local function resetpath() @@ -64,21 +57,28 @@ end local function resetall() m_path, m_stack, m_texts, m_version, m_shortcuts = { }, { }, { }, 0, false - extra_path_data, ignore_path = nil, false + extra_path_code, ignore_path = nil, false specials = { } resetpath() end resetall() +-- -- this does not work as expected (displacement of text) beware, needs another +-- -- comment hack +-- +-- local function pdfcode(str) +-- context(pdfpageliteral(str)) +-- end + local pdfcode = context.pdfliteral local function mpscode(str) if ignore_path then pdfcode("h W n") - if extra_path_data then - pdfcode(extra_path_data) - extra_path_data = nil + if extra_path_code then + pdfcode(extra_path_code) + extra_path_code = nil end ignore_path = false else @@ -99,28 +99,16 @@ local function flushpath(cmd) if #m_stack_path > 0 then local path = { } if m_stack_concat then - local sx = m_stack_concat[1] - local sy = m_stack_concat[4] - local rx = m_stack_concat[2] - local ry = m_stack_concat[3] - local tx = m_stack_concat[5] - local ty = m_stack_concat[6] + local sx, sy = m_stack_concat[1], m_stack_concat[4] + local rx, ry = m_stack_concat[2], m_stack_concat[3] + local tx, ty = m_stack_concat[5], m_stack_concat[6] local d = (sx*sy) - (rx*ry) for k=1,#m_stack_path do - local v = m_stack_path[k] - local px = v[1] - local py = v[2] - v[1] = (sy*(px-tx)-ry*(py-ty))/d - v[2] = (sx*(py-ty)-rx*(px-tx))/d + local v = m_stack_path[k] + local px, py = v[1], v[2] ; v[1], v[2] = (sy*(px-tx)-ry*(py-ty))/d, (sx*(py-ty)-rx*(px-tx))/d -- mpconcat(v[1],v[2]) if #v == 7 then - px = v[3] - py = v[4] - v[3] = (sy*(px-tx)-ry*(py-ty))/d - v[4] = (sx*(py-ty)-rx*(px-tx))/d - px = v[5] - py = v[6] - v[5] = (sy*(px-tx)-ry*(py-ty))/d - v[6] = (sx*(py-ty)-rx*(px-tx))/d + local px, py = v[3], v[4] ; v[3], v[4] = (sy*(px-tx)-ry*(py-ty))/d, (sx*(py-ty)-rx*(px-tx))/d -- mpconcat(v[3],v[4]) + local px, py = v[5], v[6] ; v[5], v[6] = (sy*(px-tx)-ry*(py-ty))/d, (sx*(py-ty)-rx*(px-tx))/d -- mpconcat(v[5],v[6]) end path[k] = concat(v," ") end @@ -173,8 +161,7 @@ function mps.lineto(x,y) end function mps.rlineto(x,y) - local dx = 0 - local dy = 0 + local dx, dy = 0, 0 local topofstack = #m_stack_path if topofstack > 0 then local msp = m_stack_path[topofstack] @@ -251,8 +238,7 @@ function mps.clip() end function mps.textext(font, scale, str) -- old parser - local dx = 0 - local dy = 0 + local dx, dy = 0, 0 if #m_stack_path > 0 then dx, dy = m_stack_path[1][1], m_stack_path[1][2] end @@ -293,7 +279,7 @@ local function linearshade(colorspace,domain,ca,cb,coordinates) nofshades = nofshades + 1 local name = formatters["MpsSh%s"](nofshades) lpdf.linearshade(name,domain,ca,cb,1,colorspace,coordinates) - extra_path_data, ignore_path = formatters["/%s sh Q"](name), true + extra_path_code, ignore_path = formatters["/%s sh Q"](name), true pdfcode("q /Pattern cs") end @@ -302,7 +288,7 @@ local function circularshade(colorspace,domain,ca,cb,coordinates) nofshades = nofshades + 1 local name = formatters["MpsSh%s"](nofshades) lpdf.circularshade(name,domain,ca,cb,1,colorspace,coordinates) - extra_path_data, ignore_path = formatters["/%s sh Q"](name), true + extra_path_code, ignore_path = formatters["/%s sh Q"](name), true pdfcode("q /Pattern cs") end @@ -347,12 +333,9 @@ handlers[50] = function() report_mptopdf("skipping special %s",50) end --end of not supported function mps.setrgbcolor(r,g,b) -- extra check - r = tonumber(r) -- needed when we use lpeg - g = tonumber(g) -- needed when we use lpeg - b = tonumber(b) -- needed when we use lpeg + r, g, b = tonumber(r), tonumber(g), tonumber(b) -- needed when we use lpeg if r == 0.0123 and g < 0.1 then - g = round(g*10000) - b = round(b*10000) + g, b = round(g*10000), round(b*10000) local s = specials[b] local h = round(s[#s]) local handler = handlers[h] @@ -362,8 +345,7 @@ function mps.setrgbcolor(r,g,b) -- extra check report_mptopdf("unknown special handler %s (1)",h) end elseif r == 0.123 and g < 0.1 then - g = round(g*1000) - b = round(b*1000) + g, b = round(g*1000), round(b*1000) local s = specials[b] local h = round(s[#s]) local handler = handlers[h] |