texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[7307] LuaTeX PDF destination name


From: trueroad
Subject: [7307] LuaTeX PDF destination name
Date: Sun, 7 Aug 2016 15:22:36 +0000 (UTC)

Revision: 7307
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7307
Author:   trueroad
Date:     2016-08-07 15:22:35 +0000 (Sun, 07 Aug 2016)
Log Message:
-----------
LuaTeX PDF destination name

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/doc/texinfo.tex

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2016-08-06 20:16:05 UTC (rev 7306)
+++ trunk/ChangeLog     2016-08-07 15:22:35 UTC (rev 7307)
@@ -1,3 +1,13 @@
+2016-08-07  Masamichi Hosoda  <address@hidden>
+
+       * doc/texinfo.tex (\pdfescapestrutfsixteen):
+       Rename from \pdfescapestring for LuaTeX.
+       (PDFescstr): New Lua function.
+       (\pdfescapestring): New macro for LuaTeX.
+       (\txiescapepdfutfsixteen): New macro.
+       (\dopdfoutline): LuaTeX:
+       Use UTF-8 encodings instead of UTF-16 for PDF destination names.
+
 2016-08-06  Gavin Smith  <address@hidden>
 
        * doc/texinfo.tex (\doublecolumntopgap, \pagesofar)

Modified: trunk/doc/texinfo.tex
===================================================================
--- trunk/doc/texinfo.tex       2016-08-06 20:16:05 UTC (rev 7306)
+++ trunk/doc/texinfo.tex       2016-08-07 15:22:35 UTC (rev 7307)
@@ -3,7 +3,7 @@
 % Load plain if necessary, i.e., if running under initex.
 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
 %
-\def\texinfoversion{2016-08-06.20}
+\def\texinfoversion{2016-08-07.14}
 %
 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@@ -1115,7 +1115,7 @@
 \else
   % Use Unicode destination names
   \txiuseunicodedestnametrue
-  % Escape PDF strings UTF-8 to UTF-16
+  % Escape PDF strings with converting UTF-16 from UTF-8
   \begingroup
     \catcode`\%=12
     \directlua{
@@ -1143,7 +1143,24 @@
       end
     }
   \endgroup
-  \def\pdfescapestring#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
+  \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
+  % Escape PDF strings without converting
+  \begingroup
+    \directlua{
+      function PDFescstr(str)
+        for c in string.bytes(str) do
+          if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
+            tex.sprint(
+              string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
+                            c))
+          else
+            tex.sprint(string.char(c))
+          end
+        end
+      end
+    }
+  \endgroup
+  \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
   \ifnum\luatexversion>84
     % For LuaTeX >= 0.85
     \def\pdfdest{\pdfextension dest}
@@ -1204,6 +1221,14 @@
     \xdef#1{\pdfescapestring{#1}}%
   \fi
 }
+\def\txiescapepdfutfsixteen#1{%
+  \ifx\pdfescapestrutfsixteen\thisisundefined
+    % No UTF-16 converting macro available.
+    \txiescapepdf{#1}%
+  \else
+    \xdef#1{\pdfescapestrutfsixteen{#1}}%
+  \fi
+}
 
 \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
 with PDF output, and none of those formats could be found.  (.eps cannot
@@ -1423,9 +1448,13 @@
       \ifx\pdfoutlinedest\empty
         \def\pdfoutlinedest{#4}%
       \else
+        % LuaTeX: Use UTF-8
+        % pdfTeX: Use ASCII
         \txiescapepdf\pdfoutlinedest
       \fi
-      \txiescapepdf\pdfoutlinetext
+      % LuaTeX: Convert to UTF-16
+      % pdfTeX: Use Latin-1 as PDFDocEncoding
+      \txiescapepdfutfsixteen\pdfoutlinetext
       %
       \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
     }
@@ -1684,6 +1713,8 @@
     \turnoffactive
     % Always use Unicode characters in title texts.
     \def\pdfoutlinetext{#1}%
+    % For XeTeX, xdvipdfmx converts to UTF-16.
+    % So we do not convert.
     \txiescapepdf\pdfoutlinetext
     \iftxiuseunicodedestname
       % Pass through Unicode characters.
@@ -1695,6 +1726,7 @@
     \ifx\pdfoutlinedest\empty
       \def\pdfoutlinedest{#4}%
     \fi
+    % Use UTF-8 or ASCII
     \txiescapepdf\pdfoutlinedest
     %
     \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A




reply via email to

[Prev in Thread] Current Thread [Next in Thread]