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\registerctxluafile { font txt }{}
26\registerctxluafile { font phb }{}
27
28\startluacode
29
30 local function processlist ( data )
31 local list = data . list
32 local timings = data . results
33 for i = 1 , # list do
34 local name = list [ i ]
35 local data = timings [ name ]
36 local none = data [ " context none " ] or 0
37 local node = data [ " context node " ] or 0
38 if node > 0 . 1 then
39 context . starttabulate { " |l|c|c|c|c|c| " }
40 context . NC ( ) context . bold ( name )
41 context . NC ( ) context ( [ [ $ t $ ] ] )
42 context . NC ( ) context ( [ [ $ t - t_ { \hbox { \tx none } } $ ] ] )
43 context . NC ( ) context ( [ [ $ t - t_ { \hbox { \tx node } } $ ] ] )
44 context . NC ( ) context ( [ [ $ t / t_ { \hbox { \tx node } } $ ] ] )
45 context . NC ( ) context ( [ [ $ \frac { t - t_ { \hbox { \txx none } } } { t_ { \hbox { \txx node } } - t_ { \hbox { \txx none } } } $ ] ] )
46 context . NC ( ) context . NR ( )
47 context . TL ( )
48 for k , v in table . sortedhash ( data ) do
49 context . NC ( ) context ( k )
50 context . NC ( ) context ( " %0.2f " , v )
51 context . NC ( ) context ( " %0.2f " , v - none )
52 context . NC ( ) context ( " %0.2f " , v - node )
53 context . NC ( ) context ( " %0.2f " , v / node )
54 context . NC ( ) if node ~ = none then context ( " %0.2f " , ( v - none ) / ( node - none ) ) end
55 context . NC ( ) context . NR ( )
56 end
57 context . stoptabulate ( )
58 end
59 end
60 end
61
62 moduledata . plugins = {
63 processlist = processlist ,
64 }
65
66\stopluacode
67
68\continueifinputfile { m fonts plugins . mkiv }
69
70\usemodule [ art 0 1 ]
71
72\starttext
73
74\edef \tufte { \cldloadfile { tufte . tex }}
75\edef \khatt { \cldloadfile { khatt ar . tex }}
76
77\startbuffer [ latin definitions ]
78\definefont [ TestA ][ Serif * test ]
79\definefont [ TestB ][ SerifItalic * test ]
80\definefont [ TestC ][ SerifBold * test ]
81\stopbuffer
82
83\startbuffer [ latin text ]
84\TestA \tufte \par
85\TestB \tufte \par
86\TestC \tufte \par
87\dorecurse { 1 0 } {
88 \TestA Fluffy Test Font A
89 \TestB Fluffy Test Font B
90 \TestC Fluffy Test Font C
91} \par
92\stopbuffer
93
94\startbuffer [ arabic definitions ]
95\definedfont [ Arabic * test at 1 4 pt ]
96\setupinterlinespace [ line = 1 8 pt ]
97\setupalign [ r 2 l ]
98\stopbuffer
99
100\startbuffer [ arabic text ]
101\dorecurse { 1 0 } {
102 \khatt \space
103 \khatt \space
104 \khatt
105 \blank
106}
107\stopbuffer
108
109\startbuffer [ mixed definitions ]
110\definefont [ TestL ][ Serif * test ]
111\definefont [ TestA ][ Arabic * test at 1 4 pt ]
112\setupinterlinespace [ line = 1 8 pt ]
113\setupalign [ r 2 l ]
114\stopbuffer
115
116\startbuffer [ mixed text ]
117\dorecurse { 2 } {
118 { \TestA \khatt \space \khatt \space \khatt }
119 { \TestL \lefttoright \tufte }
120 \blank
121 \dorecurse { 1 0 }{
122 { \TestA وَ قَرْمِطْ بَيْنَ الْحُرُوفِ؛ فَإِنَّ }
123 { \TestL \lefttoright A snippet text that makes no sense . }
124 }
125}
126\stopbuffer
127
128\definefontfeature
129 [ test none ]
130 [ mode = none ]
131
132\definefontfeature
133 [ test base ]
134 [ mode = base ,
135 liga = yes ,
136 kern = yes ]
137
138
139
140\definefontfeature
141 [ test node ]
142 [ mode = node ,
143 script = auto ,
144 autoscript = position ,
145 autolanguage = position ,
146 ccmp = yes ,
147 liga = yes ,
148
149
150
151 clig = yes ,
152 kern = yes ,
153 mark = yes ,
154 mkmk = yes ,
155 curs = yes ]
156
157\definefontfeature
158 [ test text ]
159 [ mode = plug ,
160 features = text ]
161
162\definefontfeature
163 [ test native ]
164 [ mode = plug ,
165 features = harfbuzz ,
166
167
168 shaper = native ]
169
170\definefontfeature
171 [ test uniscribe ]
172 [ mode = plug ,
173 features = harfbuzz ,
174
175
176 shaper = uniscribe ]
177
178\definefontfeature
179 [ test binary ]
180 [ mode = plug ,
181 features = harfbuzz ,
182
183
184 shaper = uniscribe ,
185 method = binary ]
186
187\definefontfeature
188 [ arabic node ]
189 [ arabic ]
190 [ salt = yes ]
191
192\definefontfeature
193 [ arabic native ]
194 [ mode = plug ,
195 features = harfbuzz ,
196
197
198 script = arab , language = dflt ,
199
200
201
202
203 shaper = native ]
204
205\definefontfeature
206 [ arabic uniscribe ]
207 [ mode = plug ,
208 features = harfbuzz ,
209 script = arab , language = dflt ,
210
211
212
213
214 shaper = uniscribe ]
215
216\starttexdefinition RunLatinTest # 1 # 2 # 3 # 4 # 5
217 \start
218 \dontcomplain
219 \definefontfeature [ test ][ test # 4 ]
220 \writestatus { warning }{ # 1 # 3 # 4 ( 1 initial run ) }
221 \page
222 \startluacode
223 collectgarbage ( " collect " )
224 \stopluacode
225 \title { # 1 # 3 # 4 }
226 \start
227 \getbuffer [# 5 definitions ]
228 \showfontkerns
229 \showmakeup [ discretionary ]
230
231 \testfeatureonce { 1 }{
232 \getbuffer [# 5 text ]
233 }
234 \stop
235 \page
236 \startluacode
237 collectgarbage ( " collect " )
238 \stopluacode
239 \ifnum # 2 > 1 \relax
240 \writestatus { warning }{ # 1 # 3 # 4 (# 2 timing runs ) }
241 \start
242 \getbuffer [# 5 definitions ]
243 \testfeatureonce { # 2 }{
244 \setbox \scratchbox \hbox { \getbuffer [# 5 text ] }
245 }
246 \stop
247 \writestatus { warning }{ done }
248 \fi
249 \startluacode
250 document . collected_timings . timings [ " #5 " ] . results [ " #1 " ] [ " #3 #4 " ] = \elapsedtime \space
251 collectgarbage ( " collect " )
252 \stopluacode
253 \stop
254\stoptexdefinition
255
256\starttexdefinition RunArabicTest # 1 # 2 # 3 # 4 # 5
257 \start
258 \dontcomplain
259 \definefontsynonym [ Arabic ][# 1 ]
260 \definefontfeature [ test ][ arabic # 4 ]
261 \writestatus { warning }{ # 1 # 3 # 4 # 5 ( 1 initial run ) }
262 \page
263 \startluacode
264 collectgarbage ( " collect " )
265 \stopluacode
266 \title { # 1 # 3 # 4 }
267 \start
268 \getbuffer [# 5 definitions ]
269
270 \testfeatureonce { 1 }{
271 \setupalign [ flushleft ]
272 \getbuffer [# 5 text ]
273 }
274 \par
275 \stop
276 \page
277 \ifnum # 2 > 1 \relax
278 \writestatus { warning }{ # 1 # 3 # 4 # 5 (# 2 timing runs ) }
279 \start
280 \getbuffer [# 5 definitions ]
281 \testfeatureonce { # 2 }{
282 \setbox \scratchbox \hbox { \getbuffer [# 5 text ] }
283 }
284 \stop
285 \writestatus { warning }{ done }
286 \fi
287 \startluacode
288 document . collected_timings . timings [ " #5 " ] . results [ " #1 " ] [ " #3 #4 " ] = \elapsedtime \space
289 collectgarbage ( " collect " )
290 \stopluacode
291 \stop
292\stoptexdefinition
293
294\startluacode
295 local processlist = moduledata . plugins . processlist
296
297 local data = {
298 timings = { } ,
299 engine = jit and " luajittex " or " luatex " ,
300 }
301
302 document . collected_timings = data
303
304
305
306 local list = {
307 " modern " ,
308 " pagella " ,
309 " dejavu " ,
310 " cambria " ,
311 " ebgaramond " ,
312 " lucidaot "
313 }
314
315 data . timings [ " latin " ] = {
316 list = list ,
317 results = table . setmetatableindex ( " table " ) ,
318 }
319
320 for i = 1 , # list do
321
322 local name = list [ i ]
323
324 context . setupbodyfont { name }
325 context . RunLatinTest ( name , 100 , " context " , " none " , " latin " )
326 context . RunLatinTest ( name , 100 , " context " , " base " , " latin " )
327 context . RunLatinTest ( name , 100 , " context " , " node " , " latin " )
328 context . RunLatinTest ( name , 100 , " harfbuzz " , " native " , " latin " )
329 context . RunLatinTest ( name , 100 , " harfbuzz " , " uniscribe " , " latin " )
330
331
332
333 end
334
335 context ( function ( )
336 context . page ( )
337 context . title ( ( jit and " luajittex " or " luatex " ) . . " latin " )
338 processlist ( data . timings [ " latin " ] )
339 context . page ( )
340 end )
341
342
343
344 local list = {
345 " arabtype " ,
346 " husayni " ,
347 }
348
349 data . timings [ " arabic " ] = {
350 list = list ,
351 results = table . setmetatableindex ( " table " )
352 }
353
354 for i = 1 , # list do
355
356 local name = list [ i ]
357
358 context . setupbodyfont { name }
359 context . RunArabicTest ( name , 100 , " context " , " none " , " arabic " )
360 context . RunArabicTest ( name , 100 , " context " , " base " , " arabic " )
361 context . RunArabicTest ( name , 100 , " context " , " node " , " arabic " )
362 context . RunArabicTest ( name , 100 , " harfbuzz " , " native " , " arabic " )
363 context . RunArabicTest ( name , 100 , " harfbuzz " , " uniscribe " , " arabic " )
364
365
366
367 end
368
369 context ( function ( )
370 context . page ( )
371 context . title ( ( jit and " luajittex " or " luatex " ) . . " arabic " )
372 processlist ( data . timings [ " arabic " ] )
373 context . page ( )
374 end )
375
376
377
378 local list = {
379 " arabtype " ,
380 " husayni "
381 }
382
383 data . timings [ " mixed " ] = {
384 list = list ,
385 results = table . setmetatableindex ( " table " )
386 }
387
388 for i = 1 , # list do
389
390 local name = list [ i ]
391
392 context . setupbodyfont { name }
393 context . RunArabicTest ( name , 100 , " context " , " none " , " mixed " )
394 context . RunArabicTest ( name , 100 , " context " , " base " , " mixed " )
395 context . RunArabicTest ( name , 100 , " context " , " node " , " mixed " )
396 context . RunArabicTest ( name , 100 , " harfbuzz " , " native " , " mixed " )
397 context . RunArabicTest ( name , 100 , " harfbuzz " , " uniscribe " , " mixed " )
398
399
400
401 end
402
403 context ( function ( )
404 context . page ( )
405 context . title ( ( jit and " luajittex " or " luatex " ) . . " mixed " )
406 processlist ( data . timings [ " mixed " ] )
407 context . page ( )
408 end )
409
410 context ( function ( )
411 table . save ( " m-fonts-plugins-timings- " . . ( jit and " luajittex " or " luatex " ) . . " .lua " , data )
412 end )
413
414\stopluacode
415
416\stoptext
417 |