diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/thumbpdf/thumbpdf.sty')
-rw-r--r-- | Master/texmf-dist/tex/generic/thumbpdf/thumbpdf.sty | 94 |
1 files changed, 91 insertions, 3 deletions
diff --git a/Master/texmf-dist/tex/generic/thumbpdf/thumbpdf.sty b/Master/texmf-dist/tex/generic/thumbpdf/thumbpdf.sty index 2c925afbd7e..c97bf33b238 100644 --- a/Master/texmf-dist/tex/generic/thumbpdf/thumbpdf.sty +++ b/Master/texmf-dist/tex/generic/thumbpdf/thumbpdf.sty @@ -1,11 +1,11 @@ % File: thumbpdf.sty % Project: thumbpdf -% Version: 2010/07/07 v3.11 +% Version: 2011/08/10 v3.13 % Author: Heiko Oberdiek % % Function: Inclusion of thumbnails % -% Copyright: Copyright (C) 1999-2010 Heiko Oberdiek. +% Copyright: Copyright (C) 1999-2011 Heiko Oberdiek. % % This work may be distributed and/or modified under % the conditions of the LaTeX Project Public License, @@ -96,6 +96,8 @@ % 2007/11/07 v3.9 % 2008/04/16 v3.10 % 2010/07/07 v3.11: Warning if \pdfobjcompresslevel>0. +% 2011/08/09 v3.12: Support for LuaTeX added. +% 2011/08/10 v3.13: Version date fixed. % % \THB@ is the prefix for internal command names. % @@ -116,7 +118,7 @@ \def\x{\endgroup\ProvidesPackage{thumbpdf}}% \fi \fi -\x[2010/07/07 v3.11 Inclusion of thumbnails (HO)]% +\x[2011/08/10 v3.13 Inclusion of thumbnails (HO)]% % Dummy for \thisthumb and \DeclareThumbs. It is overwritten, % if the checks succeed and the whole package is loaded. @@ -481,6 +483,70 @@ \fi } +\RequirePackage{ifluatex}[2010/03/01] +\ifluatex + \def\THB@InitLua{% + \catcode39=12 % ' + \catcode40=12 % ( + \catcode41=12 % ) + \catcode43=12 % + + \catcode45=12 % - + \catcode46=12 % . + \catcode60=12 % < + \catcode95=12 % _ + \escapechar=-1 % + \edef\\{\string\\}% + \edef\%{\string\%}% + \escapechar=92 % + \newlinechar=13 % + \catcode13=12 % + \endlinechar=13 % + }% + \ifnum\luatexversion<36 % + \def\THB@directlua#{\directlua0}% + \else + \let\THB@directlua\directlua + \fi + \begingroup + \THB@InitLua % + \THB@directlua{% + thumbpdf = {} + thumbpdf.callback = callback.find('process_input_buffer') +% if thumbpdf.callback then +% texio.write_nl('log', 'Package thumbpdf Info: Callback saved.') +% texio.write_nl('log', '') +% end + function thumbpdf.process_input_buffer(buffer) + return string.gsub(buffer, '[\\100-\\255]', + function (s) + local num = string.byte(s) + if num < 128 then + return s + else + return unicode.utf8.char(num + 1114112) + end + end + ) + end + thumbpdf.id, thumbpdf.error = + callback.register('process_input_buffer', + thumbpdf.process_input_buffer) + if thumbpdf.id == nil then + tex.print(string.format( + '\\\\endgroup\\\\begingroup% + \\\\PackageError{thumbpdf}% + {\%s:\\\\MessageBreak \%s}\\\\@ehc', + 'Setting process_input_buffer failed', + string.gsub(thumbpdf.error, '\\.$', ''))) +% else +% texio.write_nl('log', +% 'Package thumbpdf Info: Setting process_input_buffer.') +% texio.write_nl('log', '') + end + }% + \endgroup% +\fi + % Many commands and catcode changes are only necessary to read % the data file, so we do this in a group. \begingroup @@ -551,6 +617,28 @@ \input{\THB@datafile}% \fi \endgroup + +\ifluatex + \begingroup + \THB@InitLua % + \THB@directlua{% + thumbpdf.id, thumbpdf.error = + callback.register('process_input_buffer', thumbpdf.callback) + if thumbpdf.id == nil then + tex.print(string.format( + '\\\\endgroup\\\\begingroup% + \\\\PackageError{thumbpdf}% + {\%s:\\\\MessageBreak \%s}\\\\@ehc', + 'Restoring process_input_buffer failed', + string.gsub(thumbpdf.error, '\\.$', ''))) +% else +% texio.write_nl('log', 'Package thumbpdf Info: Callback restored.') +% texio.write_nl('log', '') + end + }% + \endgroup +\fi + % restore catcode of `@'. \catcode`\@=\THB@AtCode\relax \endinput |