bug-texinfo
[Top][All Lists]
Advanced

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

PDF destination names for pdfTeX and LuaTeX


From: Masamichi Hosoda
Subject: PDF destination names for pdfTeX and LuaTeX
Date: Fri, 05 Aug 2016 01:04:05 +0900 (JST)

Hi Gavin,

I've made the patch that fixes PDF destination names, etc.
for pdfTeX and LuaTeX.

May I commit it?

For XeTeX, I've committed a similar patch.

ChangeLog:

2016-08-XX  Masamichi Hosoda  <address@hidden>

        * doc/texinfo.tex (\pdfmkdest, \dopdfoutline, \xrefX):
        Change the method of destination name switching
        Unicode or ASCII for pdfTeX and LuaTeX.

Thanks.
Index: doc/texinfo.tex
===================================================================
--- doc/texinfo.tex     (revision 7303)
+++ doc/texinfo.tex     (working copy)
@@ -1319,11 +1319,20 @@
     \indexnofonts
     \makevalueexpandable
     \turnoffactive
-    \ifx\luatexversion\thisisundefined
-      % pdfTeX: Use ASCII approximations in destination names.
+    \iftxiuseunicodedestname
+      \ifx \declaredencoding \latone
+        % Pass through Latin-1 characters.
+      \else
+        \ifx \declaredencoding \utfeight
+          % Pass through Unicode characters.
+        \else
+          % Use ASCII approximations in destination names.
+          \passthroughcharsfalse
+        \fi
+      \fi
+    \else
+      % Use ASCII approximations in destination names.
       \passthroughcharsfalse
-    \else
-      % LuaTeX: Pass through Unicode characters.
     \fi
     \def\pdfdestname{#1}%
     \txiescapepdf\pdfdestname
@@ -1358,33 +1367,61 @@
     % text in the case where a section has no node, but it doesn't
     % seem worth the trouble, since most documents are normally structured.
     {
-      \ifx\luatexversion\thisisundefined \else
-        \turnoffactive % LuaTeX can use Unicode strings for PDF
+      \turnoffactive
+      \ifx \declaredencoding \latone
+        % The PDF format can use an extended form of Latin-1 in bookmark
+        % strings.  See Appendix D of the PDF Reference, Sixth Edition, for
+        % the "PDFDocEncoding".
+        \passthroughcharstrue
+        \edef\pdfoutlinetext{#1}% Pass through Latin-1 characters.
+        \iftxiuseunicodedestname
+          % Pass through Latin-1 characters.
+          \edef\pdfoutlinedest{#3}%
+        \else
+          % Use ASCII approximations in destination names.
+          \passthroughcharsfalse
+          \edef\pdfoutlinedest{#3}% 
+        \fi
+      \else
+        \ifx \declaredencoding \utfeight
+          \ifx\luatexversion\thisisundefined
+            % For pdfTeX  with UTF-8.
+            % TODO: the PDF format can use UTF-16 in bookmark strings,
+            % but the code for this isn't done yet.
+            % Use ASCII approximations.
+            \passthroughcharsfalse
+            \edef\pdfoutlinetext{#1}%
+            \edef\pdfoutlinedest{#3}% 
+          \else
+            % For LuaTeX with UTF-8.
+            % Pass through Unicode characters for title texts.
+            \passthroughcharstrue
+            \edef\pdfoutlinetext{#1}%
+            \iftxiuseunicodedestname
+              % Pass through Unicode characters for destination names.
+              \edef\pdfoutlinedest{#3}%
+            \else
+              % Use ASCII approximations in destination names.
+              \passthroughcharsfalse
+              \edef\pdfoutlinedest{#3}% 
+            \fi
+          \fi
+        \else
+          % For non-Latin-1 or non-UTF-8 encodings.
+          % Use ASCII approximations.
+          \passthroughcharsfalse
+          \edef\pdfoutlinetext{#1}%
+          \edef\pdfoutlinedest{#3}% 
+        \fi
       \fi
-      \edef\pdfoutlinedest{#3}%
+      %
       \ifx\pdfoutlinedest\empty
         \def\pdfoutlinedest{#4}%
       \else
         \txiescapepdf\pdfoutlinedest
       \fi
+      \txiescapepdf\pdfoutlinetext
       %
-      % Also escape PDF chars in the display string.
-      \bgroup
-        \ifx \declaredencoding \latone
-          % The PDF format can use an extended form of Latin-1 in bookmark
-          % strings.  See Appendix D of the PDF Reference, Sixth Edition, for
-          % the "PDFDocEncoding".
-          \passthroughcharstrue
-        \fi
-        \ifx \declaredencoding \utfeight
-          % TODO: the PDF format can use UTF-16 in bookmark strings, but the
-          % code for this isn't done yet.
-        \fi
-        \globaldefs=1
-        \edef\pdfoutlinetext{#1}%
-        \txiescapepdf\pdfoutlinetext
-      \egroup
-      %
       \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
     }
   }
@@ -8857,14 +8894,6 @@
     % For pdfTeX and LuaTeX
     {\indexnofonts
      \makevalueexpandable
-     %
-     % This (wrongly) does not take account of leading or trailing
-     % spaces in #1, which should be ignored.
-     \ifx\luatexversion\thisisundefined
-       \edef\pdfxrefdest{#1}% pdfTeX: Replace Unicode characters with ASCII.
-     \else
-       \def\pdfxrefdest{#1}% LuaTeX: Pass through Unicode characters.
-     \fi
      \turnoffactive
      % This expands tokens, so do it after making catcode changes, so _
      % etc. don't get their TeX definitions.  This ignores all spaces in
@@ -8871,6 +8900,25 @@
      % #4, including (wrongly) those in the middle of the filename.
      \getfilename{#4}%
      %
+     % This (wrongly) does not take account of leading or trailing
+     % spaces in #1, which should be ignored.
+     \iftxiuseunicodedestname
+       \ifx \declaredencoding \latone
+         % Pass through Latin-1 characters.
+       \else
+         \ifx \declaredencoding \utfeight
+           % Pass through Unicode characters.
+         \else
+           % Use ASCII approximations in destination names.
+           \passthroughcharsfalse
+         \fi
+       \fi
+     \else
+       % Use ASCII approximations in destination names.
+       \passthroughcharsfalse
+     \fi
+     \def\pdfxrefdest{#1}%
+     %
      \ifx\pdfxrefdest\empty
        \def\pdfxrefdest{Top}% no empty targets
      \else

reply via email to

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