1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Typesetting Macros Initials}
15
16
17
18\unprotect
19
20\registerctxluafile{typodrp}{autosuffix}
21
22\definesystemattribute[initial][public]
23
24\appendtoks
25 \c_attr_initial\attributeunsetvalue
26\to \everyforgetall
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50\installcorenamespace{initial}
51
52\installcommandhandler \??initial {initial} \??initial
53
54\definemeasure[initial:n][\lineheight*\initialparameter\c!n \strutdp]
55
56\setupinitial
57 [\c!location=\v!text,
58 \c!n=3,
59 \c!m=1,
60 \c!method=\v!none,
61 \c!continue=\v!no,
62
63
64 \c!font=Bold cp \measure{initial:n},
65 \c!distance=.125\emwidth,
66 \c!hoffset=\zeropoint,
67 \c!voffset=\v!line,
68 \c!style=,
69 \c!color=,
70 \c!before=\blank]
71
72\permanent\tolerant\protected\def\placeinitial[#1]
73 {\par
74 \namedinitialparameter{#1}\c!before
75 \enforced\edef\typo_initial_handle{\typo_initial_handle_indeed{#1}{}}}
76
77\permanent\tolerant\protected\def\setinitial[#1]#*[#S#2]
78 {\enforced\edef\typo_initial_handle{\typo_initial_handle_indeed{#1}{#2}}}
79
80
81
82
83
84
85
86\permanent\tolerant\protected\def\flushinitial
87 {\typo_initial_handle}
88
89\newconstant \c_initial_lines
90\newconditional\c_initial_synchronize
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109\protected\def\typo_initial_handle_indeed#1#2
110 {\dontleavehmode
111 \begingroup
112 \cdef\currentinitial{#1}
113 \setupcurrentinitial[#2]
114 \resetfontfeature
115 \ifempty{\initialparameter\c!style}
116 \definedfont[\initialparameter\c!font]
117 \else
118 \useinitialstyleparameter\c!style
119 \fi
120 \useinitialcolorparameter\c!color
121 \edef\p_voffset{\initialparameter\c!voffset}
122 \scratchcounter \initialparameter\c!n\relax
123 \scratchvoffset\dimexpr\ifx\p_voffset\v!line\scratchcounter\lineheight\lineheight\else\p_voffset\fi\relax
124 \clf_setinitial
125 location {\initialparameter\c!location}
126 enabled true\space
127 n \scratchcounter
128 m \numexpr\initialparameter\c!m\relax
129 method {\initialparameter\c!method}
130 continue {\initialparameter\c!continue}
131 distance \dimexpr\initialparameter\c!distance\relax
132 hoffset \dimexpr\initialparameter\c!hoffset\relax
133 voffset \scratchvoffset
134 ma \c_attr_colormodel
135 ca \c_attr_color
136 ta \c_attr_transparency
137 font \fontid\font
138 glyphscale \glyphscale
139 dynamic \font_dynamic_value
140 \relax
141 \c_attr_initial\plusone
142 \initialparameter\c!text
143 \normalexpanded{\endgroup\c_initial_lines\the\scratchcounter}
144 \enforced\glettonothing\typo_initial_handle
145 \ifconditional\c_initial_synchronize
146 \appendtoks \forgetinitial \to \everybeforepar
147 \fi}
148
149\lettonothing\typo_initial_handle
150
151\permanent\protected\def\forgetinitial
152 {\ifcase\c_initial_lines\else
153 \begingroup
154 \advanceby\c_initial_lines\prevgraf\relax
155 \ifcase\c_initial_lines\else
156 \obeydepth
157 \forgetall
158 \testpage[\the\c_initial_lines]
159 \dorecurse\c_initial_lines{\nointerlineskip\hpack to \hsize{\strut}\par}
160 \fi
161 \endgroup
162 \c_initial_lines\zerocount
163 \ifconditional\c_initial_synchronize
164 \removetoks \forgetinitial \from \everybeforepar
165 \fi
166 \fi}
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182\installtexexperiment
183 {autoforgetinitials}
184 {\c_initial_synchronize\conditionaltrue}
185 {\c_initial_synchronize\conditionalfalse}
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202\protect \endinput
203 |