diff options
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luamplib/luamplib.lua')
-rw-r--r-- | Master/texmf-dist/tex/luatex/luamplib/luamplib.lua | 57 |
1 files changed, 42 insertions, 15 deletions
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua index 98abf0866d1..2b7db37bbd0 100644 --- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua +++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua @@ -18,8 +18,8 @@ luamplib.lastlog = "" local err, warn, info, log = luatexbase.provides_module({ name = "luamplib", - version = "2.10.1", - date = "2015/03/26", + version = "2.11.0", + date = "2015/08/01", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", }) @@ -33,6 +33,13 @@ local stringgmatch = string.gmatch local stringexplode = string.explode local tableconcat = table.concat local texsprint = tex.sprint +local textprint = tex.tprint + +local texget = tex.get +local texset = tex.set +local texgettoks = tex.gettoks +local texsettoks = tex.settoks +local texgetbox = tex.getbox local mplib = require ('mplib') local kpse = require ('kpse') @@ -258,10 +265,16 @@ local randomseed = nil local mpkpse = kpse.new("luatex", "mpost") +local special_ftype = { + pfb = "type1 fonts", + enc = "enc files", +} + local function finder(name, mode, ftype) if mode == "w" then return name else + ftype = special_ftype[ftype] or ftype local file = mpkpse:find_file(name,ftype) if file then if not lfstouch or ftype ~= "mp" or noneedtoreplace[name] then @@ -436,7 +449,7 @@ local function pdf_stopfigure() end local function pdf_literalcode(fmt,...) -- table - texsprint(format("\\mplibtoPDF{%s}",format(fmt,...))) + textprint({"\\mplibtoPDF{"},{-2,format(fmt,...)},{"}"}) end luamplib.pdf_literalcode = pdf_literalcode @@ -608,7 +621,6 @@ def externalfigure primary filename = draw rawtextext("\includegraphics{"& filename &"}") enddef; def TEX = textext enddef; -def fontmapfile primary filename = enddef; def specialVerbatimTeX (text t) = special "MPlibVerbTeX="&t; enddef; def normalVerbatimTeX (text t) = special "PostMPlibVerbTeX="&t; enddef; let VerbatimTeX = specialVerbatimTeX; @@ -631,8 +643,8 @@ enddef; luamplib.textextlabelpreamble = textextlabelpreamble local function protecttextext(data) - local everymplib = tex.toks['everymplibtoks'] or '' - local everyendmplib = tex.toks['everyendmplibtoks'] or '' + local everymplib = texgettoks('everymplibtoks') or '' + local everyendmplib = texgettoks('everyendmplibtoks') or '' data = "\n" .. everymplib .."\n".. data .."\n".. everyendmplib data = stringgsub(data,"\r","\n") data = stringgsub(data, "\"[^\n]-\"", @@ -730,7 +742,7 @@ local function processwithTEXboxes (data) local prepreamble = format("TEXBOX_:=%i;\n",num) while true do num = num + 1 - local box = tex.box[num] + local box = texgetbox(num) if not box then break end prepreamble = format( "%sTEXBOX_wd_[%i]:=%f;\nTEXBOX_ht_[%i]:=%f;\nTEXBOX_dp_[%i]:=%f;\n", @@ -743,7 +755,7 @@ local function processwithTEXboxes (data) end luamplib.processwithTEXboxes = processwithTEXboxes -local pdfmode = tex.pdfoutput > 0 and true or false +local pdfmode = texget("pdfoutput") > 0 and true or false local function start_pdf_code() if pdfmode then @@ -816,6 +828,8 @@ local transparancy_modes = { [0] = "Normal", "Compatible", } +local pgf_loaded + local function update_tr_res(res,mode,opaq) local os = format("<</BM /%s/ca %.3f/CA %.3f/AIS false>>",mode,opaq,opaq) local on, new = update_pdfobjs(os) @@ -823,27 +837,40 @@ local function update_tr_res(res,mode,opaq) if pdfmode then res = format("%s/MPlibTr%i %i 0 R",res,on,on) else - texsprint(format("\\special{pdf:put @MPlibTr<</MPlibTr%i%s>>}",on,os)) + if pgf_loaded then + texsprint(format("\\csname pgf@sys@addpdfresource@extgs@plain\\endcsname{/MPlibTr%i%s}",on,os)) + else + texsprint(format("\\special{pdf:put @MPlibTr<</MPlibTr%i%s>>}",on,os)) + end end end return res,on end local function tr_pdf_pageresources(mode,opaq) + pgf_loaded = pgf_loaded or (newtoken and newtoken.create("pgfutil@everybye").cmdname == "assign_toks") local res, on_on, off_on = "", nil, nil res, off_on = update_tr_res(res, "Normal", 1) res, on_on = update_tr_res(res, mode, opaq) if pdfmode then if res ~= "" then - local tpr = tex.pdfpageresources -- respect luaotfload-colors - if not stringfind(tpr,"/ExtGState<<.*>>") then - tpr = tpr.."/ExtGState<<>>" + local tpr = texget("pdfpageresources") -- respect luaotfload-colors + local no_extgs = not stringfind(tpr,"/ExtGState<<.*>>") + local pgf_pdf_loaded = no_extgs and pgf_loaded + if pgf_pdf_loaded then + texsprint(format("\\csname pgf@sys@addpdfresource@extgs@plain\\endcsname{%s}",res)) + else + if no_extgs then + tpr = tpr.."/ExtGState<<>>" + end + tpr = stringgsub(tpr,"/ExtGState<<","%1"..res) + texset("global","pdfpageresources",tpr) end - tpr = stringgsub(tpr,"/ExtGState<<","%1"..res) - tex.set("global","pdfpageresources",tpr) end else - texsprint(format("\\special{pdf:put @resources<</ExtGState @MPlibTr>>}")) + if not pgf_loaded then + texsprint(format("\\special{pdf:put @resources<</ExtGState @MPlibTr>>}")) + end end return on_on, off_on end |