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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
|
% language=uk
\environment luametatex-style
\startcomponent luametatex-fonts
\startchapter[reference=fonts,title={Fonts}]
\startsection[title={Introduction}]
Only traditional font support is built in, anything more needs to be implemented
in \LUA. This conforms to the \LUATEX\ philosophy. When you pass a font to the
frontend only the dimensions matter, as these are used in typesetting, and
optionally ligatures and kerns when you rely on the built|-|in font handler. For
math some extra data is needed, like information about extensibles and next in
size glyphs. You can of course put more information in your \LUA\ tables because
when such a table is passed to \TEX\ only that what is needed is filtered from
it.
Because there is no built|-|in backend, virtual font information is not used. If
you want to be compatible you'd better make sure that your tables are okay, and
in that case you can best consult the \LUATEX\ manual. For instance, parameters
like \type {extend} are backend related and the standard \LUATEX\ backend sets
the standard here.
\stopsection
\startsection[title={Defining fonts}]
All \TEX\ fonts are represented to \LUA\ code as tables, and internally as
\CCODE\ structures. All keys in the table below are saved in the internal font
structure if they are present in the table passed to \type {font.define}. When
the callback is set, which is needed for \type {\font} to work, its function
gets the name and size passed, and it has to return a valid font identifier (a
positive number).
For the engine to work well, the following information has to be present at
the font level:
\starttabulate[|l|l|pl|]
\DB key \BC value type \BC description \NC \NR
\TB
\NC \type {name} \NC string \NC metric (file) name \NC \NR
\NC \type {characters} \NC table \NC the defined glyphs of this font \NC \NR
\NC \type {designsize} \NC number \NC expected size (default: 655360 == 10pt) \NC \NR
\NC \type {fonts} \NC table \NC locally used fonts \NC \NR
\NC \type {hyphenchar} \NC number \NC default: \TEX's \prm {hyphenchar} \NC \NR
\NC \type {parameters} \NC hash \NC default: 7 parameters, all zero \NC \NR
\NC \type {size} \NC number \NC the required scaling (by default the same as designsize) \NC \NR
\NC \type {skewchar} \NC number \NC default: \TEX's \prm {skewchar} \NC \NR
\NC \type {stretch} \NC number \NC the \quote {stretch} \NC \NR
\NC \type {shrink} \NC number \NC the \quote {shrink} \NC \NR
\NC \type {step} \NC number \NC the \quote {step} \NC \NR
\NC \type {nomath} \NC boolean \NC this key allows a minor speedup for text fonts; if it
is present and true, then \LUATEX\ will not check the
character entries for math|-|specific keys \NC \NR
\NC \type {oldmath} \NC boolean \NC this key flags a font as representing an old school \TEX\
math font and disables the \OPENTYPE\ code path \NC \NR
\LL
\stoptabulate
The \type {parameters} is a hash with mixed key types. There are seven possible
string keys, as well as a number of integer indices (these start from 8 up). The
seven strings are actually used instead of the bottom seven indices, because that
gives a nicer user interface.
The names and their internal remapping are:
\starttabulate[|l|c|]
\DB name \BC remapping \NC \NR
\TB
\NC \type {slant} \NC 1 \NC \NR
\NC \type {space} \NC 2 \NC \NR
\NC \type {space_stretch} \NC 3 \NC \NR
\NC \type {space_shrink} \NC 4 \NC \NR
\NC \type {x_height} \NC 5 \NC \NR
\NC \type {quad} \NC 6 \NC \NR
\NC \type {extra_space} \NC 7 \NC \NR
\LL
\stoptabulate
The \type {characters} table is a \LUA\ hash table where the keys are integers.
When a character in the input is turned into a glyph node, it gets a character
code that normally refers to an entry in that table. For proper paragraph
building and math rendering the following fields can be present in an entry in
the \type {characters} table. You can of course add all kind of extra fields. The
engine only uses those that it needs for typesetting a paragraph or formula. The
subtables that define ligatures and kerns are also hashes with integer keys, and
these indices should point to entries in the main characters table.
Providing ligatures and kerns this way permits \TEX\ to construct ligatures and
add inter|-|character kerning. However, normally you will use an \OPENTYPE\ font
in combination with \LUA\ code that does this. In \CONTEXT\ we have base mode
that uses the engine, and node mode that uses \LUA. A monospaced font normally
has no ligatures and kerns and is normally not processed at all.
\starttabulate[|l|l|pl|]
\DB key \BC type \BC description \NC\NR
\TB
\NC \type {width} \NC number \NC width in sp (default 0) \NC\NR
\NC \type {height} \NC number \NC height in sp (default 0) \NC\NR
\NC \type {depth} \NC number \NC depth in sp (default 0) \NC\NR
\NC \type {italic} \NC number \NC italic correction in sp (default 0) \NC\NR
\NC \type {top_accent} \NC number \NC top accent alignment place in sp (default zero) \NC\NR
\NC \type {bot_accent} \NC number \NC bottom accent alignment place, in sp (default zero) \NC\NR
\NC \type {left_protruding} \NC number \NC left protruding factor (\lpr {lpcode}) \NC\NR
\NC \type {right_protruding} \NC number \NC right protruding factor (\lpr {rpcode}) \NC\NR
\NC \type {expansion_factor} \NC number \NC expansion factor (\lpr {efcode}) \NC\NR
\NC \type {next} \NC number \NC \quote {next larger} character index \NC\NR
\NC \type {extensible} \NC table \NC constituent parts of an extensible recipe \NC\NR
\NC \type {vert_variants} \NC table \NC constituent parts of a vertical variant set \NC \NR
\NC \type {horiz_variants} \NC table \NC constituent parts of a horizontal variant set \NC \NR
\NC \type {kerns} \NC table \NC kerning information \NC\NR
\NC \type {ligatures} \NC table \NC ligaturing information \NC\NR
\NC \type {mathkern} \NC table \NC math cut-in specifications \NC\NR
\LL
\stoptabulate
For example, here is the character \quote {f} (decimal 102) in the font \type
{cmr10 at 10pt}. The numbers that represent dimensions are in scaled points.
\starttyping
[102] = {
["width"] = 200250,
["height"] = 455111,
["depth"] = 0,
["italic"] = 50973,
["kerns"] = {
[63] = 50973,
[93] = 50973,
[39] = 50973,
[33] = 50973,
[41] = 50973
},
["ligatures"] = {
[102] = { ["char"] = 11, ["type"] = 0 },
[108] = { ["char"] = 13, ["type"] = 0 },
[105] = { ["char"] = 12, ["type"] = 0 }
}
}
\stoptyping
Two very special string indexes can be used also: \type {left_boundary} is a
virtual character whose ligatures and kerns are used to handle word boundary
processing. \type {right_boundary} is similar but not actually used for anything
(yet).
The values of \type {top_accent}, \type {bot_accent} and \type {mathkern} are
used only for math accent and superscript placement, see \at {page} [math] in
this manual for details. The values of \type {left_protruding} and \type
{right_protruding} are used only when \lpr {protrudechars} is non-zero. Whether
or not \type {expansion_factor} is used depends on the font's global expansion
settings, as well as on the value of \lpr {adjustspacing}.
A math character can have a \type {next} field that points to a next larger
shape. However, the presence of \type {extensible} will overrule \type {next}, if
that is also present. The \type {extensible} field in turn can be overruled by
\type {vert_variants}, the \OPENTYPE\ version. The \type {extensible} table is
very simple:
\starttabulate[|l|l|p|]
\DB key \BC type \BC description \NC\NR
\TB
\NC \type{top} \NC number \NC top character index \NC\NR
\NC \type{mid} \NC number \NC middle character index \NC\NR
\NC \type{bot} \NC number \NC bottom character index \NC\NR
\NC \type{rep} \NC number \NC repeatable character index \NC\NR
\LL
\stoptabulate
The \type {horiz_variants} and \type {vert_variants} are arrays of components.
Each of those components is itself a hash of up to five keys:
\starttabulate[|l|l|p|]
\DB key \BC type \BC explanation \NC \NR
\TB
\NC \type{glyph} \NC number \NC The character index. Note that this is an encoding number, not a name. \NC \NR
\NC \type{extender} \NC number \NC One (1) if this part is repeatable, zero (0) otherwise. \NC \NR
\NC \type{start} \NC number \NC The maximum overlap at the starting side (in scaled points). \NC \NR
\NC \type{end} \NC number \NC The maximum overlap at the ending side (in scaled points). \NC \NR
\NC \type{advance} \NC number \NC The total advance width of this item. It can be zero or missing,
then the natural size of the glyph for character \type {component}
is used. \NC \NR
\LL
\stoptabulate
The \type {kerns} table is a hash indexed by character index (and \quote
{character index} is defined as either a non|-|negative integer or the string
value \type {right_boundary}), with the values of the kerning to be applied, in
scaled points.
The \type {ligatures} table is a hash indexed by character index (and \quote
{character index} is defined as either a non|-|negative integer or the string
value \type {right_boundary}), with the values being yet another small hash, with
two fields:
\starttabulate[|l|l|p|]
\DB key \BC type \BC description \NC \NR
\TB
\NC \type{type} \NC number \NC the type of this ligature command, default 0 \NC \NR
\NC \type{char} \NC number \NC the character index of the resultant ligature \NC \NR
\LL
\stoptabulate
The \type {char} field in a ligature is required. The \type {type} field inside a
ligature is the numerical or string value of one of the eight possible ligature
types supported by \TEX. When \TEX\ inserts a new ligature, it puts the new glyph
in the middle of the left and right glyphs. The original left and right glyphs
can optionally be retained, and when at least one of them is kept, it is also
possible to move the new \quote {insertion point} forward one or two places. The
glyph that ends up to the right of the insertion point will become the next
\quote {left}.
\starttabulate[|l|c|l|l|]
\DB textual (Knuth) \BC number \BC string \BC result \NC\NR
\TB
\NC \type{l + r =: n} \NC 0 \NC \type{=:} \NC \type{|n} \NC\NR
\NC \type{l + r =:| n} \NC 1 \NC \type{=:|} \NC \type{|nr} \NC\NR
\NC \type{l + r |=: n} \NC 2 \NC \type{|=:} \NC \type{|ln} \NC\NR
\NC \type{l + r |=:| n} \NC 3 \NC \type{|=:|} \NC \type{|lnr} \NC\NR
\NC \type{l + r =:|> n} \NC 5 \NC \type{=:|>} \NC \type{n|r} \NC\NR
\NC \type{l + r |=:> n} \NC 6 \NC \type{|=:>} \NC \type{l|n} \NC\NR
\NC \type{l + r |=:|> n} \NC 7 \NC \type{|=:|>} \NC \type{l|nr} \NC\NR
\NC \type{l + r |=:|>> n} \NC 11 \NC \type{|=:|>>} \NC \type{ln|r} \NC\NR
\LL
\stoptabulate
The default value is~0, and can be left out. That signifies a \quote {normal}
ligature where the ligature replaces both original glyphs. In this table the~\type {|}
indicates the final insertion point.
\stopsection
\startsection[reference=virtualfonts,title={Virtual fonts}]
% \topicindex {fonts+virtual}
Virtual fonts have been introduced to overcome limitations of good old \TEX. They
were mostly used for providing a direct mapping from for instance accented
characters onto a glyph. The backend was responsible for turning a reference to a
character slot into a real glyph, possibly constructed from other glyphs. In our
case there is no backend so there is also no need to pass this information
through \TEX. But it can of course be part of the font information and because it is
a kind of standard, we describe it here.
A character is virtual when it has a \type {commands} array as part of the data.
A virtual character can itself point to virtual characters but be careful with
nesting as you can create loops and overflow the stack (which often indicates an
error anyway).
At the font level there can be a an (indexed) \type {fonts} table. The values are
one- or two|-|key hashes themselves, each entry indicating one of the base fonts
in a virtual font. In case your font is referring to itself in for instance a
virtual font, you can use the \type {slot} command with a zero font reference,
which indicates that the font itself is used. So, a table looks like this:
\starttyping
fonts = {
{ name = "ptmr8a", size = 655360 },
{ name = "psyr", size = 600000 },
{ id = 38 }
}
\stoptyping
The first referenced font (at index~1) in this virtual font is \type {ptrmr8a}
loaded at 10pt, and the second is \type {psyr} loaded at a little over 9pt. The
third one is a previously defined font that is known to \LUATEX\ as font id~38.
The array index numbers are used by the character command definitions that are
part of each character.
The \type {commands} array is a hash where each item is another small array, with
the first entry representing a command and the extra items being the parameters
to that command. The frontend is only interested in the dimensions, ligatures and
kerns of a font, which is the reason why the \TEX\ engine didn't have to be
extended when virtual fonts showed up: dealing with it is up to the driver that
comes after the backend. In \PDFTEX\ and \LUATEX\ that driver is integrated so
there the backend also deals with virtual fonts. The first block in the next
table is what the standard mentions. The \type {special} command is indeed
special because it is an extension container. The mentioned engines only support
pseudo standards where the content starts with \type {pdf:}. The last block is
\LUATEX\ specific and will not be found in native fonts. These entries can be
used in virtual fonts that are constructed in \LUA.
But \unknown\ in \LUAMETATEX\ there is no backend built in but we might assume
that the one provided deals with these entries. However, a provided backend can
provide more and that is indeed what happens in \CONTEXT. There, because we no
longer have compacting (of passed tables) and unpacking (when embedding) of these
tables going on we stay in the \LUA\ domain. None of the virtual specification is
ever seen in the engine.
\starttabulate[|l|l|l|p|]
\DB command \BC arguments \BC type \BC description \NC \NR
\TB
\NC \type{font} \NC 1 \NC number \NC select a new font from the local \type {fonts} table \NC \NR
\NC \type{char} \NC 1 \NC number \NC typeset this character number from the current font,
and move right by the character's width \NC \NR
\NC \type{push} \NC 0 \NC \NC save current position\NC \NR
\NC \type{pop} \NC 0 \NC \NC pop position \NC \NR
\NC \type{rule} \NC 2 \NC 2 numbers \NC output a rule $ht*wd$, and move right. \NC \NR
\NC \type{down} \NC 1 \NC number \NC move down on the page \NC \NR
\NC \type{right} \NC 1 \NC number \NC move right on the page \NC \NR
\HL
\NC \type{special} \NC 1 \NC string \NC output a \prm {special} command \NC \NR
\HL
\NC \type{nop} \NC 0 \NC \NC do nothing \NC \NR
\NC \type{slot} \NC 2 \NC 2 numbers \NC a shortcut for the combination of a font and char command\NC \NR
\NC \type{node} \NC 1 \NC node \NC output this node (list), and move right
by the width of this list\NC \NR
\NC \type{pdf} \NC 2 \NC 2 strings \NC output a \PDF\ literal, the first string is one of \type {origin},
\type {page}, \type {text}, \type {font}, \type {direct} or \type {raw}; if you
have one string only \type {origin} is assumed \NC \NR
\NC \type{lua} \NC 1 \NC string,
function \NC execute a \LUA\ script when the glyph is embedded; in case of a
function it gets the font id and character code passed \NC \NR
\NC \type{image} \NC 1 \NC image \NC output an image (the argument can be either an \type {<image>} variable or an \type {image_spec} table) \NC \NR
\NC \type{comment} \NC any \NC any \NC the arguments of this command are ignored \NC \NR
\LL
\stoptabulate
When a font id is set to~0 then it will be replaced by the currently assigned
font id. This prevents the need for hackery with future id's.
The \type {pdf} option also accepts a \type {mode} keyword in which case the
third argument sets the mode. That option will change the mode in an efficient
way (passing an empty string would result in an extra empty lines in the \PDF\
file. This option only makes sense for virtual fonts. The \type {font} mode only
makes sense in virtual fonts. Modes are somewhat fuzzy and partially inherited
from \PDFTEX.
\starttabulate[|l|p|]
\DB mode \BC description \NC \NR
\TB
\NC \type {origin} \NC enter page mode and set the position \NC \NR
\NC \type {page} \NC enter page mode \NC \NR
\NC \type {text} \NC enter text mode \NC \NR
\NC \type {font} \NC enter font mode (kind of text mode, only in virtual fonts) \NC \NR
\NC \type {always} \NC finish the current string and force a transform if needed \NC \NR
\NC \type {raw} \NC finish the current string \NC \NR
\LL
\stoptabulate
You always need to check what \PDF\ code is generated because there can be all
kind of interferences with optimization in the backend and fonts are complicated
anyway. Here is a rather elaborate glyph commands example using such keys:
\starttyping
...
commands = {
{ "push" }, -- remember where we are
{ "right", 5000 }, -- move right about 0.08pt
{ "font", 3 }, -- select the fonts[3] entry
{ "char", 97 }, -- place character 97 (ASCII 'a')
-- { "slot", 2, 97 }, -- an alternative for the previous two
{ "pop" }, -- go all the way back
{ "down", -200000 }, -- move upwards by about 3pt
{ "special", "pdf: 1 0 0 rg" } -- switch to red color
-- { "pdf", "origin", "1 0 0 rg" } -- switch to red color (alternative)
{ "rule", 500000, 20000 } -- draw a bar
{ "special", "pdf: 0 g" } -- back to black
-- { "pdf", "origin", "0 g" } -- back to black (alternative)
}
...
\stoptyping
The default value for \type {font} is always~1 at the start of the
\type {commands} array. Therefore, if the virtual font is essentially only a
re|-|encoding, then you do usually not have created an explicit \quote {font}
command in the array.
Rules inside of \type {commands} arrays are built up using only two dimensions:
they do not have depth. For correct vertical placement, an extra \type {down}
command may be needed.
Regardless of the amount of movement you create within the \type {commands}, the
output pointer will always move by exactly the width that was given in the \type
{width} key of the character hash. Any movements that take place inside the \type
{commands} array are ignored on the upper level.
The special can have a \type {pdf:}, \type {pdf:origin:}, \type {pdf:page:},
\type {pdf:direct:} or \type {pdf:raw:} prefix. When you have to concatenate
strings using the \type {pdf} command might be more efficient.
\stopsection
\startsection[title={Additional \TEX\ commands}]
\startsubsection[title={Font syntax}]
\topicindex {fonts}
\LUATEX\ will accept a braced argument as a font name:
\starttyping
\font\myfont = {cmr10}
\stoptyping
This allows for embedded spaces, without the need for double quotes. Macro
expansion takes place inside the argument.
\stopsubsection
\startsubsection[title={\lpr {fontid} and \lpr {setfontid}}]
\startsyntax
\fontid\font
\stopsyntax
This primitive expands into a number. The currently used font id is
\number\fontid\font. Here are some more: \footnote {Contrary to \LUATEX\ this is
now a number so you need to use \type {\number} or \type {\the}. The same is true
for some other numbers and dimensions that for some reason ended up in the
serializer that produced a sequence of tokens.}
\starttabulate[|l|c|c|]
\DB style \BC command \BC font id \NC \NR
\TB
\NC normal \NC \type {\tf} \NC \tf \number\fontid\font \NC \NR
\NC bold \NC \type {\bf} \NC \bf \number\fontid\font \NC \NR
\NC italic \NC \type {\it} \NC \it \number\fontid\font \NC \NR
\NC bold italic \NC \type {\bi} \NC \bi \number\fontid\font \NC \NR
\LL
\stoptabulate
These numbers depend on the macro package used because each one has its own way
of dealing with fonts. They can also differ per run, as they can depend on the
order of loading fonts. For instance, when in \CONTEXT\ virtual math \UNICODE\
fonts are used, we can easily get over a hundred ids in use. Not all ids have to
be bound to a real font, after all it's just a number.
The primitive \lpr {setfontid} can be used to enable a font with the given id,
which of course needs to be a valid one.
\stopsubsection
\startsubsection[title={\lpr {glyphoptions}}]
\topicindex {ligatures+suppress}
\topicindex {kerns+suppress}
\topicindex {expansion+suppress}
\topicindex {protrusion+suppress}
In \LUATEX\ the \type {\noligs} and \type {\nokerns} primitives suppress these
features but in \LUAMETATEX\ these primitives are gone. They are replace by a more
generic control primitive \lpr {glyphoptions}. This numerical parameter is a
bitset with the following fields:
\starttabulate[|l|pl|]
\DB value \BC effect \NC\NR
\TB
\NC \type{0x01} \NC prevent left ligature \NC \NR
\NC \type{0x02} \NC prevent right ligature \NC \NR
\NC \type{0x04} \NC block left kern \NC \NR
\NC \type{0x08} \NC block right kern \NC \NR
\NC \type{0x10} \NC don't apply expansion \NC \NR
\NC \type{0x20} \NC don't apply protrusion \NC \NR
\NC \type{0x40} \NC apply xoffset to width \NC \NR
\NC \type{0x80} \NC apply yoffset to height and depth \NC \NR
\LL
\stoptabulate
The effects speak for themselves. They provide detailed control over individual
glyph, this because the current value of this option is stored with glyphs.
\stopsubsection
\startsubsection[title={\lpr {glyphxscale}, \lpr {glyphyscale} and \lpr {scaledfontdimen}}]
The two scale parameters control the current scaling. They are traditional \TEX\
integer parameters that operate independent of each other. The scaling is
reflected in the dimensions of glyphs as well as in the related font dimensions,
which means that units like \type {ex} and \type {em} work as expected. If you
query a font dimensions with \prm {fontdimen} you get the raw value but with \lpr
{scaledfontdimen} you get the useable value.
\stopsubsection
\startsubsection[title={\lpr {glyphxoffset}, \lpr {glyphyoffset}}]
These two parameters control the horizontal and vertical shift of glyphs with,
when applied to a stretch of them, the horizontal offset probably being the least
useful.
\stopsubsection
\startsubsection[title={\lpr {glyph}}]
This command is a variation in \prm {char} that takes keywords:
\starttabulate[|l|p|]
\DB keyword \BC effect \NC type \NC \NR
\TB
\NC \type {xoffset} \NC (virtual) horizontal shift \NC dimension \NC \NR
\NC \type {yoffset} \NC (virtual) vertical shift \NC dimension \NC \NR
\NC \type {xscale} \NC horizontal scaling \NC integer \NC \NR
\NC \type {yscale} \NC vertical scaling \NC integer \NC \NR
\NC \type {options} \NC glyph options \NC bitset \NC \NR
\NC \type {font} \NC font \NC identifier \NC \NR
\NC \type {id} \NC font \NC integer \NC \NR
\LL
\stoptabulate
The values default to the currently set values. Here is a \CONTEXT\ example:
\startbuffer
\ruledhbox{
\ruledhbox{\glyph yoffset 1ex options 0 123}
\ruledhbox{\glyph xoffset .5em yoffset 1ex options "C0 125}
\ruledhbox{baseline\glyphyoffset 1ex \glyphxscale 800 \glyphyscale\glyphxscale raised}
}
\stopbuffer
\typebuffer
Visualized:
\getbuffer
\stopsubsection
\startsubsection[title={\lpr{nospaces}}]
\topicindex {spaces+suppress}
This new primitive can be used to overrule the usual \prm {spaceskip} related
heuristics when a space character is seen in a text flow. The value~\type{1}
triggers no injection while \type{2} results in injection of a zero skip. In \in
{figure} [fig:nospaces] we see the results for four characters separated by a
space.
\startplacefigure[reference=fig:nospaces,title={The \lpr {nospaces} options.}]
\startcombination[3*2]
{\ruledhbox to 5cm{\vtop{\hsize 10mm\nospaces=0\relax x x x x \par}\hss}} {\type {0 / hsize 10mm}}
{\ruledhbox to 5cm{\vtop{\hsize 10mm\nospaces=1\relax x x x x \par}\hss}} {\type {1 / hsize 10mm}}
{\ruledhbox to 5cm{\vtop{\hsize 10mm\nospaces=2\relax x x x x \par}\hss}} {\type {2 / hsize 10mm}}
{\ruledhbox to 5cm{\vtop{\hsize 1mm\nospaces=0\relax x x x x \par}\hss}} {\type {0 / hsize 1mm}}
{\ruledhbox to 5cm{\vtop{\hsize 1mm\nospaces=1\relax x x x x \par}\hss}} {\type {1 / hsize 1mm}}
{\ruledhbox to 5cm{\vtop{\hsize 1mm\nospaces=2\relax x x x x \par}\hss}} {\type {2 / hsize 1mm}}
\stopcombination
\stopplacefigure
\stopsubsection
\startsubsection[title={\lpr{protrusionboundary}}]
\topicindex {protrusion}
\topicindex {boundaries}
The protrusion detection mechanism is enhanced a bit to enable a bit more complex
situations. When protrusion characters are identified some nodes are skipped:
\startitemize[packed,columns,two]
\startitem zero glue \stopitem
\startitem penalties \stopitem
\startitem empty discretionaries \stopitem
\startitem normal zero kerns \stopitem
\startitem rules with zero dimensions \stopitem
\startitem math nodes with a surround of zero \stopitem
\startitem dir nodes \stopitem
\startitem empty horizontal lists \stopitem
\startitem local par nodes \stopitem
\startitem inserts, marks and adjusts \stopitem
\startitem boundaries \stopitem
\startitem whatsits \stopitem
\stopitemize
Because this can not be enough, you can also use a protrusion boundary node to
make the next node being ignored. When the value is~1 or~3, the next node will be
ignored in the test when locating a left boundary condition. When the value is~2
or~3, the previous node will be ignored when locating a right boundary condition
(the search goes from right to left). This permits protrusion combined with for
instance content moved into the margin:
\starttyping
\protrusionboundary1\llap{!\quad}«Who needs protrusion?»
\stoptyping
\stopsubsection
\stopsection
\startsection[title={The \LUA\ font library}][library=font]
\startsubsection[title={Introduction}]
The \LUA\ font library is reduced to a few commands. Contrary to \LUATEX\ there
is no loading of \TFM\ or \VF\ files. The explanation of the following commands
is in the \LUATEX\ manual.
\starttabulate[|l|pl|]
\DB function \BC description \NC\NR
\TB
\NC \type {current} \NC returns the id of the currently active font \NC \NR
\NC \type {max} \NC returns the last assigned font identifier \NC \NR
\NC \type {setfont} \NC enables a font setfont (sets the current font id) \NC \NR
\NC \type {addcharacters} \NC adds characters to a font \NC \NR
\NC \type {define} \NC defined a font \NC \NR
\NC \type {id} \NC returns the id that relates to a command name \NC \NR
\LL
\stoptabulate
For practical reasons the management of font identifiers is still done by \TEX\
but it can become an experiment to delegate that to \LUA\ as well.
\stopsubsection
\startsubsection[title={Defining a font with \type {define}, \type {addcharacters} and \type
{setfont}}]
\topicindex {fonts+define}
\topicindex {fonts+extend}
Normally you will use a callback to define a font but there's also a \LUA\
function that does the job.
\startfunctioncall
id = font.define(<table> f)
\stopfunctioncall
Within reasonable bounds you can extend a font after it has been defined. Because
some properties are best left unchanged this is limited to adding characters.
\startfunctioncall
font.addcharacters(<number n>, <table> f)
\stopfunctioncall
The table passed can have the fields \type {characters} which is a (sub)table
like the one used in define, and for virtual fonts a \type {fonts} table can be
added. The characters defined in the \type {characters} table are added (when not
yet present) or replace an existing entry. Keep in mind that replacing can have
side effects because a character already can have been used. Instead of posing
restrictions we expect the user to be careful. The \type {setfont} helper is
a more drastic replacer and only works when a font has not been used yet.
\stopsubsection
\startsubsection[title={Font ids: \type {id}, \type {max} and \type {current}}]
\topicindex {fonts+id}
\topicindex {fonts+current}
\startfunctioncall
<number> i = font.id(<string> csname)
\stopfunctioncall
This returns the font id associated with \type {csname}, or $-1$ if \type
{csname} is not defined.
\startfunctioncall
<number> i = font.max()
\stopfunctioncall
This is the largest used index so far. The currently active font id can be
queried or set with:
\startfunctioncall
<number> i = font.current()
font.current(<number> i)
\stopfunctioncall
\stopsubsection
\startsubsection[title={Glyph data: \lpr {glyphdata}, \lpr {glyphscript}, \lpr {glyphstate}}]
These primitives can be used to set an additional glyph properties. Of course
it's very macro package dependant what is done with that. It started with just
the first one as experiment, simply because we had some room left in the glyph
data structure. It's basically an single attribute. Then, when we got rid of the
ligature pointer we could either drop it or use that extra field for some more,
and because \CONTEXT\ already used the data field, that is what happened. The
script and state fields are shorts, that is, they run from zero to \type {0xFFFF}
where we assume that zero means \quote {unset}. Although they can be used for
whatever purpose their use in \CONTEXT\ is fixed.
\stopsubsection
\stopsection
\stopchapter
\stopcomponent
|