diff options
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luamplib/luamplib.lua')
-rw-r--r-- | Master/texmf-dist/tex/luatex/luamplib/luamplib.lua | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua index fa176c813b9..4dd1b5e946c 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.7.0", - date = "2014/04/25", + version = "2.8.0", + date = "2014/06/17", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", }) @@ -161,6 +161,7 @@ local noneedtoreplace = { ["mp-step.mpiv"] = true, ["mp-text.mpiv"] = true, ["mp-tool.mpiv"] = true, + ["mp-luas.mpiv"] = true, } luamplib.noneedtoreplace = noneedtoreplace @@ -633,6 +634,14 @@ local function protecttextext(data) str = stringgsub(str,"#", "!!!!!SHARPE!!!!!") return format("\\detokenize{%s}",str) end) + luamplib.mpxcolors = {} + data = stringgsub(data, "\\mpcolor%s*{(.-)}", + function(str) + local cnt = #luamplib.mpxcolors + 1 + luamplib.mpxcolors[cnt] = format( + "\\expandafter\\mplibcolor\\csname mpxcolor%i\\endcsname{%s}",cnt,str) + return format("\\csname mpxcolor%i\\endcsname",cnt) + end) texsprint(data) end @@ -870,6 +879,8 @@ local function color_normalize(ca,cb) end end +local prev_override_color + local function do_preobj_color(object,prescript) -- transparency local opaq = prescript and prescript.tr_transparency @@ -881,9 +892,26 @@ local function do_preobj_color(object,prescript) pdf_literalcode("/MPlibTr%i gs",tron_no) end -- color - local cs = object.color - if cs and #cs > 0 then - pdf_literalcode(luamplib.colorconverter(cs)) + local override = prescript and prescript.MPlibOverrideColor + if override then + if pdfmode then + pdf_literalcode(override) + override = nil + else + texsprint(format("\\special{color push %s}",override)) + prev_override_color = override + end + else + local cs = object.color + if cs and #cs > 0 then + pdf_literalcode(luamplib.colorconverter(cs)) + prev_override_color = nil + elseif not pdfmode then + override = prev_override_color + if override then + texsprint(format("\\special{color push %s}",override)) + end + end end -- shading local sh_type = prescript and prescript.sh_type @@ -914,7 +942,7 @@ local function do_preobj_color(object,prescript) if #colorb == 1 then colorspace = "DeviceGray" elseif #colorb == 3 then colorspace = "DeviceRGB" elseif #colorb == 4 then colorspace = "DeviceCMYK" - else return troff_no + else return troff_no,override end colora = tableconcat(colora, " ") colorb = tableconcat(colorb, " ") @@ -929,15 +957,18 @@ local function do_preobj_color(object,prescript) shade_no = sh_pdfpageresources(3,domain,colorspace,colora,colorb,coordinates) end pdf_literalcode("q /Pattern cs") - return troff_no,shade_no + return troff_no,override,shade_no end - return troff_no + return troff_no,override end -local function do_postobj_color(tr,sh) +local function do_postobj_color(tr,over,sh) if sh then pdf_literalcode("W n /MPlibSh%s sh Q",sh) end + if over then + texsprint("\\special{color pop}") + end if tr then pdf_literalcode("/MPlibTr%i gs",tr) end @@ -972,7 +1003,7 @@ local function flush(result,flusher) local objecttype = object.type local prescript = object.prescript prescript = prescript and script2table(prescript) -- prescript is now a table - local tr_opaq,shade_no = do_preobj_color(object,prescript) + local tr_opaq,cr_over,shade_no = do_preobj_color(object,prescript) if prescript and prescript.MPlibTEXboxID then putTEXboxes(object,prescript) elseif objecttype == "start_bounds" or objecttype == "stop_bounds" then @@ -1084,7 +1115,7 @@ local function flush(result,flusher) -- pdf_literalcode(cr) -- end end - do_postobj_color(tr_opaq,shade_no) + do_postobj_color(tr_opaq,cr_over,shade_no) end end stop_pdf_code() |