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