]> matita.cs.unibo.it Git - helm.git/blob - helm/software/share/texmf/unicode/ucshyper.sty
Preparing for 0.5.9 release.
[helm.git] / helm / software / share / texmf / unicode / ucshyper.sty
1 %%
2 %% This is file `ucshyper.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% ucs.dtx  (with options: `ucshyper.sty')
8 %% 
9 %% Copyright 2001 Dominique Unruh <dominique@unruh.de>
10 %% 
11 %% This program is provided under the terms of the LaTeX Project Public
12 %% License with some modifications.
13 %% See the file LICENSE (http://www.unruh.de/DniQ/latex/unicode/content/LICENSE)
14 %% for information.
15 %% 
16 \ProvidesPackage{ucshyper}[2002/03/05
17     UCS: Unicode in Hyperref's PDF bookmarks]%
18 \ifx\pdfoutput\undefined
19   \PackageWarning{ucshyper}{ucshyper needs to be run with
20     pdflatex.\MessageBreak Disabling functionality}%
21   \expandafter\endinput\fi
22 \RequirePackage[pdftex,unicode]{hyperref}
23 \newif\ifucshyper@prerender\ucshyper@prerendertrue
24 \newif\ifucshyper@direct\ucshyper@directtrue
25 \DeclareOption{nodirect}{\ucshyper@directfalse}%
26 \DeclareOption{direct}{\ucshyper@directtrue}%
27 \DeclareOption{noprerender}{\ucshyper@prerenderfalse}%
28 \DeclareOption{prerender}{\ucshyper@prerendertrue}%
29 \ProcessOptions*%
30 \newcommand\UCSPU@tmp{}%
31 \newcommand\UCSPU[1]{%
32   \begingroup\let\UCSPU@tmp\relax\relax\ifx\UCSPU@tmp\relax
33     \ifx\utf@viii@map\undefined\else
34       \expandafter\utf@viii@map\expandafter{\number#1}\fi
35     \ifnum#1>"FFFF
36       \PackageError{ucshy}{UCSPU does not support codes greater than
37         \number"FFFF}\fi
38     \@tempcntb#1\divide\@tempcntb by'40000
39     \edef\uc@temp@a{\@backslashchar\number\@tempcntb}%
40     \multiply\@tempcntb by'40000 \@tempcnta#1\advance\@tempcnta by-\@tempcntb
41     \@tempcntb\@tempcnta\divide\@tempcntb by'4000
42     \edef\uc@temp@a{\uc@temp@a\number\@tempcntb}%
43     \multiply\@tempcntb by'4000\advance\@tempcnta by-\@tempcntb
44     \@tempcntb\@tempcnta\divide\@tempcntb by'400
45     \edef\uc@temp@a{\uc@temp@a\number\@tempcntb\@backslashchar}%
46     \multiply\@tempcntb by'400\advance\@tempcnta by-\@tempcntb
47     \@tempcntb\@tempcnta\divide\@tempcntb by'100
48     \edef\uc@temp@a{\uc@temp@a\number\@tempcntb}%
49     \multiply\@tempcntb by'100\advance\@tempcnta by-\@tempcntb
50     \@tempcntb\@tempcnta\divide\@tempcntb by'10
51     \edef\uc@temp@a{\uc@temp@a\number\@tempcntb}%
52     \multiply\@tempcntb by'10\advance\@tempcnta by-\@tempcntb
53     \@tempcntb\@tempcnta
54     \expandafter\xdef\csname UCS2PU\number#1\endcsname{%
55       \uc@temp@a\number\@tempcntb}%
56   \fi\endgroup
57 }
58 \newcommand\ucspu@err[1]{%
59   \csname[*** Insert \string\UCSPU{\number#1}
60   into preamble ***]\endcsname}
61 \@ifundefined{pdfstringdefPreHook}{\let\pdfstringdefPreHook\@empty}{}
62 \g@addto@macro\pdfstringdefPreHook{%
63   \ifucshyper@direct
64     \let\old@unichar\unichar
65     \def\unichar#1{%
66       \expandafter\ifx\csname UCS2PU\number#1\endcsname\relax
67         \ucspu@err{#1}\old@unichar{#1}\else
68         \csname UCS2PU\number#1\endcsname\fi
69       }%
70   \fi
71   \let\selectfont\empty
72   \let\fontencoding\@gobble
73   \let\selectlanguage\@gobble
74   \let\foreignlanguage\@gobble
75   }
76 \let\ucshyper@old@pdfstringdef\pdfstringdef
77 \def\pdfstringdef#1#2{%
78   \ifucshyper@prerender
79     \begingroup
80       \let\old@unichar\unichar
81       \let\uc@output\@gobbletwo
82       \fontencoding{PU}\enc@update
83       \def\unichar##1{\old@unichar{##1}\UCSPU{##1}}%
84       \edef\0{\string\0}%
85       \edef\1{\string\1}%
86       \edef\2{\string\2}%
87       \edef\3{\string\3}%
88       \edef\8{\string\8}%
89       \edef\9{\string\9}%
90       \Hy@pdfstringtrue
91       \PrerenderUnicode{#2}%
92     \endgroup
93   \fi
94   \ucshyper@old@pdfstringdef{#1}{#2}}
95 \newcommand\UCSPUrange[2]{%
96   \count255=#1\relax
97   \loop\ifnum\count255>#2\relax\else
98     \UCSPU{\count255}%
99     \advance\count255 by1\relax
100   \repeat}
101 \@onlypreamble\UCSPUrange