-
Notifications
You must be signed in to change notification settings - Fork 0
/
tc-xetex.def
145 lines (145 loc) · 4.73 KB
/
tc-xetex.def
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
142
143
144
145
% \begin{macrocode}
%<!COPYRIGHT>
\ProvidesFile{tc-xetex.def}[2019/01/04 v2.2 Clipping driver for xetex]
% \end{macrocode}
%
% \begin{macro}{\@cliptoboxdim}
% Clips to official box dimension.
%
% The following clipping code was suggested by
% Joseph Wright (LaTeX3 project), but slightly modified
% for this package.
% \begin{macrocode}
\def\@cliptoboxdim#1{%
\setbox#1=\hbox{%
\adjcalc@settobp\WIDTH{\wd#1}%
\adjcalc@settobp\DEPTH{\dp#1}%
\adjcalc@settobp\TOTALHEIGHT{\ht#1+\dp#1}%
\special{pdf:content q }%
\special{pdf:code 0 -\DEPTH \WIDTH \TOTALHEIGHT re W n }%
\special{pdf:literal direct -1 0 0 -1 0 0 cm }%
\special{pdf:content q }%
\special{pdf:literal direct -1 0 0 -1 0 0 cm }%
\hbox to 0 pt{\copy#1\hss}%
\special{pdf:literal direct Q }%
\special{pdf:literal direct Q }%
\hskip\wd#1%
}%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@clip@bpdimens}[5]{<box register}{<upper left>}{<upper right>}{<lower left>}{<lower right>}
% \begin{macrocode}
\def\@clip@bpdimens#1#2#3#4#5{%
\adjcalc@settobp\TOTALHEIGHT{\ht#1+\dp#1}%
\adjcalc@settobp\HEIGHT{\ht#1}%
\adjcalc@settobp\DEPTH{-\dp#1}%
\adjcalc@settobp\WIDTH{\wd#1}%
\adjcalc@settobp\RADIUSTL{#2}%
\adjcalc@settobp\RADIUSTR{#3}%
\adjcalc@settobp\RADIUSBL{#4}%
\adjcalc@settobp\RADIUSBR{#5}%
\adjcalc@settobp\RADIUSTLb{\tc@bezfacn#2}%
\adjcalc@settobp\HEIGHTmRADIUSTL{\ht#1-#2}%
\adjcalc@settobp\HEIGHTmRADIUSTLb{\ht#1-\tc@bezfacn#2}%
\adjcalc@settobp\HEIGHTmRADIUSTR{\ht#1-#3}%
\adjcalc@settobp\HEIGHTmRADIUSTRb{\ht#1-\tc@bezfacn#3}%
\adjcalc@settobp\WIDTHmRADIUSTR{\wd#1-#3}%
\adjcalc@settobp\WIDTHmRADIUSTRb{\wd#1-\tc@bezfacn#3}%
\adjcalc@settobp\RADIUSBRmDEPTH{#5-\dp#1}%
\adjcalc@settobp\RADIUSBRmDEPTHb{\tc@bezfacn#5-\dp#1}%
\adjcalc@settobp\WIDTHmRADIUSBR{\wd#1-#5}%
\adjcalc@settobp\WIDTHmRADIUSBRb{\wd#1-\tc@bezfacn#5}%
\adjcalc@settobp\RADIUSBLmDEPTH{#4-\dp#1}%
\adjcalc@settobp\RADIUSBLmDEPTHb{\tc@bezfacn#4-\dp#1}%
\adjcalc@settobp\RADIUSBLb{\tc@bezfacn#4}%
\adjcalc@settobp\LINEWIDTH{\fboxrule}%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@clip@roundedbox@pdfcode}
% \begin{macrocode}
\def\@clip@roundedboxpath@pdfcode{%
0 \HEIGHTmRADIUSTL m
0 \HEIGHTmRADIUSTLb \RADIUSTLb \HEIGHT \RADIUSTL \HEIGHT c
\WIDTHmRADIUSTR \HEIGHT l
\WIDTHmRADIUSTRb \HEIGHT \WIDTH \HEIGHTmRADIUSTRb \WIDTH \HEIGHTmRADIUSTR c
\WIDTH \RADIUSBRmDEPTH l
\WIDTH \RADIUSBRmDEPTHb \WIDTHmRADIUSBRb \DEPTH \WIDTHmRADIUSBR \DEPTH c
\RADIUSBL \DEPTH l
\RADIUSBLb \DEPTH 0 \RADIUSBLmDEPTHb 0 \RADIUSBLmDEPTH c
0 \RADIUSBLmDEPTH l
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\@clipcornersofbox}[5]{<box register}{<upper left>}{<upper right>}{<lower left>}{<lower right>}
% Clips round corners off.
% \begin{macrocode}
\def\@clipcornersofbox#1#2#3#4#5{%
\setbox#1=\hbox{%
\@clip@bpdimens{#1}{#2}{#3}{#4}{#5}%
\special{pdf:content q }%
\special{pdf:literal direct
\@clip@roundedboxpath@pdfcode
h W n
}%
\special{pdf:literal direct -1 0 0 -1 0 0 cm }%
\special{pdf:content q }%
\special{pdf:literal direct -1 0 0 -1 0 0 cm }%
\hbox to 0pt{\copy#1\hss}%
\special{pdf:literal direct Q }%
\special{pdf:literal direct Q }%
\hskip\wd#1%
}%
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\@rndframearoundbox}[6]{<box register}{<upper left>}{<upper right>}{<lower left>}{<lower right>}{<clip>}
% Round frame around a box.
% \begin{macrocode}
\def\@rndframearoundbox#1#2#3#4#5#6{%
\setbox#1=\hbox{%
\adjsetlength\@tempdima{\fboxsep+.5\fboxrule}%
\@marginbox#1\@tempdima\@tempdima\@tempdima\@tempdima%
\@clip@bpdimens{#1}{#2}{#3}{#4}{#5}%
\edef\@tempa{#6}%
\ifx\@empty\@tempa\else
\@clipcornersofbox{#1}{#2}{#3}{#4}{#5}%
\fi
%
\hbox to 0pt{\copy#1\hss}%
\hbox to 0pt{%
\color@setgroup
\adjbox@rndframe@color
\special{pdf:content q }%
\special{pdf:literal direct
\LINEWIDTH w
\@clip@roundedboxpath@pdfcode
h s
}%
\special{pdf:literal direct -1 0 0 -1 0 0 cm }%
\special{pdf:content q }%
\special{pdf:literal direct -1 0 0 -1 0 0 cm }%
\special{pdf:literal direct Q }%
\special{pdf:literal direct Q }%
\color@endgroup
}%
\hskip\wd#1%
}%
\adjsetlength\@tempdima{.5\fboxrule}%
\@marginbox#1\@tempdima\@tempdima\@tempdima\@tempdima%
}
% \end{macrocode}
% \end{macro}
%
%^^A vim: ft=tex