diff options
author | Karl Berry <karl@freefriends.org> | 2013-05-20 22:01:05 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-05-20 22:01:05 +0000 |
commit | d1a5a7d850a8c705d97d7e531551efc651b372e7 (patch) | |
tree | 44f42e6a8584e4a3f665c74480b42d93d7fbf7c5 /Master/texmf-dist/tex | |
parent | cf085a356fa83e6b5774102207a9b6ea804931d5 (diff) |
csplain (20may13)
git-svn-id: svn://tug.org/texlive/trunk@30594 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/csplain/opmac/opmac.tex | 14 | ||||
-rw-r--r-- | Master/texmf-dist/tex/csplain/opmac/pdfuni.tex | 182 |
2 files changed, 191 insertions, 5 deletions
diff --git a/Master/texmf-dist/tex/csplain/opmac/opmac.tex b/Master/texmf-dist/tex/csplain/opmac/opmac.tex index 71833814afc..42dc999a998 100644 --- a/Master/texmf-dist/tex/csplain/opmac/opmac.tex +++ b/Master/texmf-dist/tex/csplain/opmac/opmac.tex @@ -5,7 +5,7 @@ %% The history of versions is at the end of this file, after \endpinput \ifx\OPmacversion\undefined \else \endinput \fi -\def\OPmacversion{Apr. 2013} +\def\OPmacversion{May 2013} \immediate\write16{This is OPmac (Olsak's Plain macros), version <\OPmacversion>} @@ -971,7 +971,7 @@ %%%%%%%%%%%%%% Outlines -- sec. 3.17 in opmac-d.pdf -\def\outlines#1{\openref\ifx\toclist\empty +\def\outlines#1{\pdfcatalog{/PageMode/UseOutlines}\openref\ifx\toclist\empty \opwarning{\noexpand\outlines -- data unavailable. TeX me again}% \else {\let\tocline=\outlinesA @@ -1014,7 +1014,7 @@ \fi } \def\toasciidata{% Removes Czech+Slovak accents - AA\'AA\"AA\'aa\" aaBBCC\v CC\v ccDD\v DD\v ddEE\'EE\v EE\'ee\v ee% + AA\'AA\"AA\'aa\"aaBBCC\v CC\v ccDD\v DD\v ddEE\'EE\v EE\'ee\v ee% FFGGHHII\'II\'iiJJKKLL\'LL\v LL\'ll\v llMMNN\v NN\v nnOO\'OO\"OO\^OO% \'oo\"oo\^ooPPQQRR\v RR\v rrSS\v SS\v ssTT\v TT\v ttUU\'UU\"UU\r UU% \'uu\"uu\r uuVVWWXXYY\'YY\'yyZZ\v ZZ\v zz% @@ -1511,6 +1511,7 @@ \newdimen\pgwidth \newdimen\pgheight \pgwidth=0pt \newdimen\shiftoffset +\newif\ifmarginshook \marginshookfalse \def\margins/#1 #2 (#3,#4,#5,#6)#7 {\def\tmp{#7}% \ifx\tmp\empty @@ -1537,10 +1538,11 @@ \advance\vsize -#5\tmp \advance\vsize -#6\tmp \advance\voffset #5\tmp \fi\fi - \if 1#1\else \if 2#1% double-page layout + \if 1#1\shiftoffset=0pt \else \if 2#1% double-page layout \shiftoffset=\pgwidth \advance\shiftoffset -\hsize \advance\shiftoffset -2\hoffset \advance\shiftoffset -2in - \addto\pghook{\ifodd\pageno \else \advance\hoffset \shiftoffset \fi} + \ifmarginshook \else \marginshooktrue + \addto\pghook{\ifodd\pageno \else \advance\hoffset \shiftoffset \fi}\fi \else \opwarning{use \string\margins/1 or \string\margins/2}% \fi\fi\fi } @@ -1592,6 +1594,8 @@ Apr. 2013 \table in \table allowed, \catcode`\|=12 set in \table. \printsec(c): \ifnum\lastpenalty added. \urlink: ``~ removing'' corrected {\em text}\macro error corrected. +May 2013 \margins (2pages laylout) can be redefined by new \margins + \outlines use \pdfcatalog{/PageMode/UseOutlines} %%%%%%%%%%%%%% End of opmac.tex diff --git a/Master/texmf-dist/tex/csplain/opmac/pdfuni.tex b/Master/texmf-dist/tex/csplain/opmac/pdfuni.tex new file mode 100644 index 00000000000..302d5ac940e --- /dev/null +++ b/Master/texmf-dist/tex/csplain/opmac/pdfuni.tex @@ -0,0 +1,182 @@ +% pdfuni.tex +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Petr Olsak, 2013 + +% OPmac converts the Czech/Slovak texts for PDFoutlines to ASCII (removes accents) +% because this is more robust and PDFencoding is incompatible with +% Czech/Slovak alphabet. If you dislike this behavior, you can write: +% +% \input opmac +% \input pdfuni +% +% Now, the \outlines<num> macro generates Czech/Slovak texts with accents. +% The Unicode Encoding is used internally here. +% +% For more information about the implemetation and the posibilities of +% setting more converted characters (not only Czech/Slovak) see the end of +% this file (after \endinput command) + + +\def\tmp#1#2\end{\if$#2$\else + \errmessage {This file is UTF-8 encoded. Use TeX+encTeX or 16bit TeX engine.}\fi}% +\tmp č\end + +\ifx\tmpnum\undefined \csname newcount\endcsname\tmpnum \fi +{\lccode`\?=`\\ \lowercase{\gdef\Bslash{?}}} + +\edef\pdfunichars{\Bslash() + ÁáÄäČčĎď ÉéĚěÍíĹĺ ĽľŇňÓóÖö ÔôŔŕŘřŠš ŤťÚúŮůÜü ÝýŽž +} +\def\pdfunicodes {\or00134\or00050\or00051\or % \ () + 00301\or00341\or00304\or00344\or01014\or01015\or01016\or01017\or % ÁáÄäČčĎď + 00311\or00351\or01032\or01033\or00315\or00355\or01071\or01072\or % ÉéĚěÍíĹĺ + 01075\or01076\or01107\or01110\or00323\or00363\or00326\or00366\or % ĽľŇňÓóÖö + 00324\or00364\or01124\or01125\or01130\or01131\or01140\or01141\or % ÔôŔŕŘřŠš + 01144\or01145\or00332\or00372\or01156\or01157\or00334\or00374\or % ŤťÚúŮůÜü + 00335\or00375\or01175\or01176% % ÝýŽž +} +\def\pdfunipre {\def\TeX{TeX}\def\LaTeX{LaTeX}\def~{ }\def\ { }% + \let\ss\relax \let\l\relax \let\L\relax + \let\ae\relax \let\oe\relax \let\AE\relax \let\OE\relax + \let\o\relax \let\O\relax \let\i\relax \let\j\relax \let\aa\relax \let\AA\relax + \let\S\relax \let\P\relax \let\copyright\relax + \let\dots\relax \let\dag\relax \let\ddag\relax + \let\clqq\relax \let\crqq\relax \let\flqq\relax \let\frqq\relax + \let\promile\relax \let\euro\relax + \def\\{\Bslash}\let\{\relax \let\}\relax + \def\${\string^^24}\def\&{\string&}\def\_{\string_}\def\~{\string~}% +} +\def\pdfunipost {\odef\ss000337 \odef\l001102 \odef\L001101 + \odef\AE000306 \odef\ae000346 \odef\OE001122 \odef\oe001123 + \odef\o000370 \odef\O000330 \odef\aa000345 \odef\AA000305 + \odef\i001061 \odef\j002067 \odef\S000247 \odef\P000266 + \odef\copyright000251 \odef\dots040046 \odef\dag040040 \odef\ddag040041 + \odef\clqq040033 \odef\crqq040034 \odef\flqq000253 \odef\frqq000273 + \odef\promile040060 \odef\euro040254 \odef\{000173 \odef\}000175 \odef\#000043 +} +\def\pdfinitcode{\Bslash376\Bslash377} +\def\pdfspacecode{\Bslash000\Bslash040} +\def\pdfcircumflexcode{\Bslash000\Bslash136} +\def\pdflowlinecode{\Bslash000\Bslash137} + +\def\pdfunidef#1#2{\bgroup \def\tmpa{\noexpand#1}% + \pdfunipre \edef\tmp{#2}\edef\out{\pdfinitcode}% + \def\odef##1##2##3##4##5##6##7 + {\def##1{&\edef\out{\out\Bslash##2##3##4\Bslash##5##6##7}}}\pdfunipost + \def\insertbslashes ##1##2##3##4##5{\Bslash0##1##2\Bslash##3##4##5}% + \def\gobbletwowords ##1 ##2 {}% + \tmpnum=0 + \loop + \sfcode\tmpnum=0 \advance\tmpnum by1 + \ifnum\tmpnum<128 \repeat + \tmpnum=0 + \expandafter \pdfunidefA \pdfunichars {}% +} +\def\pdfunidefA #1{\if\relax#1\relax% + \def\next{\let\next= }\afterassignment\pdfunidefB \expandafter\next\tmp\end + \else \advance\tmpnum by1 \sfcode`#1=\tmpnum \expandafter \pdfunidefA + \fi +} +\def\pdfunidefB {% + \ifcat x\noexpand\next \pdfunidefC + \else \ifcat .\noexpand\next \pdfunidefC + \else \ifcat\noexpand\next\space \edef\out{\out\pdfspacecode}% + \else \ifcat^\noexpand\next \edef\out{\out\pdfcircumflexcode}% + \else \ifcat_\noexpand\next \edef\out{\out\pdflowlinecode}% + \else \expandafter\ifx\expandafter&\next + \fi\fi\fi\fi\fi\fi + \ifx\next\end \edef\next{\def\tmpa{\out}}\expandafter\egroup\next \else + \def\next{\let\next= }\afterassignment\pdfunidefB \expandafter\next + \fi +} +\def\pdfunidefC {\edef\tmp{\expandafter\gobbletwowords\meaning\next}\edef\out{\out\pdfunidefD}} +\def\pdfunidefD{% + \ifnum\sfcode\expandafter`\tmp=0 \Bslash 000\tmp + \else + \expandafter \insertbslashes \ifcase \sfcode\expandafter`\tmp \pdfunicodes + \else 000077\fi + \fi +} +\def\cnvhook #1#2{#2\pdfunidef\tmp\tmp} % the default convertor in OPmac is + % redefined here +\endinput + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +There are only two encodings for PDF strings (used in PDFoutlines, PDFinfo +etc.). First one is PDFDocEncoding which is one-byte encoding, but most +Czech or Slovak characters are missing here. This is the reason, why OPmac +converts these strings to ASCII. + +The second encoding is PDFunicode encoding wich is implemented in this file for +Czech and Slovak languages. This encoding is TeX-dicomfortable, because it +looks like + +\376\377\000C\000v\000i\001\015\000e\000n\000\355\000\040\000j\000e\000\040 +\000z\000\341\000t\001\033\001\176 + +This example is real encoding of the string "Cvičení je zátěž". You can see +that this is UTF-16 encoding (two bytes per character) with two starting +bytes FEFF. Moreover, each byte is encoded by three octal digits preceded by +backslash. The only exception is the visible ASCII character encoding: such +a character is encoded by its real byte preceded by \000. + +The pdfuni.tex macro implements the command + +\pdfunidef\macro{string} + +which defines \macro and stores the PDFunicode encoded string into it +(backslashes are with catcode 12 here). + +The main conversion bijective function are declared by two macros +\pdfunichars and \pdfunicodes. The number of non-space tokens in +\pdfunichars must be the same as the number of codes in \pdfunicodes. +Each character corresponds to its code in the same order. The codes have +first trailing zero and backlashes missing, ie. the 00301 means the real code +\000\301 or the 01140 means \001\140. The codes are separated by \or +primitive. The characters with internal code < 128 and not listed in +\pdfunichars are treated as ASCII character, i.e. they are converted +to \000<char>. Other undefined characters are converted to \000\077, +which is question mark. + +User can enlarge the encoding table by \addto command (defined in opmac). +The following example adds the Ë and ë characters: + +\addto\pdfunichars{Ëë} \addto\pdfinicodes{\or00313\or00353} + +The converted string is expanded (in the group). The \pdfunipre is preceeded +before such expansion. The re-definition of logos (like \TeX, \LaTeX) is +placed here. The macros which we need to convert to cpecial code (like \ae) +is \let as \relax here. The code of such macro is defined by +\odef\ae<6-digit-code><space> in the \pdfunipost list (\odef means +``octal-def'' here). User can add next macros to \pdfunipre and \pdfunipost +lists by \addto command. Example: + +\addto\pdfunipre{\let\endash\relax} \addto\pdfunipost{\odef\endash040023 } + +This example makes possibility to convert \endash to \040\023. + +Notice for encTeX users: New UTF-8 input codes can be mapped by encTeX to +the control sequences. You can define the PDFunicode output of such +sequences in order to these charaters work properly on PDFoutlines. The +following example solves the character ñ which is not the part of +Czech/Slovak alphabet. + +\mubyte \ntilde ^^c3^^b1\endmubyte +\def\ntilde{\~n} +\addto\pdfunipre{\let\ntilde\relax} \addto\pdfunipost{\odef\ntilde000361 } + +What you need to know: the ntilde character is U+00F1 with its UTF-8 code +0xC3 0xB1 and with its UTF-16 code \000\361 typed in octal encoding. + +For more information see the article ``PDFuni -- akcenty v PDF záložkách'' +written in Czech (file pdfuni-article.tex,pdf). + +-------------- + +Versions: + +May 2013: Released + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end of the file pdfuni.tex |