| 1 |
%% |
| 2 |
%% This is file `bidicontour.sty'. |
| 3 |
%% |
| 4 |
%% __________________________________________________ |
| 5 |
%% Copyright © 2014 Vafa Khalighi <[email protected]> |
| 6 |
%% |
| 7 |
%% It may be distributed and/or modified under the LaTeX Project Public License, |
| 8 |
%% version 1.3c or higher (your choice). The latest version of |
| 9 |
%% this license is at: http://www.latex-project.org/lppl.txt |
| 10 |
%% |
| 11 |
%% This work is “author-maintained” (as per LPPL maintenance status) |
| 12 |
%% by Vafa Khalighi. |
| 13 |
%% |
| 14 |
%% |
| 15 |
\NeedsTeXFormat{LaTeX2e} |
| 16 |
\ProvidesPackage{bidicontour} |
| 17 |
[2014/07/14 v0.1 Bidi-aware contoured text] |
| 18 |
\RequirePackage{color} |
| 19 |
\RequirePackage{trig} |
| 20 |
\def\bidicon@coloroff{% |
| 21 |
\def\@undeclaredcolor[##1]##2{}% |
| 22 |
\def\@declaredcolor##1{}% |
| 23 |
} |
| 24 |
\newcommand*\bidicon@put[3]{% |
| 25 |
\if@RTL% |
| 26 |
\llap{\raisebox{#2}[0pt]{#3}\hskip-#1}% |
| 27 |
\else% |
| 28 |
\rlap{\hskip#1\raisebox{#2}[0pt]{#3}}% |
| 29 |
\fi} |
| 30 |
\newcommand*\bidicontourlength[1]{\def\bidicon@base@length{#1}} |
| 31 |
\bidicontourlength{0.03em} |
| 32 |
\newcommand*\bidicontournumber[1]{\def\bidicon@default@copies{#1}} |
| 33 |
\bidicontournumber{16} |
| 34 |
\newlength{\bidicon@length} |
| 35 |
\newcommand*\bidicon@define@copyangles[1]{% |
| 36 |
\edef\bidicon@tempa{auto}% |
| 37 |
\edef\bidicon@tempb{#1}% |
| 38 |
\ifx\bidicon@tempa\bidicon@tempb |
| 39 |
\expandafter\ifdim\f@size pt<15pt\relax |
| 40 |
\edef\bidicon@tempb{16}% |
| 41 |
\else |
| 42 |
\expandafter\ifdim\f@size pt<25pt\relax |
| 43 |
\edef\bidicon@tempb{32}% |
| 44 |
\else |
| 45 |
\expandafter\ifdim\f@size pt<50pt\relax |
| 46 |
\edef\bidicon@tempb{60}% |
| 47 |
\else |
| 48 |
\edef\bidicon@tempb{120}% |
| 49 |
\fi |
| 50 |
\fi |
| 51 |
\fi |
| 52 |
\fi |
| 53 |
\@tempcnta=\bidicon@tempb\relax |
| 54 |
\@ifundefined{bidicon@\number\@tempcnta @copies}{% |
| 55 |
\global\@namedef{bidicon@\number\@tempcnta @copies}{}% |
| 56 |
\@tempdima=360\p@ |
| 57 |
\divide\@tempdima by \@tempcnta |
| 58 |
\@tempdimb=\z@ |
| 59 |
\@tempcntb=\z@ |
| 60 |
\loop |
| 61 |
\ifnum\@tempcntb<\@tempcnta |
| 62 |
\edef\bidicon@temp@fdim{\strip@pt\@tempdimb}% |
| 63 |
\CalculateSin{\bidicon@temp@fdim}% |
| 64 |
\CalculateCos{\bidicon@temp@fdim}% |
| 65 |
\advance\@tempcntb \@ne |
| 66 |
\advance\@tempdimb \@tempdima\relax |
| 67 |
\repeat |
| 68 |
}{}% |
| 69 |
\let\bidicon@tempa\@undefined |
| 70 |
\let\bidicon@tempb\@undefined |
| 71 |
} |
| 72 |
\newcommand*\bidicontour{\@ifstar{\@bidicontour[32]}{\@bidicontour}} |
| 73 |
\newcommand*\@bidicontour[3][\bidicon@default@copies]{% |
| 74 |
\ifvmode |
| 75 |
\leavevmode |
| 76 |
\fi |
| 77 |
\setlength\bidicon@length{\bidicon@base@length}% |
| 78 |
\ifbidicon@outline |
| 79 |
\typeout{bidicontour: Using real outline for `#3'\on@line.}% |
| 80 |
\@bidicontour@outline{#2}{#3}% |
| 81 |
\else |
| 82 |
\if@RTL\mbox{#3}\fi% |
| 83 |
\begingroup |
| 84 |
\bidicon@define@copyangles{#1}% |
| 85 |
\typeout{bidicontour: Using \the\@tempcnta\space copies for `#3'\on@line.}% |
| 86 |
\@tempdima=360\p@ |
| 87 |
\divide\@tempdima by \@tempcnta\relax |
| 88 |
\@tempdimb=\z@ |
| 89 |
\@tempcntb=\z@ |
| 90 |
\color{#2}% |
| 91 |
\bidicon@coloroff |
| 92 |
\loop |
| 93 |
\ifnum\@tempcntb<\@tempcnta\relax |
| 94 |
\edef\bidicon@temp@fdim{\strip@pt\@tempdimb}% |
| 95 |
\bidicon@put |
| 96 |
{\UseSin{\bidicon@temp@fdim}\bidicon@length}% |
| 97 |
{\UseCos{\bidicon@temp@fdim}\bidicon@length}% |
| 98 |
{#3}% |
| 99 |
\advance\@tempcntb \@ne\relax |
| 100 |
\advance\@tempdimb\@tempdima\relax |
| 101 |
\repeat |
| 102 |
\endgroup |
| 103 |
\if@RTL\else\mbox{#3}\fi% |
| 104 |
\fi |
| 105 |
} |
| 106 |
\newcommand*\@bidicontour@outline[2]{% |
| 107 |
\if@RTL\mbox{#2}\fi% |
| 108 |
\begingroup |
| 109 |
\setlength\bidicon@length{2\bidicon@length}% |
| 110 |
\setlength\bidicon@length{0.99626400996\bidicon@length}% |
| 111 |
\color{#1}% |
| 112 |
\bidicon@coloroff |
| 113 |
\beginL\special{% |
| 114 |
pdf:code |
| 115 |
q |
| 116 |
1 j |
| 117 |
1 J |
| 118 |
1 Tr |
| 119 |
\strip@pt\bidicon@length\space w |
| 120 |
}% |
| 121 |
\rlap{\if@RTL\beginR\fi #2\if@RTL\endR\fi}% |
| 122 |
\special{% |
| 123 |
pdf:code |
| 124 |
Q |
| 125 |
}\endL% |
| 126 |
\endgroup |
| 127 |
\if@RTL\else\mbox{#2}\fi% |
| 128 |
} |
| 129 |
\newif\ifbidicon@outline |
| 130 |
\DeclareOption{auto}{\bidicontournumber{auto}} |
| 131 |
\DeclareOption{outline}{\bidicon@outlinetrue} |
| 132 |
\DeclareOption{copies}{\bidicon@outlinefalse} |
| 133 |
\InputIfFileExists{bidicontour.cfg}{% |
| 134 |
\typeout{Loading configuration file `bidicontour.cfg'.}% |
| 135 |
}{% |
| 136 |
\typeout{No configuration file `bidicontour.cfg' found.}% |
| 137 |
} |
| 138 |
\ProcessOptions\relax |
| 139 |
\endinput |
| 140 |
%% |
| 141 |
%% End of file `bidicontour.sty'. |