texlive[46216] Master/texmf-dist: luamplib (4jan18)

commits+karl at tug.org commits+karl at tug.org
Fri Jan 5 00:45:44 CET 2018


Revision: 46216
          http://tug.org/svn/texlive?view=revision&revision=46216
Author:   karl
Date:     2018-01-05 00:45:44 +0100 (Fri, 05 Jan 2018)
Log Message:
-----------
luamplib (4jan18)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/luatex/luamplib/NEWS
    trunk/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf
    trunk/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx
    trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
    trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty

Modified: trunk/Master/texmf-dist/doc/luatex/luamplib/NEWS
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luamplib/NEWS	2018-01-04 23:45:30 UTC (rev 46215)
+++ trunk/Master/texmf-dist/doc/luatex/luamplib/NEWS	2018-01-04 23:45:44 UTC (rev 46216)
@@ -1,5 +1,10 @@
                        History of the luamplib package
 
+2018/01/04 2.12.2
+    * workaround issue #70 "Labels outside beginfig...endfig are not inherited"
+    * address issue #71 "metafun problem: arrow tips are not filled"
+    by importing luatex-mplib.lua from context beta.
+
 2017/06/02 2.12.1
     * when \mplibglobaltextext{enable} is declared, metapost variables
     containing btex ... etex labels can be inherited across code chunks.

Modified: trunk/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx
===================================================================
--- trunk/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx	2018-01-04 23:45:30 UTC (rev 46215)
+++ trunk/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx	2018-01-04 23:45:44 UTC (rev 46216)
@@ -85,7 +85,7 @@
 %<*driver>
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesFile{luamplib.drv}%
-  [2017/06/02 v2.12.1 Interface for using the mplib library]%
+  [2018/01/04 v2.12.2 Interface for using the mplib library]%
 \documentclass{ltxdoc}
 \usepackage{metalogo,multicol,mdwlist,fancyvrb,xspace}
 \usepackage[x11names]{xcolor}
@@ -153,7 +153,7 @@
 % \author{Hans Hagen, Taco Hoekwater, Elie Roux, Philipp Gesang and Kim Dohyun\\
 % Maintainer: LuaLaTeX Maintainers ---
 % Support: \email{lualatex-dev at tug.org}}
-% \date{2017/06/02 v2.12.1}
+% \date{2018/01/04 v2.12.2}
 %
 % \maketitle
 %
@@ -373,8 +373,8 @@
 
 luatexbase.provides_module {
   name          = "luamplib",
-  version       = "2.12.1",
-  date          = "2017/06/02",
+  version       = "2.12.2",
+  date          = "2018/01/04",
   description   = "Lua package to typeset Metapost with LuaTeX's MPLib.",
 }
 
@@ -825,6 +825,12 @@
 luamplib.codeinherit = false
 local mplibinstances = {}
 local process = function (data,indeed,verbatim)
+%    \end{macrocode}
+%     workaround issue \#70
+%    \begin{macrocode}
+  if not stringfind(data, begname.."beginfig%s*%([%+%-%s]*%d[%.%d%s]*%)") then
+    data = data .. "beginfig(-1);endfig;"
+  end
   local standalone, firstpass = not luamplib.codeinherit, not indeed
   local currfmt = currentformat .. (luamplib.numbersystem or "scaled")
   currfmt = firstpass and currfmt or (currfmt.."2")
@@ -1514,9 +1520,13 @@
         local bbox = figure:boundingbox()
         local llx, lly, urx, ury = bbox[1], bbox[2], bbox[3], bbox[4] -- faster than unpack
         if urx < llx then
