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
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
|
% language=uk
\environment luatex-style
\environment luatex-logos
\startcomponent luatex-fontloader
\startchapter[reference=fontloader,title={The fontloader}]
The fontloader library is sort of independent of the rest in the sense that it
can load font into a \LUA\ table that then can be converted into a table suitable
for \TEX. The library is an adapted subset of \FONTFORGE\ and as such gives a
similar view on a font (which has advantages when you want to debug.)
\section{Getting quick information on a font}
When you want to locate font by name you need some basic information that is
hidden in the font files. For that reason we provide an efficient helper that
gets the basic information without loading all of the font. Normally this helper
is used to create a font (name) database.
\startfunctioncall
<table> info =
fontloader.info(<string> filename)
\stopfunctioncall
This function returns either \type {nil}, or a \type {table}, or an array of
small tables (in the case of a \TRUETYPE\ collection). The returned table(s) will
contain some fairly interesting information items from the font(s) defined by the
file:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC fontname \NC string \NC the \POSTSCRIPT\ name of the font\NC \NR
\NC fullname \NC string \NC the formal name of the font\NC \NR
\NC familyname \NC string \NC the family name this font belongs to\NC \NR
\NC weight \NC string \NC a string indicating the color value of the font\NC \NR
\NC version \NC string \NC the internal font version\NC \NR
\NC italicangle \NC float \NC the slant angle\NC \NR
\NC units_per_em \NC number \NC 1000 for \POSTSCRIPT-based fonts, usually 2048 for \TRUETYPE\NC \NR
\NC pfminfo \NC table \NC (see \in{section}[fontloaderpfminfotable])\NC \NR
\stoptabulate
Getting information through this function is (sometimes much) more efficient than
loading the font properly, and is therefore handy when you want to create a
dictionary of available fonts based on a directory contents.
\section{Loading an \OPENTYPE\ or \TRUETYPE\ file}
If you want to use an \OPENTYPE\ font, you have to get the metric information
from somewhere. Using the \type {fontloader} library, the simplest way to get
that information is thus:
\starttyping
function load_font (filename)
local metrics = nil
local font = fontloader.open(filename)
if font then
metrics = fontloader.to_table(font)
fontloader.close(font)
end
return metrics
end
myfont = load_font('/opt/tex/texmf/fonts/data/arial.ttf')
\stoptyping
The main function call is
\startfunctioncall
<userdata> f, <table> w = fontloader.open(<string> filename)
<userdata> f, <table> w = fontloader.open(<string> filename, <string> fontname)
\stopfunctioncall
The first return value is a userdata representation of the font. The second
return value is a table containing any warnings and errors reported by fontloader
while opening the font. In normal typesetting, you would probably ignore the
second argument, but it can be useful for debugging purposes.
For \TRUETYPE\ collections (when filename ends in 'ttc') and \DFONT\ collections,
you have to use a second string argument to specify which font you want from the
collection. Use the \type {fontname} strings that are returned by \type
{fontloader.info} for that.
To turn the font into a table, \type {fontloader.to_table} is used on the font
returned by \type {fontloader.open}.
\startfunctioncall
<table> f = fontloader.to_table(<userdata> font)
\stopfunctioncall
This table cannot be used directly by \LUATEX\ and should be turned into another
one as described in~\in {chapter} [fonts]. Do not forget to store the \type
{fontname} value in the \type {psname} field of the metrics table to be returned
to \LUATEX, otherwise the font inclusion backend will not be able to find the
correct font in the collection.
See \in {section} [fontloadertables] for details on the userdata object returned
by \type {fontloader.open()} and the layout of the \type {metrics} table returned
by \type {fontloader.to_table()}.
The font file is parsed and partially interpreted by the font loading routines
from \FONTFORGE. The file format can be \OPENTYPE, \TRUETYPE, \TRUETYPE\
Collection, \CFF, or \TYPEONE.
There are a few advantages to this approach compared to reading the actual font
file ourselves:
\startitemize
\startitem
The font is automatically re|-|encoded, so that the \type {metrics} table for
\TRUETYPE\ and \OPENTYPE\ fonts is using \UNICODE\ for the character indices.
\stopitem
\startitem
Many features are pre|-|processed into a format that is easier to handle than
just the bare tables would be.
\stopitem
\startitem
\POSTSCRIPT|-|based \OPENTYPE\ fonts do not store the character height and
depth in the font file, so the character boundingbox has to be calculated in
some way.
\stopitem
\startitem
In the future, it may be interesting to allow \LUA\ scripts access to
the font program itself, perhaps even creating or changing the font.
\stopitem
\stopitemize
A loaded font is discarded with:
\startfunctioncall
fontloader.close(<userdata> font)
\stopfunctioncall
\section{Applying a \quote{feature file}}
You can apply a \quote{feature file} to a loaded font:
\startfunctioncall
<table> errors = fontloader.apply_featurefile(<userdata> font, <string> filename)
\stopfunctioncall
A \quote {feature file} is a textual representation of the features in an
\OPENTYPE\ font. See
\starttyping
http://www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.html
\stoptyping
and
\starttyping
http://fontforge.sourceforge.net/featurefile.html
\stoptyping
for a more detailed description of feature files.
If the function fails, the return value is a table containing any errors reported
by fontloader while applying the feature file. On success, \type {nil} is
returned.
\section{Applying an \quote{\AFM\ file}}
You can apply an \quote {\AFM\ file} to a loaded font:
\startfunctioncall
<table> errors = fontloader.apply_afmfile(<userdata> font, <string> filename)
\stopfunctioncall
An \AFM\ file is a textual representation of (some of) the meta information
in a \TYPEONE\ font. See
\starttyping
ftp://ftp.math.utah.edu/u/ma/hohn/linux/postscript/5004.AFM_Spec.pdf
\stoptyping
for more information about \AFM\ files.
Note: If you \type {fontloader.open()} a \TYPEONE\ file named \type {font.pfb},
the library will automatically search for and apply \type {font.afm} if it exists
in the same directory as the file \type {font.pfb}. In that case, there is no
need for an explicit call to \type {apply_afmfile()}.
If the function fails, the return value is a table containing any errors reported
by fontloader while applying the AFM file. On success, \type {nil} is returned.
\section[fontloadertables]{Fontloader font tables}
As mentioned earlier, the return value of \type {fontloader.open()} is a userdata
object. One way to have access to the actual metrics is to call \type
{fontloader.to_table()} on this object, returning the table structure that is
explained in the following sections. In teh following sections we will not
explain each field in detail. Most fields are self descriptive and for the more
technical aspects you need to consult the relevant font references.
It turns out that the result from \type {fontloader.to_table()} sometimes needs
very large amounts of memory (depending on the font's complexity and size) so it
is possible to access the userdata object directly.
\startitemize
\startitem
All top|-|level keys that would be returned by \type {to_table()}
can also be accessed directly.
\stopitem
\startitem
The top|-|level key \quote {glyphs} returns a {\it virtual\/} array that
allows indices from \type {f.glyphmin} to (\type {f.glyphmax}).
\stopitem
\startitem
The items in that virtual array (the actual glyphs) are themselves also
userdata objects, and each has accessors for all of the keys explained in the
section \quote {Glyph items} below.
\stopitem
\startitem
The top|-|level key \quote {subfonts} returns an {\it actual} array of userdata
objects, one for each of the subfonts (or nil, if there are no subfonts).
\stopitem
\stopitemize
A short example may be helpful. This code generates a printout of all
the glyph names in the font \type {PunkNova.kern.otf}:
\starttyping
local f = fontloader.open('PunkNova.kern.otf')
print (f.fontname)
local i = 0
if f.glyphcnt > 0 then
for i=f.glyphmin,f.glyphmax do
local g = f.glyphs[i]
if g then
print(g.name)
end
i = i + 1
end
end
fontloader.close(f)
\stoptyping
In this case, the \LUATEX\ memory requirement stays below 100MB on the test
computer, while the internal structure generated by \type {to_table()} needs more
than 2GB of memory (the font itself is 6.9MB in disk size).
Only the top|-|level font, the subfont table entries, and the glyphs are virtual
objects, everything else still produces normal \LUA\ values and tables.
If you want to know the valid fields in a font or glyph structure, call the \type
{fields} function on an object of a particular type (either glyph or font):
\startfunctioncall
<table> fields = fontloader.fields(<userdata> font)
<table> fields = fontloader.fields(<userdata> font_glyph)
\stopfunctioncall
For instance:
\startfunctioncall
local fields = fontloader.fields(f)
local fields = fontloader.fields(f.glyphs[0])
\stopfunctioncall
\section{Table types}
\subsection{Top-level}
The top|-|level keys in the returned table are (the explanations in this part of
the documentation are not yet finished):
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC table_version \NC number \NC indicates the metrics version (currently~0.3)\NC \NR
\NC fontname \NC string \NC \POSTSCRIPT\ font name\NC \NR
\NC fullname \NC string \NC official (human-oriented) font name\NC \NR
\NC familyname \NC string \NC family name\NC \NR
\NC weight \NC string \NC weight indicator\NC \NR
\NC copyright \NC string \NC copyright information\NC \NR
\NC filename \NC string \NC the file name\NC \NR
\NC version \NC string \NC font version\NC \NR
\NC italicangle \NC float \NC slant angle\NC \NR
\NC units_per_em \NC number \NC 1000 for \POSTSCRIPT-based fonts, usually 2048 for \TRUETYPE\NC \NR
\NC ascent \NC number \NC height of ascender in \type {units_per_em}\NC \NR
\NC descent \NC number \NC depth of descender in \type {units_per_em}\NC \NR
\NC upos \NC float \NC \NC \NR
\NC uwidth \NC float \NC \NC \NR
\NC uniqueid \NC number \NC \NC \NR
\NC glyphs \NC array \NC \NC \NR
\NC glyphcnt \NC number \NC number of included glyphs\NC \NR
\NC glyphmax \NC number \NC maximum used index the glyphs array\NC \NR
\NC glyphmin \NC number \NC minimum used index the glyphs array\NC \NR
\NC notdef_loc \NC number \NC location of the \type {.notdef} glyph
or \type {-1} when not present \NC \NR
\NC hasvmetrics \NC number \NC \NC \NR
\NC onlybitmaps \NC number \NC \NC \NR
\NC serifcheck \NC number \NC \NC \NR
\NC isserif \NC number \NC \NC \NR
\NC issans \NC number \NC \NC \NR
\NC encodingchanged \NC number \NC \NC \NR
\NC strokedfont \NC number \NC \NC \NR
\NC use_typo_metrics \NC number \NC \NC \NR
\NC weight_width_slope_only \NC number \NC \NC \NR
\NC head_optimized_for_cleartype \NC number \NC \NC \NR
\NC uni_interp \NC enum \NC \type {unset}, \type {none}, \type {adobe},
\type {greek}, \type {japanese}, \type {trad_chinese},
\type {simp_chinese}, \type {korean}, \type {ams}\NC \NR
\NC origname \NC string \NC the file name, as supplied by the user\NC \NR
\NC map \NC table \NC \NC \NR
\NC private \NC table \NC \NC \NR
\NC xuid \NC string \NC \NC \NR
\NC pfminfo \NC table \NC \NC \NR
\NC names \NC table \NC \NC \NR
\NC cidinfo \NC table \NC \NC \NR
\NC subfonts \NC array \NC \NC \NR
\NC commments \NC string \NC \NC \NR
\NC fontlog \NC string \NC \NC \NR
\NC cvt_names \NC string \NC \NC \NR
\NC anchor_classes \NC table \NC \NC \NR
\NC ttf_tables \NC table \NC \NC \NR
\NC ttf_tab_saved \NC table \NC \NC \NR
\NC kerns \NC table \NC \NC \NR
\NC vkerns \NC table \NC \NC \NR
\NC texdata \NC table \NC \NC \NR
\NC lookups \NC table \NC \NC \NR
\NC gpos \NC table \NC \NC \NR
\NC gsub \NC table \NC \NC \NR
\NC mm \NC table \NC \NC \NR
\NC chosenname \NC string \NC \NC \NR
\NC macstyle \NC number \NC \NC \NR
\NC fondname \NC string \NC \NC \NR
%NC design_size \NC number \NC \NC \NR
\NC fontstyle_id \NC number \NC \NC \NR
\NC fontstyle_name \NC table \NC \NC \NR
%NC design_range_bottom \NC number \NC \NC \NR
%NC design_range_top \NC number \NC \NC \NR
\NC strokewidth \NC float \NC \NC \NR
\NC mark_classes \NC table \NC \NC \NR
\NC creationtime \NC number \NC \NC \NR
\NC modificationtime \NC number \NC \NC \NR
\NC os2_version \NC number \NC \NC \NR
\NC sfd_version \NC number \NC \NC \NR
\NC math \NC table \NC \NC \NR
\NC validation_state \NC table \NC \NC \NR
\NC horiz_base \NC table \NC \NC \NR
\NC vert_base \NC table \NC \NC \NR
\NC extrema_bound \NC number \NC \NC \NR
\NC truetype \NC boolean \NC signals a \TRUETYPE\ font \NC \NR
\stoptabulate
\subsection{Glyph items}
The \type {glyphs} is an array containing the per|-|character
information (quite a few of these are only present if nonzero).
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC name \NC string \NC the glyph name \NC \NR
\NC unicode \NC number \NC unicode code point, or -1 \NC \NR
\NC boundingbox \NC array \NC array of four numbers, see note below \NC \NR
\NC width \NC number \NC only for horizontal fonts \NC \NR
\NC vwidth \NC number \NC only for vertical fonts \NC \NR
\NC tsidebearing \NC number \NC only for vertical ttf/otf fonts, and only if nonzero \NC \NR
\NC lsidebearing \NC number \NC only if nonzero and not equal to boundingbox[1] \NC \NR
\NC class \NC string \NC one of "none", "base", "ligature", "mark", "component"
(if not present, the glyph class is \quote {automatic}) \NC \NR
\NC kerns \NC array \NC only for horizontal fonts, if set \NC \NR
\NC vkerns \NC array \NC only for vertical fonts, if set \NC \NR
\NC dependents \NC array \NC linear array of glyph name strings, only if nonempty\NC \NR
\NC lookups \NC table \NC only if nonempty \NC \NR
\NC ligatures \NC table \NC only if nonempty \NC \NR
\NC anchors \NC table \NC only if set \NC \NR
\NC comment \NC string \NC only if set \NC \NR
\NC tex_height \NC number \NC only if set \NC \NR
\NC tex_depth \NC number \NC only if set \NC \NR
\NC italic_correction \NC number \NC only if set \NC \NR
\NC top_accent \NC number \NC only if set \NC \NR
\NC is_extended_shape \NC number \NC only if this character is part of a math extension list \NC \NR
\NC altuni \NC table \NC alternate \UNICODE\ items \NC \NR
\NC vert_variants \NC table \NC \NC \NR
\NC horiz_variants \NC table \NC \NC \NR
\NC mathkern \NC table \NC \NC \NR
\stoptabulate
On \type {boundingbox}: The boundingbox information for \TRUETYPE\ fonts and
\TRUETYPE-based \OTF\ fonts is read directly from the font file.
\POSTSCRIPT-based fonts do not have this information, so the boundingbox of
traditional \POSTSCRIPT\ fonts is generated by interpreting the actual bezier
curves to find the exact boundingbox. This can be a slow process, so the
boundingboxes of \POSTSCRIPT-based \OTF\ fonts (and raw \CFF\ fonts) are
calculated using an approximation of the glyph shape based on the actual glyph
points only, instead of taking the whole curve into account. This means that
glyphs that have missing points at extrema will have a too|-|tight boundingbox,
but the processing is so much faster that in our opinion the tradeoff is worth
it.
The \type {kerns} and \type {vkerns} are linear arrays of small hashes:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC char \NC string \NC \NC \NR
\NC off \NC number \NC \NC \NR
\NC lookup \NC string \NC \NC \NR
\stoptabulate
The \type {lookups} is a hash, based on lookup subtable names, with
the value of each key inside that a linear array of small hashes:
% TODO: fix this description
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC type \NC enum \NC \type {position}, \type {pair}, \type
{substitution}, \type {alternate}, \type
{multiple}, \type {ligature}, \type {lcaret},
\type {kerning}, \type {vkerning}, \type
{anchors}, \type {contextpos}, \type
{contextsub}, \type {chainpos}, \type
{chainsub}, \type {reversesub}, \type {max},
\type {kernback}, \type {vkernback} \NC \NR
\NC specification \NC table \NC extra data \NC \NR
\stoptabulate
For the first seven values of \type {type}, there can be additional
sub|-|information, stored in the sub-table \type {specification}:
\starttabulate[|lT|l|p|]
\NC \rmbf value \NC \bf type \NC \bf explanation \NC \NR
\NC position \NC table \NC a table of the \type {offset_specs} type \NC \NR
\NC pair \NC table \NC one string: \type {paired}, and an array of one
or two \type {offset_specs} tables: \type
{offsets} \NC \NR
\NC substitution \NC table \NC one string: \type {variant} \NC \NR
\NC alternate \NC table \NC one string: \type {components} \NC \NR
\NC multiple \NC table \NC one string: \type {components} \NC \NR
\NC ligature \NC table \NC two strings: \type {components}, \type {char} \NC \NR
\NC lcaret \NC array \NC linear array of numbers \NC \NR
\stoptabulate
Tables for \type {offset_specs} contain up to four number|-|valued fields: \type
{x} (a horizontal offset), \type {y} (a vertical offset), \type {h} (an advance
width correction) and \type {v} (an advance height correction).
The \type {ligatures} is a linear array of small hashes:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC lig \NC table \NC uses the same substructure as a single item in
the \type {lookups} table explained above \NC \NR
\NC char \NC string \NC \NC \NR
\NC components \NC array \NC linear array of named components \NC \NR
\NC ccnt \NC number \NC \NC \NR
\stoptabulate
The \type {anchor} table is indexed by a string signifying the anchor type, which
is one of
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC mark \NC table \NC placement mark \NC \NR
\NC basechar \NC table \NC mark for attaching combining items to a base char \NC \NR
\NC baselig \NC table \NC mark for attaching combining items to a ligature \NC \NR
\NC basemark \NC table \NC generic mark for attaching combining items to connect to \NC \NR
\NC centry \NC table \NC cursive entry point \NC \NR
\NC cexit \NC table \NC cursive exit point \NC \NR
\stoptabulate
The content of these is a short array of defined anchors, with the
entry keys being the anchor names. For all except \type {baselig}, the
value is a single table with this definition:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC x \NC number \NC x location \NC \NR
\NC y \NC number \NC y location \NC \NR
\NC ttf_pt_index \NC number \NC truetype point index, only if given \NC \NR
\stoptabulate
For \type {baselig}, the value is a small array of such anchor sets sets, one for
each constituent item of the ligature.
For clarification, an anchor table could for example look like this :
\starttyping
['anchor'] = {
['basemark'] = {
['Anchor-7'] = { ['x']=170, ['y']=1080 }
},
['mark'] ={
['Anchor-1'] = { ['x']=160, ['y']=810 },
['Anchor-4'] = { ['x']=160, ['y']=800 }
},
['baselig'] = {
[1] = { ['Anchor-2'] = { ['x']=160, ['y']=650 } },
[2] = { ['Anchor-2'] = { ['x']=460, ['y']=640 } }
}
}
\stoptyping
Note: The \type {baselig} table can be sparse!
\subsection{map table}
The top|-|level map is a list of encoding mappings. Each of those is a table
itself.
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC enccount \NC number \NC \NC \NR
\NC encmax \NC number \NC \NC \NR
\NC backmax \NC number \NC \NC \NR
\NC remap \NC table \NC \NC \NR
\NC map \NC array \NC non|-|linear array of mappings\NC \NR
\NC backmap \NC array \NC non|-|linear array of backward mappings\NC \NR
\NC enc \NC table \NC \NC \NR
\stoptabulate
The \type {remap} table is very small:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC firstenc \NC number \NC \NC \NR
\NC lastenc \NC number \NC \NC \NR
\NC infont \NC number \NC \NC \NR
\stoptabulate
The \type {enc} table is a bit more verbose:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC enc_name \NC string \NC \NC \NR
\NC char_cnt \NC number \NC \NC \NR
\NC char_max \NC number \NC \NC \NR
\NC unicode \NC array \NC of \UNICODE\ position numbers\NC \NR
\NC psnames \NC array \NC of \POSTSCRIPT\ glyph names\NC \NR
\NC builtin \NC number \NC \NC \NR
\NC hidden \NC number \NC \NC \NR
\NC only_1byte \NC number \NC \NC \NR
\NC has_1byte \NC number \NC \NC \NR
\NC has_2byte \NC number \NC \NC \NR
\NC is_unicodebmp \NC number \NC only if nonzero\NC \NR
\NC is_unicodefull \NC number \NC only if nonzero\NC \NR
\NC is_custom \NC number \NC only if nonzero\NC \NR
\NC is_original \NC number \NC only if nonzero\NC \NR
\NC is_compact \NC number \NC only if nonzero\NC \NR
\NC is_japanese \NC number \NC only if nonzero\NC \NR
\NC is_korean \NC number \NC only if nonzero\NC \NR
\NC is_tradchinese \NC number \NC only if nonzero [name?]\NC \NR
\NC is_simplechinese \NC number \NC only if nonzero\NC \NR
\NC low_page \NC number \NC \NC \NR
\NC high_page \NC number \NC \NC \NR
\NC iconv_name \NC string \NC \NC \NR
\NC iso_2022_escape \NC string \NC \NC \NR
\stoptabulate
\subsection{private table}
This is the font's private \POSTSCRIPT\ dictionary, if any. Keys and values are
both strings.
\subsection{cidinfo table}
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC registry \NC string \NC \NC \NR
\NC ordering \NC string \NC \NC \NR
\NC supplement \NC number \NC \NC \NR
\NC version \NC number \NC \NC \NR
\stoptabulate
\subsection[fontloaderpfminfotable]{pfminfo table}
The \type {pfminfo} table contains most of the OS/2 information:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC pfmset \NC number \NC \NC \NR
\NC winascent_add \NC number \NC \NC \NR
\NC windescent_add \NC number \NC \NC \NR
\NC hheadascent_add \NC number \NC \NC \NR
\NC hheaddescent_add \NC number \NC \NC \NR
\NC typoascent_add \NC number \NC \NC \NR
\NC typodescent_add \NC number \NC \NC \NR
\NC subsuper_set \NC number \NC \NC \NR
\NC panose_set \NC number \NC \NC \NR
\NC hheadset \NC number \NC \NC \NR
\NC vheadset \NC number \NC \NC \NR
\NC pfmfamily \NC number \NC \NC \NR
\NC weight \NC number \NC \NC \NR
\NC width \NC number \NC \NC \NR
\NC avgwidth \NC number \NC \NC \NR
\NC firstchar \NC number \NC \NC \NR
\NC lastchar \NC number \NC \NC \NR
\NC fstype \NC number \NC \NC \NR
\NC linegap \NC number \NC \NC \NR
\NC vlinegap \NC number \NC \NC \NR
\NC hhead_ascent \NC number \NC \NC \NR
\NC hhead_descent \NC number \NC \NC \NR
\NC os2_typoascent \NC number \NC \NC \NR
\NC os2_typodescent \NC number \NC \NC \NR
\NC os2_typolinegap \NC number \NC \NC \NR
\NC os2_winascent \NC number \NC \NC \NR
\NC os2_windescent \NC number \NC \NC \NR
\NC os2_subxsize \NC number \NC \NC \NR
\NC os2_subysize \NC number \NC \NC \NR
\NC os2_subxoff \NC number \NC \NC \NR
\NC os2_subyoff \NC number \NC \NC \NR
\NC os2_supxsize \NC number \NC \NC \NR
\NC os2_supysize \NC number \NC \NC \NR
\NC os2_supxoff \NC number \NC \NC \NR
\NC os2_supyoff \NC number \NC \NC \NR
\NC os2_strikeysize \NC number \NC \NC \NR
\NC os2_strikeypos \NC number \NC \NC \NR
\NC os2_family_class \NC number \NC \NC \NR
\NC os2_xheight \NC number \NC \NC \NR
\NC os2_capheight \NC number \NC \NC \NR
\NC os2_defaultchar \NC number \NC \NC \NR
\NC os2_breakchar \NC number \NC \NC \NR
\NC os2_vendor \NC string \NC \NC \NR
\NC codepages \NC table \NC A two-number array of encoded code pages\NC \NR
\NC unicoderages \NC table \NC A four-number array of encoded unicode ranges\NC \NR
\NC panose \NC table \NC \NC \NR
\stoptabulate
The \type {panose} subtable has exactly 10 string keys:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC familytype \NC string \NC Values as in the \OPENTYPE\ font
specification: \type {Any}, \type {No Fit},
\type {Text and Display}, \type {Script},
\type {Decorative}, \type {Pictorial} \NC
\NR
\NC serifstyle \NC string \NC See the \OPENTYPE\ font specification for
values \NC \NR
\NC weight \NC string \NC id. \NC \NR
\NC proportion \NC string \NC id. \NC \NR
\NC contrast \NC string \NC id. \NC \NR
\NC strokevariation \NC string \NC id. \NC \NR
\NC armstyle \NC string \NC id. \NC \NR
\NC letterform \NC string \NC id. \NC \NR
\NC midline \NC string \NC id. \NC \NR
\NC xheight \NC string \NC id. \NC \NR
\stoptabulate
\subsection[fontloadernamestable]{names table}
Each item has two top|-|level keys:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC lang \NC string \NC language for this entry \NC \NR
\NC names \NC table \NC \NC \NR
\stoptabulate
The \type {names} keys are the actual \TRUETYPE\ name strings. The possible keys
are:
\starttabulate[|lT|p|]
\NC \rmbf key \NC \bf explanation \NC \NR
\NC copyright \NC \NC \NR
\NC family \NC \NC \NR
\NC subfamily \NC \NC \NR
\NC uniqueid \NC \NC \NR
\NC fullname \NC \NC \NR
\NC version \NC \NC \NR
\NC postscriptname \NC \NC \NR
\NC trademark \NC \NC \NR
\NC manufacturer \NC \NC \NR
\NC designer \NC \NC \NR
\NC descriptor \NC \NC \NR
\NC venderurl \NC \NC \NR
\NC designerurl \NC \NC \NR
\NC license \NC \NC \NR
\NC licenseurl \NC \NC \NR
\NC idontknow \NC \NC \NR
\NC preffamilyname \NC \NC \NR
\NC prefmodifiers \NC \NC \NR
\NC compatfull \NC \NC \NR
\NC sampletext \NC \NC \NR
\NC cidfindfontname \NC \NC \NR
\NC wwsfamily \NC \NC \NR
\NC wwssubfamily \NC \NC \NR
\stoptabulate
\subsection{anchor_classes table}
The anchor_classes classes:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC name \NC string \NC a descriptive id of this anchor class\NC \NR
\NC lookup \NC string \NC \NC \NR
\NC type \NC string \NC one of \type {mark}, \type {mkmk}, \type {curs}, \type {mklg} \NC \NR
\stoptabulate
% type is actually a lookup subtype, not a feature name. Officially, these
% strings should be gpos_mark2mark etc.
\subsection{gpos table}
The \type {gpos} table has one array entry for each lookup. (The \type {gpos_}
prefix is somewhat redundant.)
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC type \NC string \NC one of \type {gpos_single}, \type {gpos_pair},
\type {gpos_cursive}, \type {gpos_mark2base},\crlf
\type {gpos_mark2ligature}, \type
{gpos_mark2mark}, \type {gpos_context},\crlf \type
{gpos_contextchain} \NC \NR
\NC flags \NC table \NC \NC \NR
\NC name \NC string \NC \NC \NR
\NC features \NC array \NC \NC \NR
\NC subtables \NC array \NC \NC \NR
\stoptabulate
The flags table has a true value for each of the lookup flags that is actually
set:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC r2l \NC boolean \NC \NC \NR
\NC ignorebaseglyphs \NC boolean \NC \NC \NR
\NC ignoreligatures \NC boolean \NC \NC \NR
\NC ignorecombiningmarks \NC boolean \NC \NC \NR
\NC mark_class \NC string \NC \NC \NR
\stoptabulate
The features subtable items of gpos have:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC tag \NC string \NC \NC \NR
\NC scripts \NC table \NC \NC \NR
\stoptabulate
The scripts table within features has:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC script \NC string \NC \NC \NR
\NC langs \NC array of strings \NC \NC \NR
\stoptabulate
The subtables table has:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC name \NC string \NC \NC \NR
\NC suffix \NC string \NC (only if used)\NC \NR % used by gpos_single to get a default
\NC anchor_classes \NC number \NC (only if used)\NC \NR
\NC vertical_kerning \NC number \NC (only if used)\NC \NR
\NC kernclass \NC table \NC (only if used)\NC \NR
\stoptabulate
The kernclass with subtables table has:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC firsts \NC array of strings \NC \NC \NR
\NC seconds \NC array of strings \NC \NC \NR
\NC lookup \NC string or array \NC associated lookup(s) \NC \NR
\NC offsets \NC array of numbers \NC \NC \NR
\stoptabulate
Note: the kernclass (as far as we can see) always has one entry so it could be one level
deep instead. Also the seconds start at \type {[2]} which is close to the fontforge
internals so we keep that too.
\subsection{gsub table}
This has identical layout to the \type {gpos} table, except for the
type:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC type \NC string \NC one of \type {gsub_single}, \type {gsub_multiple},
\type {gsub_alternate}, \type
{gsub_ligature},\crlf \type {gsub_context}, \type
{gsub_contextchain}, \type
{gsub_reversecontextchain} \NC \NR
\stoptabulate
\subsection{ttf_tables and ttf_tab_saved tables}
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC tag \NC string \NC \NC \NR
\NC len \NC number \NC \NC \NR
\NC maxlen \NC number \NC \NC \NR
\NC data \NC number \NC \NC \NR
\stoptabulate
\subsection{mm table}
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC axes \NC table \NC array of axis names \NC \NR
\NC instance_count \NC number \NC \NC \NR
\NC positions \NC table \NC array of instance positions
(\#axes * instances )\NC \NR
\NC defweights \NC table \NC array of default weights for instances \NC \NR
\NC cdv \NC string \NC \NC \NR
\NC ndv \NC string \NC \NC \NR
\NC axismaps \NC table \NC \NC \NR
\stoptabulate
The \type {axismaps}:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC blends \NC table \NC an array of blend points \NC \NR
\NC designs \NC table \NC an array of design values \NC \NR
\NC min \NC number \NC \NC \NR
\NC def \NC number \NC \NC \NR
\NC max \NC number \NC \NC \NR
\stoptabulate
\subsection{mark_classes table}
The keys in this table are mark class names, and the values are a
space|-|separated string of glyph names in this class.
\subsection{math table}
\starttabulate[|lT|p|]
\NC ScriptPercentScaleDown \NC \NC \NR
\NC ScriptScriptPercentScaleDown \NC \NC \NR
\NC DelimitedSubFormulaMinHeight \NC \NC \NR
\NC DisplayOperatorMinHeight \NC \NC \NR
\NC MathLeading \NC \NC \NR
\NC AxisHeight \NC \NC \NR
\NC AccentBaseHeight \NC \NC \NR
\NC FlattenedAccentBaseHeight \NC \NC \NR
\NC SubscriptShiftDown \NC \NC \NR
\NC SubscriptTopMax \NC \NC \NR
\NC SubscriptBaselineDropMin \NC \NC \NR
\NC SuperscriptShiftUp \NC \NC \NR
\NC SuperscriptShiftUpCramped \NC \NC \NR
\NC SuperscriptBottomMin \NC \NC \NR
\NC SuperscriptBaselineDropMax \NC \NC \NR
\NC SubSuperscriptGapMin \NC \NC \NR
\NC SuperscriptBottomMaxWithSubscript \NC \NC \NR
\NC SpaceAfterScript \NC \NC \NR
\NC UpperLimitGapMin \NC \NC \NR
\NC UpperLimitBaselineRiseMin \NC \NC \NR
\NC LowerLimitGapMin \NC \NC \NR
\NC LowerLimitBaselineDropMin \NC \NC \NR
\NC StackTopShiftUp \NC \NC \NR
\NC StackTopDisplayStyleShiftUp \NC \NC \NR
\NC StackBottomShiftDown \NC \NC \NR
\NC StackBottomDisplayStyleShiftDown \NC \NC \NR
\NC StackGapMin \NC \NC \NR
\NC StackDisplayStyleGapMin \NC \NC \NR
\NC StretchStackTopShiftUp \NC \NC \NR
\NC StretchStackBottomShiftDown \NC \NC \NR
\NC StretchStackGapAboveMin \NC \NC \NR
\NC StretchStackGapBelowMin \NC \NC \NR
\NC FractionNumeratorShiftUp \NC \NC \NR
\NC FractionNumeratorDisplayStyleShiftUp \NC \NC \NR
\NC FractionDenominatorShiftDown \NC \NC \NR
\NC FractionDenominatorDisplayStyleShiftDown \NC \NC \NR
\NC FractionNumeratorGapMin \NC \NC \NR
\NC FractionNumeratorDisplayStyleGapMin \NC \NC \NR
\NC FractionRuleThickness \NC \NC \NR
\NC FractionDenominatorGapMin \NC \NC \NR
\NC FractionDenominatorDisplayStyleGapMin \NC \NC \NR
\NC SkewedFractionHorizontalGap \NC \NC \NR
\NC SkewedFractionVerticalGap \NC \NC \NR
\NC OverbarVerticalGap \NC \NC \NR
\NC OverbarRuleThickness \NC \NC \NR
\NC OverbarExtraAscender \NC \NC \NR
\NC UnderbarVerticalGap \NC \NC \NR
\NC UnderbarRuleThickness \NC \NC \NR
\NC UnderbarExtraDescender \NC \NC \NR
\NC RadicalVerticalGap \NC \NC \NR
\NC RadicalDisplayStyleVerticalGap \NC \NC \NR
\NC RadicalRuleThickness \NC \NC \NR
\NC RadicalExtraAscender \NC \NC \NR
\NC RadicalKernBeforeDegree \NC \NC \NR
\NC RadicalKernAfterDegree \NC \NC \NR
\NC RadicalDegreeBottomRaisePercent \NC \NC \NR
\NC MinConnectorOverlap \NC \NC \NR
\NC FractionDelimiterSize \NC \NC \NR
\NC FractionDelimiterDisplayStyleSize \NC \NC \NR
\stoptabulate
\subsection{validation_state table}
\starttabulate[|lT|p|]
\NC \rmbf key \NC \bf explanation \NC \NR
\NC bad_ps_fontname \NC \NC \NR
\NC bad_glyph_table \NC \NC \NR
\NC bad_cff_table \NC \NC \NR
\NC bad_metrics_table \NC \NC \NR
\NC bad_cmap_table \NC \NC \NR
\NC bad_bitmaps_table \NC \NC \NR
\NC bad_gx_table \NC \NC \NR
\NC bad_ot_table \NC \NC \NR
\NC bad_os2_version \NC \NC \NR
\NC bad_sfnt_header \NC \NC \NR
\stoptabulate
\subsection{horiz_base and vert_base table}
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC tags \NC table \NC an array of script list tags\NC \NR
\NC scripts \NC table \NC \NC \NR
\stoptabulate
The \type {scripts} subtable:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC baseline \NC table \NC \NC \NR
\NC default_baseline \NC number \NC \NC \NR
\NC lang \NC table \NC \NC \NR
\stoptabulate
The \type {lang} subtable:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC tag \NC string \NC a script tag \NC \NR
\NC ascent \NC number \NC \NC \NR
\NC descent \NC number \NC \NC \NR
\NC features \NC table \NC \NC \NR
\stoptabulate
The \type {features} points to an array of tables with the same layout except
that in those nested tables, the tag represents a language.
\subsection{altuni table}
An array of alternate \UNICODE\ values. Inside that array are hashes with:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC unicode \NC number \NC this glyph is also used for this unicode \NC \NR
\NC variant \NC number \NC the alternative is driven by this unicode selector \NC \NR
\stoptabulate
\subsection{vert_variants and horiz_variants table}
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC variants \NC string \NC \NC \NR
\NC italic_correction \NC number \NC \NC \NR
\NC parts \NC table \NC \NC \NR
\stoptabulate
The \type {parts} table is an array of smaller tables:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC component \NC string \NC \NC \NR
\NC extender \NC number \NC \NC \NR
\NC start \NC number \NC \NC \NR
\NC end \NC number \NC \NC \NR
\NC advance \NC number \NC \NC \NR
\stoptabulate
\subsection{mathkern table}
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC top_right \NC table \NC \NC \NR
\NC bottom_right \NC table \NC \NC \NR
\NC top_left \NC table \NC \NC \NR
\NC bottom_left \NC table \NC \NC \NR
\stoptabulate
Each of the subtables is an array of small hashes with two keys:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC height \NC number \NC \NC \NR
\NC kern \NC number \NC \NC \NR
\stoptabulate
\subsection{kerns table}
Substructure is identical to the per|-|glyph subtable.
\subsection{vkerns table}
Substructure is identical to the per|-|glyph subtable.
\subsection{texdata table}
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC type \NC string \NC \type {unset}, \type {text}, \type {math}, \type {mathext} \NC \NR
\NC params \NC array \NC 22 font numeric parameters \NC \NR
\stoptabulate
\subsection{lookups table}
Top|-|level \type {lookups} is quite different from the ones at character level.
The keys in this hash are strings, the values the actual lookups, represented as
dictionary tables.
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC type \NC string \NC \NC \NR
\NC format \NC enum \NC one of \type {glyphs}, \type {class}, \type {coverage}, \type {reversecoverage} \NC \NR
\NC tag \NC string \NC \NC \NR
\NC current_class \NC array \NC \NC \NR
\NC before_class \NC array \NC \NC \NR
\NC after_class \NC array \NC \NC \NR
\NC rules \NC array \NC an array of rule items\NC \NR
\stoptabulate
Rule items have one common item and one specialized item:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC lookups \NC array \NC a linear array of lookup names\NC \NR
\NC glyphs \NC array \NC only if the parent's format is \type {glyphs}\NC \NR
\NC class \NC array \NC only if the parent's format is \type {class}\NC \NR
\NC coverage \NC array \NC only if the parent's format is \type {coverage}\NC \NR
\NC reversecoverage \NC array \NC only if the parent's format is \type {reversecoverage}\NC \NR
\stoptabulate
A glyph table is:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC names \NC string \NC \NC \NR
\NC back \NC string \NC \NC \NR
\NC fore \NC string \NC \NC \NR
\stoptabulate
A class table is:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC current \NC array \NC of numbers \NC \NR
\NC before \NC array \NC of numbers \NC \NR
\NC after \NC array \NC of numbers \NC \NR
\stoptabulate
coverage:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC current \NC array \NC of strings \NC \NR
\NC before \NC array \NC of strings\NC \NR
\NC after \NC array \NC of strings \NC \NR
\stoptabulate
reversecoverage:
\starttabulate[|lT|l|p|]
\NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
\NC current \NC array \NC of strings \NC \NR
\NC before \NC array \NC of strings\NC \NR
\NC after \NC array \NC of strings \NC \NR
\NC replacements \NC string \NC \NC \NR
\stoptabulate
\stopchapter
\stopcomponent
|