]> matita.cs.unibo.it Git - helm.git/blobdiff - share/texmf/unicode/ucshyper.sty
the Matita manual is now convertible to a decent .tex that is processable both
[helm.git] / share / texmf / unicode / ucshyper.sty
diff --git a/share/texmf/unicode/ucshyper.sty b/share/texmf/unicode/ucshyper.sty
new file mode 100644 (file)
index 0000000..000ab35
--- /dev/null
@@ -0,0 +1,101 @@
+%%
+%% This is file `ucshyper.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% ucs.dtx  (with options: `ucshyper.sty')
+%% 
+%% Copyright 2001 Dominique Unruh <dominique@unruh.de>
+%% 
+%% This program is provided under the terms of the LaTeX Project Public
+%% License with some modifications.
+%% See the file LICENSE (http://www.unruh.de/DniQ/latex/unicode/content/LICENSE)
+%% for information.
+%% 
+\ProvidesPackage{ucshyper}[2002/03/05
+    UCS: Unicode in Hyperref's PDF bookmarks]%
+\ifx\pdfoutput\undefined
+  \PackageWarning{ucshyper}{ucshyper needs to be run with
+    pdflatex.\MessageBreak Disabling functionality}%
+  \expandafter\endinput\fi
+\RequirePackage[pdftex,unicode]{hyperref}
+\newif\ifucshyper@prerender\ucshyper@prerendertrue
+\newif\ifucshyper@direct\ucshyper@directtrue
+\DeclareOption{nodirect}{\ucshyper@directfalse}%
+\DeclareOption{direct}{\ucshyper@directtrue}%
+\DeclareOption{noprerender}{\ucshyper@prerenderfalse}%
+\DeclareOption{prerender}{\ucshyper@prerendertrue}%
+\ProcessOptions*%
+\newcommand\UCSPU@tmp{}%
+\newcommand\UCSPU[1]{%
+  \begingroup\let\UCSPU@tmp\relax\relax\ifx\UCSPU@tmp\relax
+    \ifx\utf@viii@map\undefined\else
+      \expandafter\utf@viii@map\expandafter{\number#1}\fi
+    \ifnum#1>"FFFF
+      \PackageError{ucshy}{UCSPU does not support codes greater than
+        \number"FFFF}\fi
+    \@tempcntb#1\divide\@tempcntb by'40000
+    \edef\uc@temp@a{\@backslashchar\number\@tempcntb}%
+    \multiply\@tempcntb by'40000 \@tempcnta#1\advance\@tempcnta by-\@tempcntb
+    \@tempcntb\@tempcnta\divide\@tempcntb by'4000
+    \edef\uc@temp@a{\uc@temp@a\number\@tempcntb}%
+    \multiply\@tempcntb by'4000\advance\@tempcnta by-\@tempcntb
+    \@tempcntb\@tempcnta\divide\@tempcntb by'400
+    \edef\uc@temp@a{\uc@temp@a\number\@tempcntb\@backslashchar}%
+    \multiply\@tempcntb by'400\advance\@tempcnta by-\@tempcntb
+    \@tempcntb\@tempcnta\divide\@tempcntb by'100
+    \edef\uc@temp@a{\uc@temp@a\number\@tempcntb}%
+    \multiply\@tempcntb by'100\advance\@tempcnta by-\@tempcntb
+    \@tempcntb\@tempcnta\divide\@tempcntb by'10
+    \edef\uc@temp@a{\uc@temp@a\number\@tempcntb}%
+    \multiply\@tempcntb by'10\advance\@tempcnta by-\@tempcntb
+    \@tempcntb\@tempcnta
+    \expandafter\xdef\csname UCS2PU\number#1\endcsname{%
+      \uc@temp@a\number\@tempcntb}%
+  \fi\endgroup
+}
+\newcommand\ucspu@err[1]{%
+  \csname[*** Insert \string\UCSPU{\number#1}
+  into preamble ***]\endcsname}
+\@ifundefined{pdfstringdefPreHook}{\let\pdfstringdefPreHook\@empty}{}
+\g@addto@macro\pdfstringdefPreHook{%
+  \ifucshyper@direct
+    \let\old@unichar\unichar
+    \def\unichar#1{%
+      \expandafter\ifx\csname UCS2PU\number#1\endcsname\relax
+        \ucspu@err{#1}\old@unichar{#1}\else
+        \csname UCS2PU\number#1\endcsname\fi
+      }%
+  \fi
+  \let\selectfont\empty
+  \let\fontencoding\@gobble
+  \let\selectlanguage\@gobble
+  \let\foreignlanguage\@gobble
+  }
+\let\ucshyper@old@pdfstringdef\pdfstringdef
+\def\pdfstringdef#1#2{%
+  \ifucshyper@prerender
+    \begingroup
+      \let\old@unichar\unichar
+      \let\uc@output\@gobbletwo
+      \fontencoding{PU}\enc@update
+      \def\unichar##1{\old@unichar{##1}\UCSPU{##1}}%
+      \edef\0{\string\0}%
+      \edef\1{\string\1}%
+      \edef\2{\string\2}%
+      \edef\3{\string\3}%
+      \edef\8{\string\8}%
+      \edef\9{\string\9}%
+      \Hy@pdfstringtrue
+      \PrerenderUnicode{#2}%
+    \endgroup
+  \fi
+  \ucshyper@old@pdfstringdef{#1}{#2}}
+\newcommand\UCSPUrange[2]{%
+  \count255=#1\relax
+  \loop\ifnum\count255>#2\relax\else
+    \UCSPU{\count255}%
+    \advance\count255 by1\relax
+  \repeat}
+\@onlypreamble\UCSPUrange