| 1 |
% Copyright (c) 2003-2021 Vladimir Volovich <[email protected]> |
| 2 |
% cmap package -- download CMap files into PDF |
| 3 |
% to make "search" and "copy-and-paste" functions work properly |
| 4 |
% You may distribute and/or modify this program under the terms of LPPL |
| 5 |
% the program consists of cmap.sty and {t1,t2a,t2b,t2c,t5,ot1,ot1tt,lae,lfe}.cmap |
| 6 |
% Usage: put \usepackage{cmap} immediately after the \documentclass line |
| 7 |
% Thanks to: |
| 8 |
% Han The Thanh |
| 9 |
% Maxim I. Tishin |
| 10 |
% Petr Sojka |
| 11 |
% Werner Lemberg |
| 12 |
% Oleg Katsitadze |
| 13 |
|
| 14 |
\ProvidesPackage{cmap}[2021/02/06 v1.0j CMap support: searchable PDF] |
| 15 |
|
| 16 |
\DeclareOption{resetfonts}{% |
| 17 |
\@for\reserved@a:=% |
| 18 |
OT1/cmr/m/n/5,OT1/cmr/m/n/7,OT1/cmr/m/n/10,% |
| 19 |
OML/cmm/m/it/5,OML/cmm/m/it/7,OML/cmm/m/it/10,% |
| 20 |
OMS/cmsy/m/n/5,OMS/cmsy/m/n/7,OMS/cmsy/m/n/10,% |
| 21 |
OMX/cmex/m/n/10% |
| 22 |
\do{% |
| 23 |
\expandafter\let\csname\reserved@a\endcsname\relax |
| 24 |
}% |
| 25 |
} |
| 26 |
\ProcessOptions |
| 27 |
|
| 28 |
\@ifundefined{pdffontattr}{% |
| 29 |
\@ifundefined{pdfextension}{% |
| 30 |
% The cmap package can be used only with pdflatex and lualatex, |
| 31 |
% but not with ordinary latex |
| 32 |
\PackageWarningNoLine{cmap}{pdftex not detected - exiting}% |
| 33 |
\endinput |
| 34 |
}{% |
| 35 |
\protected\def\cmap@pdfobj{\pdfextension obj }% |
| 36 |
\protected\def\cmap@fontattr{\pdfextension fontattr }% |
| 37 |
\def\cmap@lastobj{\number\pdffeedback lastobj \space 0 R}% |
| 38 |
}% |
| 39 |
}{% |
| 40 |
\let\cmap@pdfobj\pdfobj |
| 41 |
\let\cmap@fontattr\pdffontattr |
| 42 |
\def\cmap@lastobj{\number\pdflastobj\space 0 R}% |
| 43 |
} |
| 44 |
|
| 45 |
\@ifundefined{pdfoutput}{% |
| 46 |
\ifnum\outputmode<1 |
| 47 |
}{% |
| 48 |
\ifnum\pdfoutput<1 |
| 49 |
}% |
| 50 |
\PackageWarningNoLine{cmap}{pdftex in DVI mode - exiting} |
| 51 |
\expandafter\endinput |
| 52 |
\fi |
| 53 |
|
| 54 |
\edef\reserved@a{\noexpand\in@{,fontenc.sty,}{\@filelist}}% enc.def |
| 55 |
\reserved@a |
| 56 |
\ifin@ |
| 57 |
\PackageWarningNoLine{cmap}{fontenc already loaded - some fonts may be unprocessed} |
| 58 |
\fi |
| 59 |
%\@ifpackageloaded{babel}{% |
| 60 |
%\PackageWarningNoLine{cmap}{babel already loaded - some fonts may be unprocessed}% |
| 61 |
%}\relax |
| 62 |
|
| 63 |
\@ifundefined{pdfnobuiltintounicode}{% |
| 64 |
\@ifundefined{pdfgentounicode}\relax{% |
| 65 |
\pdfgentounicode=0 |
| 66 |
}% |
| 67 |
\protected\def\cmap@nobuiltintounicode{% |
| 68 |
\expandafter\@gobble\the |
| 69 |
}% |
| 70 |
}{% |
| 71 |
\let\cmap@nobuiltintounicode\pdfnobuiltintounicode |
| 72 |
} |
| 73 |
|
| 74 |
\def\extract@font{% |
| 75 |
\get@external@font |
| 76 |
\global\expandafter\font\font@name\external@font\relax |
| 77 |
\font@name\relax |
| 78 |
\cmap@hook |
| 79 |
\csname\f@encoding+\f@family\endcsname |
| 80 |
\csname\curr@fontshape\endcsname |
| 81 |
\relax |
| 82 |
} |
| 83 |
\def\cmap@load{% |
| 84 |
\edef\reserved@f{\lowercase{\def\noexpand\reserved@f{\cmap@[email protected]}}}% |
| 85 |
\reserved@f |
| 86 |
\IfFileExists{\reserved@f}{% |
| 87 |
\immediate\cmap@pdfobj stream |
| 88 |
%attr {/Type /CIDFile} |
| 89 |
file {\reserved@f}% |
| 90 |
\expandafter\xdef\csname cmap@set@\cmap@f@encoding\endcsname{% |
| 91 |
\cmap@nobuiltintounicode\noexpand\font@name |
| 92 |
\noexpand\expandafter\cmap@fontattr\noexpand\font@name{/ToUnicode \cmap@lastobj}}% |
| 93 |
}{% |
| 94 |
\global\expandafter\let\csname cmap@set@\cmap@f@encoding\endcsname\empty |
| 95 |
}% |
| 96 |
} |
| 97 |
\def\cmap@test@tt{% |
| 98 |
\ifdim\fontdimen3\font@name=\z@ |
| 99 |
\ifdim\fontdimen4\font@name=\z@ |
| 100 |
\begingroup |
| 101 |
\ifdim\fontcharwd\font@name`\i=\fontcharwd\font@name`\w |
| 102 |
\edef\reserved@f{\lowercase{\def\noexpand\reserved@f{\cmap@f@encoding tt.cmap}}}% |
| 103 |
\reserved@f |
| 104 |
\IfFileExists{\reserved@f}{\xdef\cmap@f@encoding{\cmap@f@encoding tt}}\relax |
| 105 |
\fi |
| 106 |
\endgroup |
| 107 |
\fi |
| 108 |
\fi |
| 109 |
} |
| 110 |
\def\cmap@hook{% |
| 111 |
\@ifundefined{CJK@plane}{% |
| 112 |
\edef\cmap@f@encoding{\f@encoding}% |
| 113 |
}{% |
| 114 |
\edef\cmap@f@encoding{\f@encoding\CJK@plane}% |
| 115 |
}% |
| 116 |
\cmap@test@tt |
| 117 |
\@ifundefined{cmap@set@\cmap@f@encoding}{\cmap@load}\relax |
| 118 |
\csname cmap@set@\cmap@f@encoding\endcsname |
| 119 |
} |
| 120 |
|
| 121 |
\endinput |