diff options
author | Karl Berry <karl@freefriends.org> | 2013-12-23 23:29:34 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-12-23 23:29:34 +0000 |
commit | af2acbff50348fb036cf16336e7a80037f520417 (patch) | |
tree | d17e7c1c3bfe7e3e7f243bf6b771c23017005fdc /Master/texmf-dist | |
parent | 95f3bfea27839033e3d7abd3fba2bba4dad16181 (diff) |
luamplib (23dec13)
git-svn-id: svn://tug.org/texlive/trunk@32475 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/luatex/luamplib/NEWS | 8 | ||||
-rw-r--r-- | Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf | bin | 102620 -> 103068 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/luatex/luamplib/luamplib.dtx | 112 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/luamplib/luamplib.lua | 99 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/luamplib/luamplib.sty | 2 |
5 files changed, 132 insertions, 89 deletions
diff --git a/Master/texmf-dist/doc/luatex/luamplib/NEWS b/Master/texmf-dist/doc/luatex/luamplib/NEWS index 66c93c46e1e..ddd65ff8682 100644 --- a/Master/texmf-dist/doc/luatex/luamplib/NEWS +++ b/Master/texmf-dist/doc/luatex/luamplib/NEWS @@ -1,7 +1,13 @@ History of the luamplib package +2013/12/23 2.11 + * fix a bug wrt "withoutcolor" option + * fix a bug wrt "char <number> infont <font>" picture + * bypass some ConTeXt commands which raise errors under metafun format + * ignore "fontmapfile <filename>" which isn't needed in mplib + 2013/12/19 2.1 - * Do not ignore "withcolor" option during textext process + * Do not ignore "withcolor" option for textext and normal text object * verbatimtex ... etex is now just ignored, not raising error 2013/12/11 2.03 diff --git a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf Binary files differindex c2fc27cb5bf..77a471b6318 100644 --- a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf +++ b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf diff --git a/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx b/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx index 558936a9864..9d5b3598268 100644 --- a/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx +++ b/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx @@ -85,7 +85,7 @@ See source file '\inFileName' for licencing and contact information. %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{luamplib.drv}% - [2013/12/19 v2.1 Interface for using the mplib library]% + [2013/12/23 v2.11 Interface for using the mplib library]% \documentclass{ltxdoc} \usepackage{metalogo,multicol,mdwlist,fancyvrb,xspace} \usepackage[x11names]{xcolor} @@ -154,7 +154,7 @@ See source file '\inFileName' for licencing and contact information. % \author{Hans Hagen, Taco Hoekwater, Elie Roux, Philipp Gesang and Kim Dohyun\\ % Maintainer: LuaLaTeX Maintainers --- % Support: \email{lualatex-dev@tug.org}} -% \date{2013/12/19 v2.1} +% \date{2013/12/23 v2.11} % % \maketitle % @@ -225,8 +225,8 @@ luamplib.lastlog = "" local err, warn, info, log = luatexbase.provides_module({ name = "luamplib", - version = 2.1, - date = "2013/12/19", + version = 2.11, + date = "2013/12/23", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", }) @@ -355,6 +355,7 @@ else local preamble = [[ boolean mplib ; mplib := true ; let dump = endinput ; + let normalfontsize = fontsize; input %s ; ]] @@ -463,10 +464,13 @@ end luamplib.pdf_literalcode = pdf_literalcode local function pdf_textfigure(font,size,text,width,height,depth) - text = text:gsub(".","\\hbox{%1}") -- kerning happens in metapost % \end{macrocode} -% The following line has been slightly modified by Kim. +% The following three lines have been modified by Kim. % \begin{macrocode} + -- if text == "" then text = "\0" end -- char(0) has gone + text = text:gsub(".",function(c) + return format("\\hbox{\\char%i}",string.byte(c)) -- kerning happens in metapost + end) texsprint(format("\\mplibtextext{%s}{%f}{%s}{%s}{%f}",font,size,text,0,-( 7200/ 7227)/65536*depth)) end luamplib.pdf_textfigure = pdf_textfigure @@ -567,32 +571,48 @@ end % % \begin{macrocode} -local mplibcodepreamblefirst = [[ -def textext (expr t) = - image( special "%%mkTEXbox:"&t; ) +local mplibcodepreamble = [[ +vardef rawtextext (expr t) = + if unknown TEXBOX_: + image( special "%%mkTEXbox:"&t; ) + else: + TEXBOX_ := TEXBOX_ + 1; + image ( + addto currentpicture doublepath unitsquare + xscaled TEXBOX_wd[TEXBOX_] + yscaled (TEXBOX_ht[TEXBOX_] + TEXBOX_dp[TEXBOX_]) + shifted (0, -TEXBOX_dp[TEXBOX_]) + withprescript "%%TEXtxtbox:" & + decimal TEXBOX_ & ":" & + decimal TEXBOX_wd[TEXBOX_] & ":" & + decimal(TEXBOX_ht[TEXBOX_]+TEXBOX_dp[TEXBOX_]); + ) + fi enddef; -let TEX = textext; -def VerbatimTeX (text t) = enddef; -]] - -local mplibcodepreamblesecond = [[ -vardef textext (text t) = - TEXBOX_ := TEXBOX_ + 1; - image ( - addto currentpicture doublepath unitsquare - xscaled TEXBOX_wd[TEXBOX_] - yscaled (TEXBOX_ht[TEXBOX_] + TEXBOX_dp[TEXBOX_]) - shifted (0, -TEXBOX_dp[TEXBOX_]) - withprescript "%%TEXtxtbox:" & - decimal TEXBOX_ & ":" & - decimal TEXBOX_wd[TEXBOX_] & ":" & - decimal(TEXBOX_ht[TEXBOX_]+TEXBOX_dp[TEXBOX_]); - ) +if known context_mlib: + defaultfont := "cmtt10"; + let infont = normalinfont; + let fontsize = normalfontsize; + vardef thelabel@#(expr p,z) = + if string p : + thelabel@#(p infont defaultfont scaled defaultscale,z) + else : + p shifted (z + labeloffset*mfun_laboff@# - + (mfun_labxf@#*lrcorner p + mfun_labyf@#*ulcorner p + + (1-mfun_labxf@#-mfun_labyf@#)*llcorner p)) + fi + enddef; +else: + vardef textext@# (text t) = rawtextext (t) enddef; +fi +def externalfigure primary filename = + draw rawtextext("\includegraphics{"& filename &"}") enddef; -def TEX (text t) = textext (t) enddef; +def TEX = textext enddef; def VerbatimTeX (text t) = - message "verbatimtex '"& t &"' is ignored"; + if known TEXBOX_: message "verbatimtex '"& t &"' is ignored"; fi enddef; +def fontmapfile primary filename = enddef; ]] local factor = 65536*(7227/7200) @@ -609,9 +629,10 @@ local function putTEXboxes (object) if sx == 0 then sx = 0.00001 end if sy == 0 then sy = 0.00001 end local cs = object.color - if cs then cs = luamplib.colorconverter(cs) end + if cs and #cs > 0 then + pdf_literalcode(luamplib.colorconverter(cs)) + end pdf_literalcode("q %f %f %f %f %f %f cm",sx,rx,ry,sy,tx,ty) - if cs then pdf_literalcode(cs) end texsprint(format("\\mplibputtextbox{%i}",n)) pdf_literalcode("Q") end @@ -657,7 +678,7 @@ local function makeTEXboxes (data) end) local mpx = luamplib.load(currentformat) if mpx and data then - local result = mpx:execute(mplibcodepreamblefirst .. data) + local result = mpx:execute(mplibcodepreamble .. data) domakeTEXboxes(result) end return data @@ -677,7 +698,7 @@ local function processwithTEXboxes (data) "TEXBOX_ht["..num.."] := "..box.height/factor..";\n".. "TEXBOX_dp["..num.."] := "..box.depth /factor..";\n" end - process(prepreamble .. mplibcodepreamblesecond .. data) + process(prepreamble .. mplibcodepreamble .. data) end luamplib.processwithTEXboxes = processwithTEXboxes @@ -737,21 +758,16 @@ local function flush(result,flusher) % % \begin{macrocode} local cs = object.color - if cs then cs = luamplib.colorconverter(cs) end + if cs and #cs > 0 then + pdf_literalcode(luamplib.colorconverter(cs)) + end pdf_literalcode("q %f %f %f %f %f %f cm",ot[3],ot[4],ot[5],ot[6],ot[1],ot[2]) - if cs then pdf_literalcode(cs) end pdf_textfigure(object.font,object.dsize,object.text,object.width,object.height,object.depth) pdf_literalcode("Q") else -% \end{macrocode} -% -% Change from \ConTeXt{} code: the following 5 lines are for properly supporting `withcolor' option -% -% \begin{macrocode} - local cs, cr = object.color, nil - if cs then - cs, cr = luamplib.colorconverter(cs) - if cs then pdf_literalcode(cs) end + local cs = object.color + if cs and #cs > 0 then + pdf_literalcode(luamplib.colorconverter(cs)) end local ml = object.miterlimit if ml and ml ~= miterlimit then @@ -835,9 +851,9 @@ local function flush(result,flusher) pdf_literalcode("Q") end end - if cr then - pdf_literalcode(cr) - end +-- if cr then +-- pdf_literalcode(cr) +-- end end end end @@ -858,7 +874,7 @@ local function colorconverter(cr) elseif n == 3 then local r, g, b = cr[1], cr[2], cr[3] return format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b), "0 g 0 G" - elseif n == 1 then + else local s = cr[1] return format("%.3f g %.3f G",s,s), "0 g 0 G" end @@ -885,7 +901,7 @@ luamplib.colorconverter = colorconverter \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luamplib} - [2013/12/19 v2.1 mplib package for LuaTeX] + [2013/12/23 v2.11 mplib package for LuaTeX] \RequirePackage{luatexbase-modutils} \RequirePackage{pdftexcmds} \fi diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua index e818c56c1e4..53fa55ec823 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.1, - date = "2013/12/19", + version = 2.11, + date = "2013/12/23", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", }) @@ -113,6 +113,7 @@ else local preamble = [[ boolean mplib ; mplib := true ; let dump = endinput ; + let normalfontsize = fontsize; input %s ; ]] @@ -217,7 +218,10 @@ end luamplib.pdf_literalcode = pdf_literalcode local function pdf_textfigure(font,size,text,width,height,depth) - text = text:gsub(".","\\hbox{%1}") -- kerning happens in metapost + -- if text == "" then text = "\0" end -- char(0) has gone + text = text:gsub(".",function(c) + return format("\\hbox{\\char%i}",string.byte(c)) -- kerning happens in metapost + end) texsprint(format("\\mplibtextext{%s}{%f}{%s}{%s}{%f}",font,size,text,0,-( 7200/ 7227)/65536*depth)) end luamplib.pdf_textfigure = pdf_textfigure @@ -310,32 +314,48 @@ local function flushconcatpath(path,open) end -local mplibcodepreamblefirst = [[ -def textext (expr t) = - image( special "%%mkTEXbox:"&t; ) +local mplibcodepreamble = [[ +vardef rawtextext (expr t) = + if unknown TEXBOX_: + image( special "%%mkTEXbox:"&t; ) + else: + TEXBOX_ := TEXBOX_ + 1; + image ( + addto currentpicture doublepath unitsquare + xscaled TEXBOX_wd[TEXBOX_] + yscaled (TEXBOX_ht[TEXBOX_] + TEXBOX_dp[TEXBOX_]) + shifted (0, -TEXBOX_dp[TEXBOX_]) + withprescript "%%TEXtxtbox:" & + decimal TEXBOX_ & ":" & + decimal TEXBOX_wd[TEXBOX_] & ":" & + decimal(TEXBOX_ht[TEXBOX_]+TEXBOX_dp[TEXBOX_]); + ) + fi enddef; -let TEX = textext; -def VerbatimTeX (text t) = enddef; -]] - -local mplibcodepreamblesecond = [[ -vardef textext (text t) = - TEXBOX_ := TEXBOX_ + 1; - image ( - addto currentpicture doublepath unitsquare - xscaled TEXBOX_wd[TEXBOX_] - yscaled (TEXBOX_ht[TEXBOX_] + TEXBOX_dp[TEXBOX_]) - shifted (0, -TEXBOX_dp[TEXBOX_]) - withprescript "%%TEXtxtbox:" & - decimal TEXBOX_ & ":" & - decimal TEXBOX_wd[TEXBOX_] & ":" & - decimal(TEXBOX_ht[TEXBOX_]+TEXBOX_dp[TEXBOX_]); - ) +if known context_mlib: + defaultfont := "cmtt10"; + let infont = normalinfont; + let fontsize = normalfontsize; + vardef thelabel@#(expr p,z) = + if string p : + thelabel@#(p infont defaultfont scaled defaultscale,z) + else : + p shifted (z + labeloffset*mfun_laboff@# - + (mfun_labxf@#*lrcorner p + mfun_labyf@#*ulcorner p + + (1-mfun_labxf@#-mfun_labyf@#)*llcorner p)) + fi + enddef; +else: + vardef textext@# (text t) = rawtextext (t) enddef; +fi +def externalfigure primary filename = + draw rawtextext("\includegraphics{"& filename &"}") enddef; -def TEX (text t) = textext (t) enddef; +def TEX = textext enddef; def VerbatimTeX (text t) = - message "verbatimtex '"& t &"' is ignored"; + if known TEXBOX_: message "verbatimtex '"& t &"' is ignored"; fi enddef; +def fontmapfile primary filename = enddef; ]] local factor = 65536*(7227/7200) @@ -352,9 +372,10 @@ local function putTEXboxes (object) if sx == 0 then sx = 0.00001 end if sy == 0 then sy = 0.00001 end local cs = object.color - if cs then cs = luamplib.colorconverter(cs) end + if cs and #cs > 0 then + pdf_literalcode(luamplib.colorconverter(cs)) + end pdf_literalcode("q %f %f %f %f %f %f cm",sx,rx,ry,sy,tx,ty) - if cs then pdf_literalcode(cs) end texsprint(format("\\mplibputtextbox{%i}",n)) pdf_literalcode("Q") end @@ -400,7 +421,7 @@ local function makeTEXboxes (data) end) local mpx = luamplib.load(currentformat) if mpx and data then - local result = mpx:execute(mplibcodepreamblefirst .. data) + local result = mpx:execute(mplibcodepreamble .. data) domakeTEXboxes(result) end return data @@ -420,7 +441,7 @@ local function processwithTEXboxes (data) "TEXBOX_ht["..num.."] := "..box.height/factor..";\n".. "TEXBOX_dp["..num.."] := "..box.depth /factor..";\n" end - process(prepreamble .. mplibcodepreamblesecond .. data) + process(prepreamble .. mplibcodepreamble .. data) end luamplib.processwithTEXboxes = processwithTEXboxes @@ -466,16 +487,16 @@ local function flush(result,flusher) elseif objecttype == "text" then local ot = object.transform -- 3,4,5,6,1,2 local cs = object.color - if cs then cs = luamplib.colorconverter(cs) end + if cs and #cs > 0 then + pdf_literalcode(luamplib.colorconverter(cs)) + end pdf_literalcode("q %f %f %f %f %f %f cm",ot[3],ot[4],ot[5],ot[6],ot[1],ot[2]) - if cs then pdf_literalcode(cs) end pdf_textfigure(object.font,object.dsize,object.text,object.width,object.height,object.depth) pdf_literalcode("Q") else - local cs, cr = object.color, nil - if cs then - cs, cr = luamplib.colorconverter(cs) - if cs then pdf_literalcode(cs) end + local cs = object.color + if cs and #cs > 0 then + pdf_literalcode(luamplib.colorconverter(cs)) end local ml = object.miterlimit if ml and ml ~= miterlimit then @@ -559,9 +580,9 @@ local function flush(result,flusher) pdf_literalcode("Q") end end - if cr then - pdf_literalcode(cr) - end +-- if cr then +-- pdf_literalcode(cr) +-- end end end end @@ -582,7 +603,7 @@ local function colorconverter(cr) elseif n == 3 then local r, g, b = cr[1], cr[2], cr[3] return format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b), "0 g 0 G" - elseif n == 1 then + else local s = cr[1] return format("%.3f g %.3f G",s,s), "0 g 0 G" end diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty index ceff5edcddb..d22255d4d92 100644 --- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty +++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty @@ -14,7 +14,7 @@ \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luamplib} - [2013/12/19 v2.1 mplib package for LuaTeX] + [2013/12/23 v2.11 mplib package for LuaTeX] \RequirePackage{luatexbase-modutils} \RequirePackage{pdftexcmds} \fi |