summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/cmap/cmap.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/cmap/cmap.sty')
-rw-r--r--macros/latex/contrib/cmap/cmap.sty94
1 files changed, 94 insertions, 0 deletions
diff --git a/macros/latex/contrib/cmap/cmap.sty b/macros/latex/contrib/cmap/cmap.sty
new file mode 100644
index 0000000000..87a0361d20
--- /dev/null
+++ b/macros/latex/contrib/cmap/cmap.sty
@@ -0,0 +1,94 @@
+% Copyright (c) 2003-2008 Vladimir Volovich <vvv@vsu.ru>
+% cmap package -- download CMap files into PDF
+% to make "search" and "copy-and-paste" functions work properly
+% You may distribute and/or modify this program under the terms of LPPL
+% the program consists of cmap.sty and {t1,t2a,t2b,t2c,t5,ot1,ot1tt,lae,lfe}.cmap
+% Usage: put \usepackage{cmap} immediately after the \documentclass line
+% Thanks to:
+% Han The Thanh
+% Maxim I. Tishin
+% Petr Sojka
+% Werner Lemberg
+% Oleg Katsitadze
+
+\ProvidesPackage{cmap}[2008/03/06 v1.0h CMap support: searchable PDF]
+
+\DeclareOption{resetfonts}{%
+ \@for\reserved@a:=%
+ OT1/cmr/m/n/5,OT1/cmr/m/n/7,OT1/cmr/m/n/10,%
+ OML/cmm/m/it/5,OML/cmm/m/it/7,OML/cmm/m/it/10,%
+ OMS/cmsy/m/n/5,OMS/cmsy/m/n/7,OMS/cmsy/m/n/10,%
+ OMX/cmex/m/n/10%
+ \do{%
+ \expandafter\let\csname\reserved@a\endcsname\relax
+ }%
+}
+\ProcessOptions
+
+\@ifundefined{pdffontattr}{%
+% The cmap package can be used only with pdflatex,
+% but not with ordinary latex
+ \PackageWarningNoLine{cmap}{pdftex not detected - exiting}%
+ \endinput
+}\relax
+\ifnum\pdfoutput<1
+ \PackageWarningNoLine{cmap}{pdftex in DVI mode - exiting}
+ \expandafter\endinput
+\fi
+
+\edef\reserved@a{\noexpand\in@{,fontenc.sty,}{\@filelist}}% enc.def
+\reserved@a
+\ifin@
+\PackageWarningNoLine{cmap}{fontenc already loaded - some fonts may be unprocessed}
+\fi
+%\@ifpackageloaded{babel}{%
+%\PackageWarningNoLine{cmap}{babel already loaded - some fonts may be unprocessed}%
+%}\relax
+
+\def\extract@font{%
+ \get@external@font
+ \global\expandafter\font\font@name\external@font\relax
+ \font@name\relax
+ \cmap@hook
+ \csname\f@encoding+\f@family\endcsname
+ \csname\curr@fontshape\endcsname
+ \relax
+}
+\def\cmap@load{%
+ \edef\reserved@f{\lowercase{\def\noexpand\reserved@f{\cmap@f@encoding.cmap}}}%
+ \reserved@f
+ \IfFileExists{\reserved@f}{%
+ \immediate\pdfobj stream
+ %attr {/Type /CIDFile}
+ file {\reserved@f}%
+ \expandafter\xdef\csname cmap@set@\cmap@f@encoding\endcsname{%
+ \noexpand\expandafter\pdffontattr\noexpand\font@name{/ToUnicode \the\pdflastobj\space 0 R}}%
+ }{%
+ \global\expandafter\let\csname cmap@set@\cmap@f@encoding\endcsname\empty
+ }%
+}
+\def\cmap@test@tt{%
+ \ifdim\fontdimen3\font@name=\z@
+ \ifdim\fontdimen4\font@name=\z@
+ \begingroup
+ \ifdim\fontcharwd\font@name`\i=\fontcharwd\font@name`\w
+ \edef\reserved@f{\lowercase{\def\noexpand\reserved@f{\cmap@f@encoding tt.cmap}}}%
+ \reserved@f
+ \IfFileExists{\reserved@f}{\xdef\cmap@f@encoding{\cmap@f@encoding tt}}\relax
+ \fi
+ \endgroup
+ \fi
+ \fi
+}
+\def\cmap@hook{%
+ \@ifundefined{CJK@plane}{%
+ \edef\cmap@f@encoding{\f@encoding}%
+ }{%
+ \edef\cmap@f@encoding{\f@encoding\CJK@plane}%
+ }%
+ \cmap@test@tt
+ \@ifundefined{cmap@set@\cmap@f@encoding}{\cmap@load}\relax
+ \csname cmap@set@\cmap@f@encoding\endcsname
+}
+
+\endinput