Debian Codegraph @

texk/ttfdump/include/tables.h

raw
1 /* tables.h -- define data structures for various ttf file internal tables
2 * See Also: True Type Font Specification
3 */
4
5 #ifndef __TTF_TABLES_H
6 #define __TTF_TABLES_H
7
8 /* $Id: tables.h,v 1.2 1998/07/06 06:07:01 werner Exp $ */
9
10 /* Offset Table:
11 * Into the beginning of a True Type font file
12 */
13 typedef struct
14 {
15 Fixed version;
16 USHORT numTables;
17 USHORT searchRange;
18 USHORT entrySelector;
19 USHORT rangeShift;
20 }
21 OffsetTable, *OffsetTablePtr;
22
23 /* Table Directory:
24 * The directory to find each table in a True Type font file
25 */
26 typedef struct
27 {
28 ULONG tag;
29 ULONG checksum;
30 ULONG offset;
31 ULONG length;
32 }
33 TableDir, *TableDirPtr;
34
35
36 /* cmap: Character to Glyph Index Mapping Table
37 * There are nine kinds of cmap, format 0, 2, 4, 6, 8, 10, 12,
38 * 13, and 14. They are defined as follows
39 */
40 typedef struct
41 {
42 USHORT format; /* = 0 */
43 USHORT length;
44 USHORT version;
45 BYTE glyphIndexArray[256];
46 }
47 CMAP0;
48
49 typedef struct
50 {
51 USHORT firstCode;
52 USHORT entryCount;
53 SHORT idDelta;
54 USHORT idRangeOffset;
55 }
56 SubHeader, *SubHeaderPtr;
57
58 typedef struct
59 {
60 USHORT format; /* = 2 */
61 USHORT length;
62 USHORT version;
63 USHORT subHeaderKeys[256];
64 SubHeaderPtr subHeaders;
65 USHORT *glyphIndexArray;
66 }
67 CMAP2;
68
69 typedef struct
70 {
71 USHORT format; /* = 4 */
72 USHORT length;
73 USHORT version;
74 USHORT segCountX2;
75 USHORT searchRange;
76 USHORT entrySelector;
77 USHORT rangeShift;
78 USHORT *endCount;
79 USHORT reservedPad;
80 USHORT *startCount;
81 USHORT *idDelta;
82 USHORT *idRangeOffset;
83 USHORT *glyphIndexArray;
84 }
85 CMAP4;
86
87 typedef struct
88 {
89 USHORT format; /* = 6 */
90 USHORT length;
91 USHORT version;
92 USHORT firstCode;
93 USHORT entryCount;
94 USHORT *glyphIndexArray;
95 }
96 CMAP6;
97
98 typedef struct
99 {
100 ULONG startCharCode;
101 ULONG endCharCode;
102 ULONG startGlyphID;
103 }
104 CharGroup, *CharGroupPtr;
105
106 typedef struct
107 {
108 USHORT format; /* = 8 */
109 ULONG length;
110 ULONG version;
111 BYTE is32[8192];
112 ULONG nGroups;
113 CharGroupPtr charGroup; /* size = nGroups */
114 }
115 CMAP8;
116
117 typedef struct
118 {
119 USHORT format; /* = 10 */
120 ULONG length;
121 ULONG version;
122 ULONG startCharCode;
123 ULONG numChars;
124 USHORT *glyphs;
125 }
126 CMAP10;
127
128 typedef struct
129 {
130 USHORT format; /* = 12 */
131 ULONG length;
132 ULONG version;
133 ULONG nGroups;
134 CharGroupPtr charGroup; /* size = nGroups */
135 }
136 CMAP12;
137
138 typedef struct
139 {
140 USHORT format; /* = 13 */
141 ULONG length;
142 ULONG version;
143 ULONG nGroups;
144 CharGroupPtr charGroup; /* size = nGroups */
145 }
146 CMAP13;
147
148 typedef struct
149 {
150 int notYet;
151 }
152 VarSelRec, *VarSelRecPtr;
153
154 typedef struct
155 {
156 USHORT format; /* = 14 */
157 ULONG length;
158 ULONG numVarSelRec;
159 VarSelRecPtr varSelRec; /* size = numVarSelRec */
160 }
161 CMAP14;
162
163 typedef union
164 {
165 USHORT *format;
166 CMAP0 *cmap0;
167 CMAP2 *cmap2;
168 CMAP4 *cmap4;
169 CMAP6 *cmap6;
170 CMAP8 *cmap8;
171 CMAP10 *cmap10;
172 CMAP12 *cmap12;
173 CMAP13 *cmap13;
174 CMAP14 *cmap14;
175 }
176 MapPtr;
177
178 /* Encoding: one for each encoding scheme */
179 typedef struct
180 {
181 /* encoding table */
182 USHORT PlatformID;
183 USHORT EncodingID;
184 ULONG offset;
185 USHORT mapindex;
186 MapPtr map;
187 }
188 Encoding, *EncodingPtr;
189
190 typedef struct
191 {
192 ULONG offset;
193 MapPtr map;
194 }
195 SubTable, *SubTablePtr;
196
197 typedef struct
198 {
199 USHORT version;
200 USHORT numberOfEncodings;
201 USHORT numberOfMaps;
202 EncodingPtr encoding; /* size = numberOfEncodings */
203 SubTablePtr subTable; /* size = numberOfMaps */
204 }
205 CMAP, *CMAPPtr;
206
207 /* glyf: Glyph Data table
208 * It is necessary to load "loca" table first to know where to load a specific
209 * glyph; the "loca" table itself depends on "head" and "maxp" tables
210 */
211 typedef F2Dot14 SCALE;
212
213 typedef struct
214 {
215 F2Dot14 xscale;
216 F2Dot14 yscale;
217 }
218 VECTOR;
219
220 typedef struct
221 {
222 F2Dot14 xscale;
223 F2Dot14 scale01;
224 F2Dot14 scale10;
225 F2Dot14 yscale;
226 }
227 TENSOR;
228
229 typedef struct
230 {
231 SHORT args[2]; /* need reconsideration */
232 union
233 {
234 SCALE scale;
235 VECTOR vector;
236 TENSOR tensor;
237 }
238 transform;
239 }
240 CompositeData;
241
242 typedef struct _component
243 {
244 USHORT flags;
245 USHORT glyphIndex;
246 CompositeData data;
247 struct _component *next, *previous; /* linked list used, no way to know
248 * how many components in advance */
249 }
250 Component;
251
252 typedef struct
253 {
254 SHORT numberOfContours;
255 FWord xMin;
256 FWord yMin;
257 FWord xMax;
258 FWord yMax;
259 /* simple glyph data */
260 USHORT *endPtsOfContours; /* size = numberOfContours */
261 USHORT instructionLength;
262 BYTE *instructions; /* size = instructionLength */
263 BYTE *flags; /* size = the total # of x,y
264 * coordinates, i.e. last number
265 * of endPtsOfContour */
266 SHORT *xCoordinates;
267 SHORT *yCoordinates;
268 Component *comp; /* a pointer to a linked list of
269 * composite components */
270 }
271 GLYF, *GLYFPtr;
272
273 /* Flags for Coordinates */
274 #define FLAGS_ON_CURVE 1
275 #define FLAGS_X_SHORT_VECTOR 2
276 #define FLAGS_Y_SHORT_VECTOR 4
277 #define FLAGS_REPEAT 8
278 #define FLAGS_X_SAME 0x10
279 #define FLAGS_Y_SAME 0x20
280
281 /* Flags for Composite Glyph */
282 #define ARG_1_AND_2_ARE_WORDS 0x001
283 #define ARGS_ARE_XY_VALUES 0x002
284 #define ROUND_XY_TO_GRID 0x004
285 #define WE_HAVE_A_SCALE 0x008
286 #define RESERVE 0x010
287 #define NO_OVERLAP 0x010
288 #define MORE_COMPONENT 0x020
289 #define WE_HAVE_AN_X_AND_Y_SCALE 0x040
290 #define WE_HAVE_A_TWO_BY_TWO 0x080
291 #define WE_HAVE_INSTRUCTIONS 0x100
292 #define USE_MY_METRICS 0x200
293 #define OVERLAP_COMPOUND 0x400 /* from Apple's TTF specs */
294
295 typedef struct
296 {
297 Fixed version;
298 Fixed fontRevision;
299 ULONG checkSumAdj;
300 ULONG magicNumber;
301 USHORT flags;
302 USHORT unitsPerEm;
303 ULONG created[2];
304 ULONG modified[2];
305 FWord xMin;
306 FWord yMin;
307 FWord xMax;
308 FWord yMax;
309 USHORT macStyle;
310 USHORT lowestRecPPEM;
311 SHORT fontDirectionHint;
312 SHORT indexToLocFormat; /* 0 => ushort, 1 => ulong */
313 SHORT glyphDataFormat;
314 }
315 HEAD, *HEADPtr;
316
317 #define FLAGS_Y_0 1
318 #define FLAGS_X_0 2
319 #define FLAGS_SIZE_DEP 4
320 #define FLAGS_INT_PPEM 8
321 #define FLAGS_ALT_WIDTH 0x10
322 #define MAC_STYLE_BOLD 1
323 #define MAC_STYLE_ITALIC 2
324 #define FONT_DIR_MIX 0
325 #define FONT_DIR_L2R 1
326 #define FONT_DIR_L2R_NEUTRALS 2
327 #define FONT_DIR_R2L -1
328 #define FONT_DIR_R2L_NEUTRALS -2
329 #define LOCA_OFFSET_SHORT 0
330 #define LOCA_OFFSET_LONG 1
331
332 typedef struct
333 {
334 Fixed version;
335 FWord Ascender;
336 FWord Descender;
337 FWord LineGap;
338 uFWord advanceWidthMax;
339 FWord minLeftSideBearing;
340 FWord minRightSideBearing;
341 FWord xMaxExtent;
342 SHORT caretSlopeRise;
343 SHORT caretSlopeRun;
344 SHORT reserved[5];
345 SHORT metricDataFormat;
346 USHORT numberOfHMetrics;
347 }
348 HHEA, *HHEAPtr;
349
350 /* for a new created HMTX, one have to fill numberofHMetrics manually for
351 * hhea */
352 typedef struct
353 {
354 uFWord advanceWidth;
355 FWord lsb;
356 }
357 longHorMetric;
358
359 typedef struct
360 { /* depends on hhea */
361 USHORT numberOfHMetrics; /* defined in hhea */
362 USHORT numberOfLSB; /* numGlyph - numberOfHMetrics */
363 longHorMetric *hMetrics;
364 FWord *leftSideBearing;
365 }
366 HMTX, *HMTXPtr;
367
368 /* for a newly created LOCA, one have to fill indexToLocFormat from head and
369 * numGlyphs from maxp manually */
370 typedef struct
371 { /* depends on head and maxp */
372 SHORT indexToLocFormat; /* defined in head */
373 USHORT numGlyphs; /* defined in maxp */
374 ULONG *offset;
375 }
376 LOCA, *LOCAPtr;
377
378 typedef struct
379 {
380 Fixed version;
381 USHORT numGlyphs;
382 USHORT maxPoints;
383 USHORT maxContours;
384 USHORT maxCompositePoints;
385 USHORT maxCompositeContours;
386 USHORT maxZones;
387 USHORT maxTwilightPoints;
388 USHORT maxStorage;
389 USHORT maxFunctionDefs;
390 USHORT maxInstructionDefs;
391 USHORT maxStackElements;
392 USHORT maxSizeOfInstructions;
393 USHORT maxComponentElements;
394 USHORT maxComponentDepth;
395 }
396 MAXP, *MAXPPtr;
397
398 typedef struct
399 {
400 USHORT PlatformID;
401 USHORT EncodingID;
402 USHORT LanguageID;
403 USHORT NameID;
404 USHORT length;
405 USHORT offset;
406 char *data;
407 }
408 NameRecord, *NameRecordPtr;
409
410 typedef struct
411 {
412 USHORT format;
413 USHORT numberOfRecords;
414 USHORT offset;
415 NameRecordPtr NameRecords;
416 }
417 NAME, *NAMEPtr;
418
419 typedef struct
420 {
421 USHORT numGlyphs; /* Should be the same as numGlyphs defined in maxp */
422 USHORT *glyphNameIndex;
423 CHAR **GlyphName;
424 }
425 Format20;
426
427 typedef struct
428 {
429 char *offset;
430 }
431 Format25;
432
433 typedef struct
434 {
435 Fixed format;
436 Fixed italicAngle;
437 FWord underlinePosition;
438 FWord underlineThickness;
439 ULONG isFixedPitch;
440 ULONG minMemType42;
441 ULONG maxMemType42;
442 ULONG minMemType1;
443 ULONG maxMemType1;
444 /* the elements below exist only for 2.0 and 2.5 format */
445 union
446 {
447 Format20 *format20;
448 Format25 *format25;
449 }
450 name;
451 }
452 POST, *POSTPtr;
453
454 typedef struct
455 {
456 USHORT version;
457 SHORT xAvgCharWidth;
458 USHORT usWeightClass;
459 USHORT usWidthClass;
460 USHORT fsType;
461 SHORT ySubscriptXSize;
462 SHORT ySubscriptYSize;
463 SHORT ySubscriptXOffset;
464 SHORT ySubscriptYOffset;
465 SHORT ySuperscriptXSize;
466 SHORT ySuperscriptYSize;
467 SHORT ySuperscriptXOffset;
468 SHORT ySuperscriptYOffset;
469 SHORT yStrikeoutSize;
470 SHORT yStrikeoutPosition;
471 SHORT sFamilyClass;
472 CHAR panose[10];
473 ULONG ulUnicodeRange1;
474 ULONG ulUnicodeRange2;
475 ULONG ulUnicodeRange3;
476 ULONG ulUnicodeRange4;
477 CHAR achVendID[5];
478 USHORT fsSelection;
479 USHORT usFirstCharIndex;
480 USHORT usLastCharIndex;
481 SHORT sTypoAscender;
482 SHORT sTypoDescender;
483 SHORT sTypoLineGap;
484 USHORT usWinAscent;
485 USHORT usWinDescent;
486 /* only version 1 tables */
487 ULONG ulCodePageRange1;
488 ULONG ulCodePageRange2;
489 /* only version 2 tables */
490 SHORT sxHeight;
491 SHORT sCapHeight;
492 USHORT usDefaultChar;
493 USHORT usBreakChar;
494 USHORT usMaxContext;
495 }
496 OS_2, *OS_2Ptr;
497
498 typedef struct
499 {
500 USHORT rangeMaxPPEM;
501 USHORT rangeGaspBehavior;
502 }
503 GASPRANGE;
504
505 typedef struct
506 {
507 USHORT version;
508 USHORT numRanges;
509 GASPRANGE *gaspRange; /* length = numRanges */
510 }
511 GASP, *GASPPtr;
512
513 /* flags for gasp */
514 #define GASP_GRIDFIT 0x0001
515 #define GASP_DOGRAY 0x0002
516
517 typedef struct
518 {
519 BYTE PixelSize;
520 BYTE MaxWidth;
521 BYTE *Width; /* length = numGlyphs */
522 }
523 DeviceRecord;
524
525 typedef struct
526 {
527 USHORT numGlyphs; /* defined in maxp, artifitial */
528 USHORT version;
529 SHORT numDevices;
530 LONG size;
531 DeviceRecord *Records;
532 }
533 HDMX, *HDMXPtr;
534
535 typedef struct
536 {
537 USHORT version;
538 USHORT length;
539 USHORT coverage;
540 union
541 {
542 struct
543 {
544 USHORT nPairs;
545 USHORT searchRange;
546 USHORT entrySelector;
547 USHORT rangeShift;
548 struct kernpair
549 {
550 USHORT left;
551 USHORT right;
552 FWord value;
553 }
554 *pairs;
555 }
556 kern0;
557
558 struct
559 {
560 USHORT rowWidth;
561 USHORT leftClassTable;
562 USHORT rightClassTable;
563 USHORT array;
564 }
565 kern2;
566 }
567 kern;
568 }
569 KernSubtable;
570
571 typedef struct
572 {
573 USHORT version;
574 USHORT nTables;
575 KernSubtable *subtable;
576 }
577 KERN, *KERNPtr;
578
579 typedef struct
580 {
581 USHORT version;
582 USHORT numGlyphs;
583 BYTE *yPels; /* length = numGlyphs */
584 }
585 LTSH, *LTSHPtr;
586
587 typedef struct
588 {
589 Fixed version;
590 ULONG FontNumber;
591 USHORT Pitch;
592 USHORT xHeight;
593 USHORT Style;
594 USHORT TypeFamily;
595 USHORT CapHeight;
596 USHORT SymbolSet;
597 CHAR Typeface[16];
598 CHAR CharacterComplement[8];
599 CHAR FileName[6];
600 CHAR StrokeWeight;
601 CHAR WidthType;
602 BYTE SerifStyle;
603 BYTE reserved;
604 }
605 PCLT, *PCLTPtr;
606
607 typedef struct
608 {
609 BYTE CharSet;
610 BYTE xRatio;
611 BYTE yStartRatio;
612 BYTE yEndRatio;
613 }
614 Ratios;
615
616 typedef struct
617 {
618 USHORT yPelHeight;
619 SHORT yMax;
620 SHORT yMin;
621 }
622 vTable;
623
624 typedef struct
625 {
626 USHORT recs;
627 BYTE startsz;
628 BYTE endsz;
629 vTable *entry;
630 }
631 Vdmx;
632
633 typedef struct
634 {
635 USHORT version;
636 USHORT numRecs;
637 USHORT numRatios;
638 Ratios *ratRange; /* length = numRatios */
639 USHORT *offset; /* length = numRatios */
640 Vdmx *groups;
641 }
642 VDMX, *VDMXPtr;
643
644 typedef struct
645 {
646 Fixed version;
647 SHORT ascent;
648 SHORT descent;
649 SHORT lineGap;
650 SHORT advanceHeightMax;
651 SHORT minTopSideBearing;
652 SHORT minBottomSideBearing;
653 SHORT yMaxExtent;
654 SHORT caretSlopeRise;
655 SHORT caretSlopeRun;
656 SHORT caretOffset;
657 SHORT reserved[4];
658 SHORT metricDataFormat;
659 USHORT numOfLongVerMetrics;
660 }
661 VHEA, *VHEAPtr;
662
663 typedef struct
664 {
665 uFWord advanceHeight;
666 FWord topSideBearing;
667 }
668 longVerMetric;
669
670 typedef struct
671 {
672 /* depends on vhea */
673 USHORT numOfLongVerMetrics; /* defined in vhea */
674 USHORT numOfTSB; /* numGlyph - numberOfHMetrics */
675 longVerMetric *vMetrics;
676 FWord *topSideBearing;
677 }
678 VMTX, *VMTXPtr;
679
680 /* Additional OpenType Tables */
681 #include "otftables.h"
682
683 #endif /* __TTF_TABLES_H */
684
685
686 /* end of tables.h */