bug-texinfo
[Top][All Lists]
Advanced

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

Re: XeTeX encoding problem


From: Masamichi HOSODA
Subject: Re: XeTeX encoding problem
Date: Wed, 23 Mar 2016 00:29:04 +0900 (JST)

I've made a patch that improves XeTeX PDF support.
This patch adds PDF table of contents page number link support.

Would you commit it?
Or, may I commit it?

Additionaly,
I'll make @email and @xref, \urefurlonlylinktrue link support for XeTeX.

ChangeLog:

XeTeX PDF TOC page number link support

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

        * doc/texinfo.tex (\pdfgettoks, \pdfaddtokens, \adn, \poptoks, 
        \maketoks, \makelink, \pdflink, \done): New Macro.
        Add XeTeX PDF table of contents page number link support.
--- texinfo.tex.org     2016-03-22 23:56:13.420162400 +0900
+++ texinfo.tex 2016-03-23 00:06:02.766729700 +0900
@@ -1645,6 +1645,32 @@
         /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
     \endgroup}
   \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
+  \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
+  \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
+  \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
+  \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
+  \def\maketoks{%
+    \expandafter\poptoks\the\toksA|ENDTOKS|\relax
+    \ifx\first0\adn0
+    \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
+    \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
+    \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
+    \else
+      \ifnum0=\countA\else\makelink\fi
+      \ifx\first.\let\next=\done\else
+        \let\next=\maketoks
+        \addtokens{\toksB}{\the\toksD}
+        \ifx\first,\addtokens{\toksB}{\space}\fi
+      \fi
+    \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+    \next}
+  \def\makelink{\addtokens{\toksB}%
+    {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
+  \def\pdflink#1{%
+    \special{pdf:bann << /Border [0 0 0]
+      /Type /Annot /Subtype /Link /A << /S /GoTo /D (name#1) >> >>}%
+    \setcolor{\linkcolor}#1\endlink}
+  \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
 %
   %
   % @image support
@@ -5479,7 +5505,14 @@
         % preserve coloured links across page boundaries.  Otherwise the marks
         % would get in the way of \lastbox in \insertindexentrybox.
       \else
-        \hskip\skip\thinshrinkable #1%
+        \ifx\XeTeXrevision\thisisundefined
+          \hskip\skip\thinshrinkable #1%
+        \else
+          \pdfgettoks#1.%
+          \bgroup\let\domark\relax
+            \hskip\skip\thinshrinkable\the\toksA
+          \egroup
+        \fi
       \fi
     \fi
     \egroup % end \boxA
@@ -5614,7 +5647,11 @@
   \ifpdf
     \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
   \else
-    #2
+    \ifx\XeTeXrevision\thisisundefined
+      #2
+    \else
+      \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
+    \fi
   \fi
   \par
 }}

reply via email to

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