+%    \end{macrocode}
+%    \textsf{luamplib} silently ignores this invalid figure for those codes
+%    that do not contain |beginfig ... endfig|. (issue \#70)
+%    \begin{macrocode}
           -- invalid
-          pdf_startfigure(fignum,0,0,0,0)
-          pdf_stopfigure()
+          -- pdf_startfigure(fignum,0,0,0,0)
+          -- pdf_stopfigure()
         else
 %    \end{macrocode}
 %    Insert |verbatimtex| code before mplib box.
@@ -1529,6 +1539,8 @@
           pdf_startfigure(fignum,llx,lly,urx,ury)
           start_pdf_code()
           if objects then
+            local savedpath = nil
+            local savedhtap = nil
             for o=1,#objects do
               local object        = objects[o]
               local objecttype    = object.type
@@ -1548,9 +1560,10 @@
               elseif objecttype == "start_bounds" or objecttype == "stop_bounds" then
                 -- skip
               elseif objecttype == "start_clip" then
+                local evenodd = not object.istext and object.postscript == "evenodd"
                 start_pdf_code()
                 flushnormalpath(object.path,t,false)
-                pdf_literalcode("W n")
+                pdf_literalcode(evenodd and "W* n" or "W n")
               elseif objecttype == "stop_clip" then
                 stop_pdf_code()
                 miterlimit, linecap, linejoin, dashed = -1, -1, -1, false
@@ -1569,98 +1582,146 @@
 %    \end{macrocode}
 %     Color stuffs are modified and moved to several lines above.
 %    \begin{macrocode}
-                local ml = object.miterlimit
-                if ml and ml ~= miterlimit then
-                  miterlimit = ml
-                  pdf_literalcode("%f M",ml)
+                local evenodd, collect, both = false, false, false
+                local postscript = object.postscript
+                if not object.istext then
+                  if postscript == "evenodd" then
+                    evenodd = true
+                  elseif postscript == "collect" then
+                    collect = true
+                  elseif postscript == "both" then
+                    both = true
+                  elseif postscript == "eoboth" then
+                    evenodd = true
+                    both    = true
+                  end
                 end
-                local lj = object.linejoin
-                if lj and lj ~= linejoin then
-                  linejoin = lj
-                  pdf_literalcode("%i j",lj)
-                end
-                local lc = object.linecap
-                if lc and lc ~= linecap then
-                  linecap = lc
-                  pdf_literalcode("%i J",lc)
-                end
-                local dl = object.dash
-                if dl then
-                  local d = format("[%s] %i d",tableconcat(dl.dashes or {}," "),dl.offset)
-                  if d ~= dashed then
-                    dashed = d
-                    pdf_literalcode(dashed)
+                if collect then
+                  if not savedpath then
+                    savedpath = { object.path or false }
+                    savedhtap = { object.htap or false }
+                  else
+                    savedpath[#savedpath+1] = object.path or false
+                    savedhtap[#savedhtap+1] = object.htap or false
                   end
-                elseif dashed then
-                  pdf_literalcode("[] 0 d")
-                  dashed = false
-                end
-                local path = object.path
-                local transformed, penwidth = false, 1
-                local open = path and path[1].left_type and path[#path].right_type
-                local pen = object.pen
-                if pen then
-                  if pen.type == 'elliptical' then
-                    transformed, penwidth = pen_characteristics(object) -- boolean, value
-                    pdf_literalcode("%f w",penwidth)
-                    if objecttype == 'fill' then
-                      objecttype = 'both'
+                else
+                  local ml = object.miterlimit
+                  if ml and ml ~= miterlimit then
+                    miterlimit = ml
+                    pdf_literalcode("%f M",ml)
+                  end
+                  local lj = object.linejoin
+                  if lj and lj ~= linejoin then
+                    linejoin = lj
+                    pdf_literalcode("%i j",lj)
+                  end
+                  local lc = object.linecap
+                  if lc and lc ~= linecap then
+                    linecap = lc
+                    pdf_literalcode("%i J",lc)
+                  end
+                  local dl = object.dash
+                  if dl then
+                    local d = format("[%s] %i d",tableconcat(dl.dashes or {}," "),dl.offset)
+                    if d ~= dashed then
+                      dashed = d
+                      pdf_literalcode(dashed)
                     end
-                  else -- calculated by mplib itself
-                    objecttype = 'fill'
+                  elseif dashed then
+                    pdf_literalcode("[] 0 d")
+                    dashed = false
                   end
-                end
-                if transformed then
-                  start_pdf_code()
-                end
-                if path then
+                  local path = object.path
+                  local transformed, penwidth = false, 1
+                  local open = path and path[1].left_type and path[#path].right_type
+                  local pen = object.pen
+                  if pen then
+                    if pen.type == 'elliptical' then
+                      transformed, penwidth = pen_characteristics(object) -- boolean, value
+                      pdf_literalcode("%f w",penwidth)
+                      if objecttype == 'fill' then
+                        objecttype = 'both'
+                      end
+                    else -- calculated by mplib itself
+                      objecttype = 'fill'
+                    end
+                  end
                   if transformed then
-                    flushconcatpath(path,open)
-                  else
-                    flushnormalpath(path,open)
+                    start_pdf_code()
                   end
+                  if path then
+                    if savedpath then
+                      for i=1,#savedpath do
+                        local path = savedpath[i]
+                        if transformed then
+                          flushconcatpath(path,open)
+                        else
+                          flushnormalpath(path,open)
+                        end
+                      end
+                      savedpath = nil
+                    end
+                    if transformed then
+                      flushconcatpath(path,open)
+                    else
+                      flushnormalpath(path,open)
+                    end
 %    \end{macrocode}
 %
 %     Change from \ConTeXt{} code: color stuff
 %
 %    \begin{macrocode}
-                  if not shade_no then ----- conflict with shading
+                    if not shade_no then ----- conflict with shading
+                      if objecttype == "fill" then
+                        pdf_literalcode(evenodd and "h f*" or "h f")
+                      elseif objecttype == "outline" then
+                        if both then
+                          pdf_literalcode(evenodd and "h B*" or "h B")
+                        else
+                          pdf_literalcode(open and "S" or "h S")
+                        end
+                      elseif objecttype == "both" then
+                        pdf_literalcode(evenodd and "h B*" or "h B")
+                      end
+                    end
+                  end
+                  if transformed then
+                    stop_pdf_code()
+                  end
+                  local path = object.htap
+                  if path then
+                    if transformed then
+                      start_pdf_code()
+                    end
+                    if savedhtap then
+                      for i=1,#savedhtap do
+                        local path = savedhtap[i]
+                        if transformed then
+                          flushconcatpath(path,open)
+                        else
+                          flushnormalpath(path,open)
+                        end
+                      end
+                      savedhtap = nil
+                      evenodd   = true
+                    end
+                    if transformed then
+                      flushconcatpath(path,open)
+                    else
+                      flushnormalpath(path,open)
+                    end
                     if objecttype == "fill" then
-                      pdf_literalcode("h f")
+                      pdf_literalcode(evenodd and "h f*" or "h f")
                     elseif objecttype == "outline" then
-                      pdf_literalcode((open and "S") or "h S")
+                      pdf_literalcode(open and "S" or "h S")
                     elseif objecttype == "both" then
-                      pdf_literalcode("h B")
+                      pdf_literalcode(evenodd and "h B*" or "h B")
                     end
+                    if transformed then
+                      stop_pdf_code()
+                    end
                   end
                 end
-                if transformed then
-                  stop_pdf_code()
-                end
-                local path = object.htap
-                if path then
-                  if transformed then
-                    start_pdf_code()
-                  end
-                  if transformed then
-                    flushconcatpath(path,open)
-                  else
-                    flushnormalpath(path,open)
-                  end
-                  if objecttype == "fill" then
-                    pdf_literalcode("h f")
-                  elseif objecttype == "outline" then
-                    pdf_literalcode((open and "S") or "h S")
-                  elseif objecttype == "both" then
-                    pdf_literalcode("h B")
-                  end
-                  if transformed then
-                    stop_pdf_code()
-                  end
-                end
---                if cr then
---                  pdf_literalcode(cr)
---                end
               end
 %    \end{macrocode}
 %
@@ -1718,7 +1779,7 @@
 \else
   \NeedsTeXFormat{LaTeX2e}
   \ProvidesPackage{luamplib}
-    [2017/06/02 v2.12.1 mplib package for LuaTeX]
+    [2018/01/04 v2.12.2 mplib package for LuaTeX]
   \ifx\newluafunction\@undefined
   \input ltluatex
   \fi

Modified: trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua	2018-01-04 23:45:30 UTC (rev 46215)
+++ trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua	2018-01-04 23:45:44 UTC (rev 46216)
@@ -18,8 +18,8 @@
 
 luatexbase.provides_module {
   name          = "luamplib",
-  version       = "2.12.1",
-  date          = "2017/06/02",
+  version       = "2.12.2",
+  date          = "2018/01/04",
   description   = "Lua package to typeset Metapost with LuaTeX's MPLib.",
 }
 
@@ -415,6 +415,9 @@
 luamplib.codeinherit = false
 local mplibinstances = {}
 local process = function (data,indeed,verbatim)
+  if not stringfind(data, begname.."beginfig%s*%([%+%-%s]*%d[%.%d%s]*%)") then
+    data = data .. "beginfig(-1);endfig;"
+  end
   local standalone, firstpass = not luamplib.codeinherit, not indeed
   local currfmt = currentformat .. (luamplib.numbersystem or "scaled")
   currfmt = firstpass and currfmt or (currfmt.."2")
@@ -1069,8 +1072,8 @@
         local llx, lly, urx, ury = bbox[1], bbox[2], bbox[3], bbox[4] -- faster than unpack
         if urx < llx then
           -- invalid
-          pdf_startfigure(fignum,0,0,0,0)
-          pdf_stopfigure()
+          -- pdf_startfigure(fignum,0,0,0,0)
+          -- pdf_stopfigure()
         else
           if TeX_code_t[f] then
             texsprint(TeX_code_t[f])
@@ -1079,6 +1082,8 @@
           pdf_startfigure(fignum,llx,lly,urx,ury)
           start_pdf_code()
           if objects then
+            local savedpath = nil
+            local savedhtap = nil
             for o=1,#objects do
               local object        = objects[o]
               local objecttype    = object.type
@@ -1092,9 +1097,10 @@
               elseif objecttype == "start_bounds" or objecttype == "stop_bounds" then
                 -- skip
               elseif objecttype == "start_clip" then
+                local evenodd = not object.istext and object.postscript == "evenodd"
                 start_pdf_code()
                 flushnormalpath(object.path,t,false)
-                pdf_literalcode("W n")
+                pdf_literalcode(evenodd and "W* n" or "W n")
               elseif objecttype == "stop_clip" then
                 stop_pdf_code()
                 miterlimit, linecap, linejoin, dashed = -1, -1, -1, false
@@ -1110,93 +1116,141 @@
                 pdf_textfigure(object.font,object.dsize,object.text,object.width,object.height,object.depth)
                 stop_pdf_code()
               else
-                local ml = object.miterlimit
-                if ml and ml ~= miterlimit then
-                  miterlimit = ml
-                  pdf_literalcode("%f M",ml)
-                end
-                local lj = object.linejoin
-                if lj and lj ~= linejoin then
-                  linejoin = lj
-                  pdf_literalcode("%i j",lj)
-                end
-                local lc = object.linecap
-                if lc and lc ~= linecap then
-                  linecap = lc
-                  pdf_literalcode("%i J",lc)
-                end
-                local dl = object.dash
-                if dl then
-                  local d = format("[%s] %i d",tableconcat(dl.dashes or {}," "),dl.offset)
-                  if d ~= dashed then
-                    dashed = d
-                    pdf_literalcode(dashed)
+                local evenodd, collect, both = false, false, false
+                local postscript = object.postscript
+                if not object.istext then
+                  if postscript == "evenodd" then
+                    evenodd = true
+                  elseif postscript == "collect" then
+                    collect = true
+                  elseif postscript == "both" then
+                    both = true
+                  elseif postscript == "eoboth" then
+                    evenodd = true
+                    both    = true
                   end
-                elseif dashed then
-                  pdf_literalcode("[] 0 d")
-                  dashed = false
                 end
-                local path = object.path
-                local transformed, penwidth = false, 1
-                local open = path and path[1].left_type and path[#path].right_type
-                local pen = object.pen
-                if pen then
-                  if pen.type == 'elliptical' then
-                    transformed, penwidth = pen_characteristics(object) -- boolean, value
-                    pdf_literalcode("%f w",penwidth)
-                    if objecttype == 'fill' then
-                      objecttype = 'both'
-                    end
-                  else -- calculated by mplib itself
-                    objecttype = 'fill'
-                  end
-                end
-                if transformed then
-                  start_pdf_code()
-                end
-                if path then
-                  if transformed then
-                    flushconcatpath(path,open)
+                if collect then
+                  if not savedpath then
+                    savedpath = { object.path or false }
+                    savedhtap = { object.htap or false }
                   else
-                    flushnormalpath(path,open)
+                    savedpath[#savedpath+1] = object.path or false
+                    savedhtap[#savedhtap+1] = object.htap or false
                   end
-                  if not shade_no then ----- conflict with shading
-                    if objecttype == "fill" then
-                      pdf_literalcode("h f")
-                    elseif objecttype == "outline" then
-                      pdf_literalcode((open and "S") or "h S")
-                    elseif objecttype == "both" then
-                      pdf_literalcode("h B")
+                else
+                  local ml = object.miterlimit
+                  if ml and ml ~= miterlimit then
+                    miterlimit = ml
+                    pdf_literalcode("%f M",ml)
+                  end
+                  local lj = object.linejoin
+                  if lj and lj ~= linejoin then
+                    linejoin = lj
+                    pdf_literalcode("%i j",lj)
+                  end
+                  local lc = object.linecap
+                  if lc and lc ~= linecap then
+                    linecap = lc
+                    pdf_literalcode("%i J",lc)
+                  end
+                  local dl = object.dash
+                  if dl then
+                    local d = format("[%s] %i d",tableconcat(dl.dashes or {}," "),dl.offset)
+                    if d ~= dashed then
+                      dashed = d
+                      pdf_literalcode(dashed)
                     end
+                  elseif dashed then
+                    pdf_literalcode("[] 0 d")
+                    dashed = false
                   end
-                end
-                if transformed then
-                  stop_pdf_code()
-                end
-                local path = object.htap
-                if path then
+                  local path = object.path
+                  local transformed, penwidth = false, 1
+                  local open = path and path[1].left_type and path[#path].right_type
+                  local pen = object.pen
+                  if pen then
+                    if pen.type == 'elliptical' then
+                      transformed, penwidth = pen_characteristics(object) -- boolean, value
+                      pdf_literalcode("%f w",penwidth)
+                      if objecttype == 'fill' then
+                        objecttype = 'both'
+                      end
+                    else -- calculated by mplib itself
+                      objecttype = 'fill'
+                    end
+                  end
                   if transformed then
                     start_pdf_code()
                   end
-                  if transformed then
-                    flushconcatpath(path,open)
-                  else
-                    flushnormalpath(path,open)
+                  if path then
+                    if savedpath then
+                      for i=1,#savedpath do
+                        local path = savedpath[i]
+                        if transformed then
+                          flushconcatpath(path,open)
+                        else
+                          flushnormalpath(path,open)
+                        end
+                      end
+                      savedpath = nil
+                    end
+                    if transformed then
+                      flushconcatpath(path,open)
+                    else
+                      flushnormalpath(path,open)
+                    end
+                    if not shade_no then ----- conflict with shading
+                      if objecttype == "fill" then
+                        pdf_literalcode(evenodd and "h f*" or "h f")
+                      elseif objecttype == "outline" then
+                        if both then
+                          pdf_literalcode(evenodd and "h B*" or "h B")
+                        else
+                          pdf_literalcode(open and "S" or "h S")
+                        end
+                      elseif objecttype == "both" then
+                        pdf_literalcode(evenodd and "h B*" or "h B")
+                      end
+                    end
                   end
-                  if objecttype == "fill" then
-                    pdf_literalcode("h f")
-                  elseif objecttype == "outline" then
-                    pdf_literalcode((open and "S") or "h S")
-                  elseif objecttype == "both" then
-                    pdf_literalcode("h B")
-                  end
                   if transformed then
                     stop_pdf_code()
                   end
+                  local path = object.htap
+                  if path then
+                    if transformed then
+                      start_pdf_code()
+                    end
+                    if savedhtap then
+                      for i=1,#savedhtap do
+                        local path = savedhtap[i]
+                        if transformed then
+                          flushconcatpath(path,open)
+                        else
+                          flushnormalpath(path,open)
+                        end
+                      end
+                      savedhtap = nil
+                      evenodd   = true
+                    end
+                    if transformed then
+                      flushconcatpath(path,open)
+                    else
+                      flushnormalpath(path,open)
+                    end
+                    if objecttype == "fill" then
+                      pdf_literalcode(evenodd and "h f*" or "h f")
+                    elseif objecttype == "outline" then
+                      pdf_literalcode(open and "S" or "h S")
+                    elseif objecttype == "both" then
+                      pdf_literalcode(evenodd and "h B*" or "h B")
+                    end
+                    if transformed then
+                      stop_pdf_code()
+                    end
+                  end
                 end
---                if cr then
---                  pdf_literalcode(cr)
---                end
               end
               do_postobj_color(tr_opaq,cr_over,shade_no)
             end

Modified: trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty	2018-01-04 23:45:30 UTC (rev 46215)
+++ trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty	2018-01-04 23:45:44 UTC (rev 46216)
@@ -14,7 +14,7 @@
 \else
   \NeedsTeXFormat{LaTeX2e}
   \ProvidesPackage{luamplib}
-    [2017/06/02 v2.12.1 mplib package for LuaTeX]
+    [2018/01/04 v2.12.2 mplib package for LuaTeX]
   \ifx\newluafunction\@undefined
   \input ltluatex
   \fi



More information about the tex-live-commits mailing list