summaryrefslogtreecommitdiff
path: root/common/quicktime_win32/SFNTLayoutTypes.h
blob: aa167366b5199557814cbd8f321a2c046fdf77f3 (plain) (blame)
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
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
/*
     File:       SFNTLayoutTypes.h
 
     Contains:   SFNT file layout structures and constants.
 
     Version:    QuickTime 7.3
 
     Copyright:  (c) 2007 (c) 1994-2001 by Apple Computer, Inc., all rights reserved.
 
     Bugs?:      For bug reports, consult the following page on
                 the World Wide Web:
 
                     http://developer.apple.com/bugreporter/
 
*/
#ifndef __SFNTLAYOUTTYPES__
#define __SFNTLAYOUTTYPES__

#ifndef __MACTYPES__
#include <MacTypes.h>
#endif



#if PRAGMA_ONCE
#pragma once
#endif

#if PRAGMA_IMPORT
#pragma import on
#endif

#if PRAGMA_STRUCT_ALIGN
    #pragma options align=mac68k
#elif PRAGMA_STRUCT_PACKPUSH
    #pragma pack(push, 2)
#elif PRAGMA_STRUCT_PACK
    #pragma pack(2)
#endif

/* ----------------------------------------------------------------------------------------- */
/* CONSTANTS */
/*
    The following values can be used to set run feature values. Note that unless the
    feature is defaulted differently in different fonts, the zero value for the
    selectors represents the default value.  Check the following URL site for further info:
    "http://fonts.apple.com/Registry"
*/


/*
 *  Summary:
 *    Feature types
 */
enum {
  kAllTypographicFeaturesType   = 0,
  kLigaturesType                = 1,
  kCursiveConnectionType        = 2,
  kLetterCaseType               = 3,
  kVerticalSubstitutionType     = 4,
  kLinguisticRearrangementType  = 5,
  kNumberSpacingType            = 6,
  kSmartSwashType               = 8,
  kDiacriticsType               = 9,
  kVerticalPositionType         = 10,
  kFractionsType                = 11,
  kOverlappingCharactersType    = 13,
  kTypographicExtrasType        = 14,
  kMathematicalExtrasType       = 15,
  kOrnamentSetsType             = 16,
  kCharacterAlternativesType    = 17,
  kDesignComplexityType         = 18,
  kStyleOptionsType             = 19,
  kCharacterShapeType           = 20,
  kNumberCaseType               = 21,
  kTextSpacingType              = 22,
  kTransliterationType          = 23,
  kAnnotationType               = 24,
  kKanaSpacingType              = 25,
  kIdeographicSpacingType       = 26,
  kUnicodeDecompositionType     = 27,
  kRubyKanaType                 = 28,
  kCJKSymbolAlternativesType    = 29,
  kIdeographicAlternativesType  = 30,
  kCJKVerticalRomanPlacementType = 31,
  kItalicCJKRomanType           = 32,
  kCJKRomanSpacingType          = 103,
  kLastFeatureType              = -1
};


/*
 *  Summary:
 *    Selectors for feature type kAllTypographicFeaturesType
 */
enum {
  kAllTypeFeaturesOnSelector    = 0,
  kAllTypeFeaturesOffSelector   = 1
};



/*
 *  Summary:
 *    Selectors for feature type kLigaturesType
 */
enum {
  kRequiredLigaturesOnSelector  = 0,
  kRequiredLigaturesOffSelector = 1,
  kCommonLigaturesOnSelector    = 2,
  kCommonLigaturesOffSelector   = 3,
  kRareLigaturesOnSelector      = 4,
  kRareLigaturesOffSelector     = 5,
  kLogosOnSelector              = 6,
  kLogosOffSelector             = 7,
  kRebusPicturesOnSelector      = 8,
  kRebusPicturesOffSelector     = 9,
  kDiphthongLigaturesOnSelector = 10,
  kDiphthongLigaturesOffSelector = 11,
  kSquaredLigaturesOnSelector   = 12,
  kSquaredLigaturesOffSelector  = 13,
  kAbbrevSquaredLigaturesOnSelector = 14,
  kAbbrevSquaredLigaturesOffSelector = 15,
  kSymbolLigaturesOnSelector    = 16,
  kSymbolLigaturesOffSelector   = 17
};


/*
 *  Summary:
 *    Selectors for feature type kCursiveConnectionType
 */
enum {
  kUnconnectedSelector          = 0,
  kPartiallyConnectedSelector   = 1,
  kCursiveSelector              = 2
};


/*
 *  Summary:
 *    Selectors for feature type kLetterCaseType
 */
enum {
  kUpperAndLowerCaseSelector    = 0,
  kAllCapsSelector              = 1,
  kAllLowerCaseSelector         = 2,
  kSmallCapsSelector            = 3,
  kInitialCapsSelector          = 4,
  kInitialCapsAndSmallCapsSelector = 5
};


/*
 *  Summary:
 *    Selectors for feature type kVerticalSubstitutionType
 */
enum {
  kSubstituteVerticalFormsOnSelector = 0,
  kSubstituteVerticalFormsOffSelector = 1
};


/*
 *  Summary:
 *    Selectors for feature type kLinguisticRearrangementType
 */
enum {
  kLinguisticRearrangementOnSelector = 0,
  kLinguisticRearrangementOffSelector = 1
};


/*
 *  Summary:
 *    Selectors for feature type kNumberSpacingType
 */
enum {
  kMonospacedNumbersSelector    = 0,
  kProportionalNumbersSelector  = 1,
  kThirdWidthNumbersSelector    = 2,
  kQuarterWidthNumbersSelector  = 3
};


/*
 *  Summary:
 *    Selectors for feature type kSmartSwashType
 */
enum {
  kWordInitialSwashesOnSelector = 0,
  kWordInitialSwashesOffSelector = 1,
  kWordFinalSwashesOnSelector   = 2,
  kWordFinalSwashesOffSelector  = 3,
  kLineInitialSwashesOnSelector = 4,
  kLineInitialSwashesOffSelector = 5,
  kLineFinalSwashesOnSelector   = 6,
  kLineFinalSwashesOffSelector  = 7,
  kNonFinalSwashesOnSelector    = 8,
  kNonFinalSwashesOffSelector   = 9
};


/*
 *  Summary:
 *    Selectors for feature type kDiacriticsType
 */
enum {
  kShowDiacriticsSelector       = 0,
  kHideDiacriticsSelector       = 1,
  kDecomposeDiacriticsSelector  = 2
};


/*
 *  Summary:
 *    Selectors for feature type kVerticalPositionType
 */
enum {
  kNormalPositionSelector       = 0,
  kSuperiorsSelector            = 1,
  kInferiorsSelector            = 2,
  kOrdinalsSelector             = 3
};


/*
 *  Summary:
 *    Selectors for feature type kFractionsType
 */
enum {
  kNoFractionsSelector          = 0,
  kVerticalFractionsSelector    = 1,
  kDiagonalFractionsSelector    = 2
};


/*
 *  Summary:
 *    Selectors for feature type kOverlappingCharactersType
 */
enum {
  kPreventOverlapOnSelector     = 0,
  kPreventOverlapOffSelector    = 1
};


/*
 *  Summary:
 *    Selectors for feature type kTypographicExtrasType
 */
enum {
  kHyphensToEmDashOnSelector    = 0,
  kHyphensToEmDashOffSelector   = 1,
  kHyphenToEnDashOnSelector     = 2,
  kHyphenToEnDashOffSelector    = 3,
  kSlashedZeroOnSelector        = 4,
  kSlashedZeroOffSelector       = 5,
  kFormInterrobangOnSelector    = 6,
  kFormInterrobangOffSelector   = 7,
  kSmartQuotesOnSelector        = 8,
  kSmartQuotesOffSelector       = 9,
  kPeriodsToEllipsisOnSelector  = 10,
  kPeriodsToEllipsisOffSelector = 11
};


/*
 *  Summary:
 *    Selectors for feature type kMathematicalExtrasType
 */
enum {
  kHyphenToMinusOnSelector      = 0,
  kHyphenToMinusOffSelector     = 1,
  kAsteriskToMultiplyOnSelector = 2,
  kAsteriskToMultiplyOffSelector = 3,
  kSlashToDivideOnSelector      = 4,
  kSlashToDivideOffSelector     = 5,
  kInequalityLigaturesOnSelector = 6,
  kInequalityLigaturesOffSelector = 7,
  kExponentsOnSelector          = 8,
  kExponentsOffSelector         = 9
};


/*
 *  Summary:
 *    Selectors for feature type kOrnamentSetsType
 */
enum {
  kNoOrnamentsSelector          = 0,
  kDingbatsSelector             = 1,
  kPiCharactersSelector         = 2,
  kFleuronsSelector             = 3,
  kDecorativeBordersSelector    = 4,
  kInternationalSymbolsSelector = 5,
  kMathSymbolsSelector          = 6
};


/*
 *  Summary:
 *    Selectors for feature type kCharacterAlternativesType
 */
enum {
  kNoAlternatesSelector         = 0
};


/*
 *  Summary:
 *    Selectors for feature type kDesignComplexityType
 */
enum {
  kDesignLevel1Selector         = 0,
  kDesignLevel2Selector         = 1,
  kDesignLevel3Selector         = 2,
  kDesignLevel4Selector         = 3,
  kDesignLevel5Selector         = 4
};


/*
 *  Summary:
 *    Selectors for feature type kStyleOptionsType
 */
enum {
  kNoStyleOptionsSelector       = 0,
  kDisplayTextSelector          = 1,
  kEngravedTextSelector         = 2,
  kIlluminatedCapsSelector      = 3,
  kTitlingCapsSelector          = 4,
  kTallCapsSelector             = 5
};


/*
 *  Summary:
 *    Selectors for feature type kCharacterShapeType
 */
enum {
  kTraditionalCharactersSelector = 0,
  kSimplifiedCharactersSelector = 1,
  kJIS1978CharactersSelector    = 2,
  kJIS1983CharactersSelector    = 3,
  kJIS1990CharactersSelector    = 4,
  kTraditionalAltOneSelector    = 5,
  kTraditionalAltTwoSelector    = 6,
  kTraditionalAltThreeSelector  = 7,
  kTraditionalAltFourSelector   = 8,
  kTraditionalAltFiveSelector   = 9,
  kExpertCharactersSelector     = 10
};


/*
 *  Summary:
 *    Selectors for feature type kNumberCaseType
 */
enum {
  kLowerCaseNumbersSelector     = 0,
  kUpperCaseNumbersSelector     = 1
};


/*
 *  Summary:
 *    Selectors for feature type kTextSpacingType
 */
enum {
  kProportionalTextSelector     = 0,
  kMonospacedTextSelector       = 1,
  kHalfWidthTextSelector        = 2
};


/*
 *  Summary:
 *    Selectors for feature type kTransliterationType
 */
enum {
  kNoTransliterationSelector    = 0,
  kHanjaToHangulSelector        = 1,
  kHiraganaToKatakanaSelector   = 2,
  kKatakanaToHiraganaSelector   = 3,
  kKanaToRomanizationSelector   = 4,
  kRomanizationToHiraganaSelector = 5,
  kRomanizationToKatakanaSelector = 6,
  kHanjaToHangulAltOneSelector  = 7,
  kHanjaToHangulAltTwoSelector  = 8,
  kHanjaToHangulAltThreeSelector = 9
};


/*
 *  Summary:
 *    Selectors for feature type kAnnotationType
 */
enum {
  kNoAnnotationSelector         = 0,
  kBoxAnnotationSelector        = 1,
  kRoundedBoxAnnotationSelector = 2,
  kCircleAnnotationSelector     = 3,
  kInvertedCircleAnnotationSelector = 4,
  kParenthesisAnnotationSelector = 5,
  kPeriodAnnotationSelector     = 6,
  kRomanNumeralAnnotationSelector = 7,
  kDiamondAnnotationSelector    = 8,
  kInvertedBoxAnnotationSelector = 9,
  kInvertedRoundedBoxAnnotationSelector = 10
};


/*
 *  Summary:
 *    Selectors for feature type kKanaSpacingType
 */
enum {
  kFullWidthKanaSelector        = 0,
  kProportionalKanaSelector     = 1
};


/*
 *  Summary:
 *    Selectors for feature type kIdeographicSpacingType
 */
enum {
  kFullWidthIdeographsSelector  = 0,
  kProportionalIdeographsSelector = 1,
  kHalfWidthIdeographsSelector  = 2
};


/*
 *  Summary:
 *    Selectors for feature type kUnicodeDecompositionType
 */
enum {
  kCanonicalCompositionOnSelector = 0,
  kCanonicalCompositionOffSelector = 1,
  kCompatibilityCompositionOnSelector = 2,
  kCompatibilityCompositionOffSelector = 3,
  kTranscodingCompositionOnSelector = 4,
  kTranscodingCompositionOffSelector = 5
};


/*
 *  Summary:
 *    Selectors for feature type kRubyKanaType
 */
enum {
  kNoRubyKanaSelector           = 0,
  kRubyKanaSelector             = 1
};


/*
 *  Summary:
 *    Selectors for feature type kCJKSymbolAlternativesType
 */
enum {
  kNoCJKSymbolAlternativesSelector = 0,
  kCJKSymbolAltOneSelector      = 1,
  kCJKSymbolAltTwoSelector      = 2,
  kCJKSymbolAltThreeSelector    = 3,
  kCJKSymbolAltFourSelector     = 4,
  kCJKSymbolAltFiveSelector     = 5
};


/*
 *  Summary:
 *    Selectors for feature type kIdeographicAlternativesType
 */
enum {
  kNoIdeographicAlternativesSelector = 0,
  kIdeographicAltOneSelector    = 1,
  kIdeographicAltTwoSelector    = 2,
  kIdeographicAltThreeSelector  = 3,
  kIdeographicAltFourSelector   = 4,
  kIdeographicAltFiveSelector   = 5
};


/*
 *  Summary:
 *    Selectors for feature type kCJKVerticalRomanPlacementType
 */
enum {
  kCJKVerticalRomanCenteredSelector = 0,
  kCJKVerticalRomanHBaselineSelector = 1
};


/*
 *  Summary:
 *    Selectors for feature type kItalicCJKRomanType
 */
enum {
  kNoCJKItalicRomanSelector     = 0,
  kCJKItalicRomanSelector       = 1
};


/*
 *  Summary:
 *    Selectors for feature type kCJKRomanSpacingType
 */
enum {
  kHalfWidthCJKRomanSelector    = 0,
  kProportionalCJKRomanSelector = 1,
  kDefaultCJKRomanSelector      = 2,
  kFullWidthCJKRomanSelector    = 3
};

/* --------------------------------------------------------------------------- */
/* ---------------- Table Specific Typedefs and Constants -------------------- */
/* --------------------------------------------------------------------------- */
/* FORMATS FOR TABLE: lookup tables - used within various other tables */
enum {
  kSFNTLookupSimpleArray        = 0,    /* a simple array indexed by glyph code */
  kSFNTLookupSegmentSingle      = 2,    /* segment mapping to single value */
  kSFNTLookupSegmentArray       = 4,    /* segment mapping to lookup array */
  kSFNTLookupSingleTable        = 6,    /* sorted list of glyph, value pairs */
  kSFNTLookupTrimmedArray       = 8     /* a simple trimmed array indexed by glyph code */
};

typedef UInt16                          SFNTLookupTableFormat;
typedef UInt16                          SFNTLookupValue;
typedef UInt16                          SFNTLookupOffset;
typedef UInt32                          SFNTLookupKind;
/*
    A BinarySearchHeader defines the five standard fields needed to perform quick
    lookups in a lookup table (note that using UInt16s, and not ItemCounts or
    similar types, is important here, since these tables are in fonts, and the
    documented font formats specify 16-bit quantities).
*/
struct SFNTLookupBinarySearchHeader {
  UInt16              unitSize;               /* size of a unit in bytes */
  UInt16              nUnits;                 /* number of units in table */
  UInt16              searchRange;            /* (largest power of two <= nUnits) * unitSize */
  UInt16              entrySelector;          /* log2 (largest power of two <= nUnits) */
  UInt16              rangeShift;             /* (nUnits - largest power of two <= nUnits) * unitSize */
};
typedef struct SFNTLookupBinarySearchHeader SFNTLookupBinarySearchHeader;
/* A format 0 lookup table maps all glyphs in the font to lookup values */
struct SFNTLookupArrayHeader {
  SFNTLookupValue     lookupValues[1];
};
typedef struct SFNTLookupArrayHeader    SFNTLookupArrayHeader;
/* A format 8 lookup table maps some range of glyphs in the font to lookup values */
struct SFNTLookupTrimmedArrayHeader {
  UInt16              firstGlyph;
  UInt16              count;
  SFNTLookupValue     valueArray[1];
};
typedef struct SFNTLookupTrimmedArrayHeader SFNTLookupTrimmedArrayHeader;
/*
    Format 2 and format 4 lookup tables map ranges of glyphs to either single lookup
    values (format 2), or per-glyph lookup values (format 4). Since both formats
    use the same kind of data, only one unified set of segment-related structures
    is defined.
*/
struct SFNTLookupSegment {
  UInt16              lastGlyph;
  UInt16              firstGlyph;
  UInt16              value[1];
};
typedef struct SFNTLookupSegment        SFNTLookupSegment;
struct SFNTLookupSegmentHeader {
  SFNTLookupBinarySearchHeader  binSearch;
  SFNTLookupSegment   segments[1];
};
typedef struct SFNTLookupSegmentHeader  SFNTLookupSegmentHeader;
/* A format 6 lookup table maps single glyphs to lookup values. */
struct SFNTLookupSingle {
  UInt16              glyph;
  UInt16              value[1];
};
typedef struct SFNTLookupSingle         SFNTLookupSingle;
struct SFNTLookupSingleHeader {
  SFNTLookupBinarySearchHeader  binSearch;
  SFNTLookupSingle    entries[1];
};
typedef struct SFNTLookupSingleHeader   SFNTLookupSingleHeader;
/* The format-specific part of the subtable header */
union SFNTLookupFormatSpecificHeader {
  SFNTLookupArrayHeader  theArray;
  SFNTLookupSegmentHeader  segment;
  SFNTLookupSingleHeader  single;
  SFNTLookupTrimmedArrayHeader  trimmedArray;
};
typedef union SFNTLookupFormatSpecificHeader SFNTLookupFormatSpecificHeader;
/* The overall subtable header */
struct SFNTLookupTable {
  SFNTLookupTableFormat  format;              /* table format */
  SFNTLookupFormatSpecificHeader  fsHeader;   /* format specific header */
};
typedef struct SFNTLookupTable          SFNTLookupTable;
typedef SFNTLookupTable *               SFNTLookupTablePtr;
typedef SFNTLookupTablePtr *            SFNTLookupTableHandle;
/* --------------------------------------------------------------------------- */
/* GENERAL FORMATS FOR STATE TABLES -- prefix "ST" */
enum {
  kSTClassEndOfText             = 0,
  kSTClassOutOfBounds           = 1,
  kSTClassDeletedGlyph          = 2,
  kSTClassEndOfLine             = 3,
  kSTSetMark                    = 0x8000,
  kSTNoAdvance                  = 0x4000,
  kSTMarkEnd                    = 0x2000,
  kSTLigActionMask              = 0x3FFF,
  kSTRearrVerbMask              = 0x000F
};

typedef UInt8                           STClass;
typedef UInt8                           STEntryIndex;
struct STHeader {
  UInt8               filler;
  STClass             nClasses;
  UInt16              classTableOffset;
  UInt16              stateArrayOffset;
  UInt16              entryTableOffset;
};
typedef struct STHeader                 STHeader;
struct STClassTable {
  UInt16              firstGlyph;
  UInt16              nGlyphs;
  STClass             classes[1];
};
typedef struct STClassTable             STClassTable;
struct STEntryZero {
  UInt16              newState;
  UInt16              flags;
};
typedef struct STEntryZero              STEntryZero;
struct STEntryOne {
  UInt16              newState;
  UInt16              flags;
  UInt16              offset1;
};
typedef struct STEntryOne               STEntryOne;
struct STEntryTwo {
  UInt16              newState;
  UInt16              flags;
  UInt16              offset1;
  UInt16              offset2;
};
typedef struct STEntryTwo               STEntryTwo;
/* --------------------------------------------------------------------------- */
/* GENERAL FORMATS FOR STATE TABLES to be used with 'morx' tables -- prefix "STX" */
enum {
  kSTXHasLigAction              = 0x2000
};


typedef UInt16                          STXClass;
typedef UInt16                          STXStateIndex;
typedef UInt16                          STXEntryIndex;
struct STXHeader {
  UInt32              nClasses;
  UInt32              classTableOffset;
  UInt32              stateArrayOffset;
  UInt32              entryTableOffset;
};
typedef struct STXHeader                STXHeader;

typedef SFNTLookupTable                 STXClassTable;
struct STXEntryZero {
  STXStateIndex       newState;
  UInt16              flags;
};
typedef struct STXEntryZero             STXEntryZero;
struct STXEntryOne {
  STXStateIndex       newState;
  UInt16              flags;
  UInt16              index1;
};
typedef struct STXEntryOne              STXEntryOne;
struct STXEntryTwo {
  STXStateIndex       newState;
  UInt16              flags;
  UInt16              index1;
  UInt16              index2;
};
typedef struct STXEntryTwo              STXEntryTwo;
/* --------------------------------------------------------------------------- */
/* FORMATS FOR TABLE: 'lcar' */
/* CONSTANTS */
enum {
  kLCARTag                      = 0x6C636172, /* 'lcar' */
  kLCARCurrentVersion           = 0x00010000, /* current version number for 'lcar' table */
  kLCARLinearFormat             = 0,
  kLCARCtlPointFormat           = 1
};

/* TYPES */
struct LcarCaretClassEntry {
  UInt16              count;
  UInt16              partials[1];            /* these are either FUnits or control-point numbers */
};
typedef struct LcarCaretClassEntry      LcarCaretClassEntry;
struct LcarCaretTable {
  Fixed               version;
  UInt16              format;
  SFNTLookupTable     lookup;
};
typedef struct LcarCaretTable           LcarCaretTable;
typedef LcarCaretTable *                LcarCaretTablePtr;
/* --------------------------------------------------------------------------- */
/* FORMATS FOR TABLE: 'just' */
/* CONSTANTS */
enum {
  kJUSTTag                      = 0x6A757374, /* 'just' */
  kJUSTCurrentVersion           = 0x00010000,
  kJUSTStandardFormat           = 0,
  kJUSTnoGlyphcode              = 0xFFFF, /* used in a pcConditionalAddAction */
  kJUSTpcDecompositionAction    = 0,
  kJUSTpcUnconditionalAddAction = 1,
  kJUSTpcConditionalAddAction   = 2,
  kJUSTpcGlyphStretchAction     = 3,
  kJUSTpcDuctilityAction        = 4,
  kJUSTpcGlyphRepeatAddAction   = 5
};

/* Justification priority levels */
enum {
  kJUSTKashidaPriority          = 0,
  kJUSTSpacePriority            = 1,
  kJUSTLetterPriority           = 2,
  kJUSTNullPriority             = 3,
  kJUSTPriorityCount            = 4
};

/* Justification flags */
enum {
  kJUSTOverridePriority         = 0x8000,
  kJUSTOverrideLimits           = 0x4000,
  kJUSTOverrideUnlimited        = 0x2000,
  kJUSTUnlimited                = 0x1000,
  kJUSTPriorityMask             = 0x0003
};

/* TYPES */
typedef UInt16                          JustPCActionType;
typedef UInt16                          JustificationFlags;
/* A JustPCDecompositionAction defines a ligature decomposition action. */
struct JustPCDecompositionAction {
  Fixed               lowerLimit;
  Fixed               upperLimit;
  UInt16              order;
  UInt16              count;
  UInt16              glyphs[1];
};
typedef struct JustPCDecompositionAction JustPCDecompositionAction;
/* A JUSTPCUnconditionalAddAction defines an unconditional glyph add action. */

typedef UInt16                          JustPCUnconditionalAddAction;
/*
    A JUSTPCConditionalAddAction defines a glyph substitution and add action. If the addGlyph
    is equal to kJUSTnoGlyphcode, then no glyph will be added, and the justification for
    the line will be redone.
*/
struct JustPCConditionalAddAction {
  Fixed               substThreshhold;        /* threshhold of growth factor at which subst occurs */
  UInt16              addGlyph;
  UInt16              substGlyph;
};
typedef struct JustPCConditionalAddAction JustPCConditionalAddAction;
/* A PCDuctilityAction defines a ductile axis along which the glyph will be varied. */
struct JustPCDuctilityAction {
  UInt32              ductilityAxis;
  Fixed               minimumLimit;
  Fixed               noStretchValue;
  Fixed               maximumLimit;
};
typedef struct JustPCDuctilityAction    JustPCDuctilityAction;
/*
    A PCGlyphRepetitionAction defines a glyph which will not be stretched or otherwise
    transformed, but rather which will be emplaced however many times are needed to fill
    the needed gap.
*/
struct JustPCGlyphRepeatAddAction {
  UInt16              flags;
  UInt16              glyph;
};
typedef struct JustPCGlyphRepeatAddAction JustPCGlyphRepeatAddAction;
/* PCActionSubrecords contain the actual postcompensation actions. */
struct JustPCActionSubrecord {
  UInt16              theClass;               /* justification class value associated with this rec */
  JustPCActionType    theType;
  UInt32              length;
  UInt32              data;                   /* not really a UInt32; cast as ptr to appropriate action */
};
typedef struct JustPCActionSubrecord    JustPCActionSubrecord;
/* The set of postcompensation records is defined in a PCAction struct. */
struct JustPCAction {
  UInt32              actionCount;            /* long for alignment purposes */
  JustPCActionSubrecord  actions[1];
};
typedef struct JustPCAction             JustPCAction;
/*
    JustWidthDeltaEntry is the justification table entry structure.  The justClass value (which is
    actually limited to 7 bits by the state table structure) is defined as a long for PPC alignment reasons.
*/
struct JustWidthDeltaEntry {
  UInt32              justClass;
  Fixed               beforeGrowLimit;        /* ems AW can grow by at most on LT */
  Fixed               beforeShrinkLimit;      /* ems AW can shrink by at most on LT */
  Fixed               afterGrowLimit;         /* ems AW can grow by at most on RB */
  Fixed               afterShrinkLimit;       /* ems AW can shrink by at most on RB */
  JustificationFlags  growFlags;              /* flags controlling grow case */
  JustificationFlags  shrinkFlags;            /* flags controlling shrink case */
};
typedef struct JustWidthDeltaEntry      JustWidthDeltaEntry;
struct JustWidthDeltaGroup {
  UInt32              count;
  JustWidthDeltaEntry  entries[1];
};
typedef struct JustWidthDeltaGroup      JustWidthDeltaGroup;
/* Overall structure of a postcompensation table is defined in PostcompTable. */
struct JustPostcompTable {
  SFNTLookupTable     lookupTable;
                                              /* action records here */
};
typedef struct JustPostcompTable        JustPostcompTable;
struct JustDirectionTable {
  UInt16              justClass;              /* offset to state table (0=none) */
  UInt16              widthDeltaClusters;     /* offset to clusters */
  UInt16              postcomp;               /* offset to postcomp table (0=none) */
  SFNTLookupTable     lookup;
};
typedef struct JustDirectionTable       JustDirectionTable;
struct JustTable {
  Fixed               version;
  UInt16              format;
  UInt16              horizHeaderOffset;
  UInt16              vertHeaderOffset;
};
typedef struct JustTable                JustTable;
/* --------------------------------------------------------------------------- */
/* FORMATS FOR TABLE: 'opbd' */
/* CONSTANTS */
enum {
  kOPBDTag                      = 0x6F706264, /* 'opbd' */
  kOPBDCurrentVersion           = 0x00010000,
  kOPBDDistanceFormat           = 0,
  kOPBDControlPointFormat       = 1
};

/* TYPES */

typedef UInt16                          OpbdTableFormat;
/*
    The OpbdSideValues struct is the lookup result from the FindSingle call for the
    optical tables. It contains the 4 FUnit values that are relevant to the specified
    glyph, or the 4 control gxPoint values.
*/
struct OpbdSideValues {
  SInt16              leftSideShift;
  SInt16              topSideShift;
  SInt16              rightSideShift;
  SInt16              bottomSideShift;
};
typedef struct OpbdSideValues           OpbdSideValues;
struct OpbdTable {
  Fixed               version;
  OpbdTableFormat     format;
  SFNTLookupTable     lookupTable;
};
typedef struct OpbdTable                OpbdTable;
/* --------------------------------------------------------------------------- */
/* FORMATS FOR TABLE: 'mort' */
/* CONSTANTS */
enum {
  kMORTTag                      = 0x6D6F7274, /* 'mort' */
  kMORTCurrentVersion           = 0x00010000, /* current version number for 'mort' table */
                                        /* Coverage masks */
  kMORTCoverVertical            = 0x8000,
  kMORTCoverDescending          = 0x4000,
  kMORTCoverIgnoreVertical      = 0x2000,
  kMORTCoverTypeMask            = 0x000F, /* Subtable types */
  kMORTRearrangementType        = 0,
  kMORTContextualType           = 1,
  kMORTLigatureType             = 2,
  kMORTSwashType                = 4,
  kMORTInsertionType            = 5,    /* Ligature subtable constants */
  kMORTLigLastAction            = (long)0x80000000,
  kMORTLigStoreLigature         = 0x40000000,
  kMORTLigFormOffsetMask        = 0x3FFFFFFF,
  kMORTLigFormOffsetShift       = 2,    /* Rearrangement subtable actions */
  kMORTraNoAction               = 0,    /*    no action   */
  kMORTraxA                     = 1,    /*      Ax => xA    */
  kMORTraDx                     = 2,    /*      xD => Dx    */
  kMORTraDxA                    = 3,    /*     AxD => DxA   */
  kMORTraxAB                    = 4,    /*   ABx => xAB   */
  kMORTraxBA                    = 5,    /*   ABx => xBA   */
  kMORTraCDx                    = 6,    /*   xCD => CDx   */
  kMORTraDCx                    = 7,    /*   xCD => DCx   */
  kMORTraCDxA                   = 8,    /*  AxCD => CDxA  */
  kMORTraDCxA                   = 9,    /*  AxCD => DCxA  */
  kMORTraDxAB                   = 10,   /*  ABxD => DxAB  */
  kMORTraDxBA                   = 11,   /*  ABxD => DxBA  */
  kMORTraCDxAB                  = 12,   /* ABxCD => CDxAB */
  kMORTraCDxBA                  = 13,   /* ABxCD => CDxBA */
  kMORTraDCxAB                  = 14,   /* ABxCD => DCxAB */
  kMORTraDCxBA                  = 15,   /* ABxCD => DCxBA */
                                        /* Insertion subtable constants */
  kMORTDoInsertionsBefore       = 0x80,
  kMORTIsSplitVowelPiece        = 0x40,
  kMORTInsertionsCountMask      = 0x3F,
  kMORTCurrInsertKashidaLike    = 0x2000,
  kMORTMarkInsertKashidaLike    = 0x1000,
  kMORTCurrInsertBefore         = 0x0800,
  kMORTMarkInsertBefore         = 0x0400,
  kMORTMarkJustTableCountMask   = 0x3F80,
  kMORTMarkJustTableCountShift  = 7,    /* JustTableIndex for marked character */
  kMORTCurrJustTableCountMask   = 0x007F,
  kMORTCurrJustTableCountShift  = 0,    /* JustTableIndex for current character */
  kMORTCurrInsertCountMask      = 0x03E0,
  kMORTCurrInsertCountShift     = 5,    /* count to insert after current glyphRec */
  kMORTMarkInsertCountMask      = 0x001F,
  kMORTMarkInsertCountShift     = 0     /* count to insert after marked glyphRec */
};

/* TYPES */

typedef UInt32                          MortSubtableMaskFlags;
typedef UInt32                          MortLigatureActionEntry;
struct MortRearrangementSubtable {
  STHeader            header;
};
typedef struct MortRearrangementSubtable MortRearrangementSubtable;
struct MortContextualSubtable {
  STHeader            header;
  UInt16              substitutionTableOffset;
};
typedef struct MortContextualSubtable   MortContextualSubtable;
struct MortLigatureSubtable {
  STHeader            header;
  UInt16              ligatureActionTableOffset;
  UInt16              componentTableOffset;
  UInt16              ligatureTableOffset;
};
typedef struct MortLigatureSubtable     MortLigatureSubtable;
struct MortSwashSubtable {
  SFNTLookupTable     lookup;
};
typedef struct MortSwashSubtable        MortSwashSubtable;
struct MortInsertionSubtable {
  STHeader            header;
};
typedef struct MortInsertionSubtable    MortInsertionSubtable;
union MortSpecificSubtable {
  MortRearrangementSubtable  rearrangement;
  MortContextualSubtable  contextual;
  MortLigatureSubtable  ligature;
  MortSwashSubtable   swash;
  MortInsertionSubtable  insertion;
};
typedef union MortSpecificSubtable      MortSpecificSubtable;
struct MortSubtable {
  UInt16              length;
  UInt16              coverage;
  MortSubtableMaskFlags  flags;
  MortSpecificSubtable  u;
};
typedef struct MortSubtable             MortSubtable;
struct MortFeatureEntry {
  UInt16              featureType;
  UInt16              featureSelector;
  MortSubtableMaskFlags  enableFlags;
  MortSubtableMaskFlags  disableFlags;
};
typedef struct MortFeatureEntry         MortFeatureEntry;
struct MortChain {
  MortSubtableMaskFlags  defaultFlags;        /* default flags for this chain */
  UInt32              length;                 /* byte length of this chain */
  UInt16              nFeatures;              /* number of feature entries */
  UInt16              nSubtables;             /* number of subtables */
  MortFeatureEntry    featureEntries[1];
                                              /* the subtables follow */
};
typedef struct MortChain                MortChain;
struct MortTable {
  Fixed               version;
  UInt32              nChains;
  MortChain           chains[1];
};
typedef struct MortTable                MortTable;
/* --------------------------------------------------------------------------- */
/* FORMATS FOR TABLE: 'morx' (version 2 and beyond metamorphosis tables) */
/* CONSTANTS */
enum {
  kMORXTag                      = 0x6D6F7278, /* 'morx' */
  kMORXCurrentVersion           = 0x00020000, /* version number for current 'morx' table */
                                        /* Coverage masks */
  kMORXCoverVertical            = (long)0x80000000,
  kMORXCoverDescending          = 0x40000000,
  kMORXCoverIgnoreVertical      = 0x20000000,
  kMORXCoverTypeMask            = 0x000000FF
};

/* TYPES */
struct MorxRearrangementSubtable {
  STXHeader           header;
};
typedef struct MorxRearrangementSubtable MorxRearrangementSubtable;
struct MorxContextualSubtable {
  STXHeader           header;
  UInt32              substitutionTableOffset;
};
typedef struct MorxContextualSubtable   MorxContextualSubtable;
struct MorxLigatureSubtable {
  STXHeader           header;
  UInt32              ligatureActionTableOffset;
  UInt32              componentTableOffset;
  UInt32              ligatureTableOffset;
};
typedef struct MorxLigatureSubtable     MorxLigatureSubtable;
struct MorxInsertionSubtable {
  STXHeader           header;
  UInt32              insertionGlyphTableOffset;
};
typedef struct MorxInsertionSubtable    MorxInsertionSubtable;
union MorxSpecificSubtable {
  MorxRearrangementSubtable  rearrangement;
  MorxContextualSubtable  contextual;
  MorxLigatureSubtable  ligature;
  MortSwashSubtable   swash;
  MorxInsertionSubtable  insertion;
};
typedef union MorxSpecificSubtable      MorxSpecificSubtable;
struct MorxSubtable {
  UInt32              length;
  UInt32              coverage;
  MortSubtableMaskFlags  flags;
  MorxSpecificSubtable  u;
};
typedef struct MorxSubtable             MorxSubtable;
struct MorxChain {
  MortSubtableMaskFlags  defaultFlags;        /* default flags for this chain */
  UInt32              length;                 /* byte length of this chain */
  UInt32              nFeatures;              /* number of feature entries */
  UInt32              nSubtables;             /* number of subtables */
  MortFeatureEntry    featureEntries[1];
                                              /* the subtables follow */
};
typedef struct MorxChain                MorxChain;
struct MorxTable {
  Fixed               version;
  UInt32              nChains;
  MorxChain           chains[1];
};
typedef struct MorxTable                MorxTable;
/* --------------------------------------------------------------------------- */
/* FORMATS FOR TABLE: 'prop' */
/* CONSTANTS */
enum {
  kPROPTag                      = 0x70726F70, /* 'prop' */
  kPROPCurrentVersion           = 0x00030000, /* current version number for 'prop' table */
  kPROPPairOffsetShift          = 8,
  kPROPPairOffsetSign           = 7,
  kPROPIsFloaterMask            = 0x8000, /* glyph is floater */
  kPROPCanHangLTMask            = 0x4000, /* glyph can hang left/top */
  kPROPCanHangRBMask            = 0x2000, /* glyph can hang right/bottom */
  kPROPUseRLPairMask            = 0x1000, /* if glyph lands in RL streak, use paired glyph */
  kPROPPairOffsetMask           = 0x0F00, /* 4-bit signed offset to other pair member */
  kPROPRightConnectMask         = 0x0080, /* glyph connects to glyph on right */
  kPROPZeroReserved             = 0x0060, /* must be zero */
  kPROPDirectionMask            = 0x001F /* direction bits */
};

/* These are the Unicode direction classes (plus the Special European Number class). */
enum {
  kPROPLDirectionClass          = 0,    /* Left-to-Right */
  kPROPRDirectionClass          = 1,    /* Right-to-Left */
  kPROPALDirectionClass         = 2,    /* Right-to-Left Arabic Letter */
  kPROPENDirectionClass         = 3,    /* European Number */
  kPROPESDirectionClass         = 4,    /* European Number Seperator */
  kPROPETDirectionClass         = 5,    /* European Number Terminator */
  kPROPANDirectionClass         = 6,    /* Arabic Number */
  kPROPCSDirectionClass         = 7,    /* Common Number Seperator */
  kPROPPSDirectionClass         = 8,    /* Paragraph Seperator (also referred to as Block Separator) */
  kPROPSDirectionClass          = 9,    /* Segment Seperator */
  kPROPWSDirectionClass         = 10,   /* Whitespace */
  kPROPONDirectionClass         = 11,   /* Other Neutral */
  kPROPSENDirectionClass        = 12,   /* Special European Number (not a Unicode class) */
  kPROPLREDirectionClass        = 13,   /* Left-to-Right Embeding */
  kPROPLRODirectionClass        = 14,   /* Left-to-Right Override */
  kPROPRLEDirectionClass        = 15,   /* Right-to-Left Embeding */
  kPROPRLODirectionClass        = 16,   /* Right-to-Left Override */
  kPROPPDFDirectionClass        = 17,   /* Pop Directional Format */
  kPROPNSMDirectionClass        = 18,   /* Non-Spacing Mark */
  kPROPBNDirectionClass         = 19,   /* Boundary Neutral */
  kPROPNumDirectionClasses      = 20    /* Number of Unicode directional types + Special European Number */
};

/* TYPES */

typedef UInt16                          PropCharProperties;
struct PropTable {
  Fixed               version;
  UInt16              format;
  PropCharProperties  defaultProps;
  SFNTLookupTable     lookup;
};
typedef struct PropTable                PropTable;
struct PropLookupSegment {
  UInt16              lastGlyph;
  UInt16              firstGlyph;
  UInt16              value;
};
typedef struct PropLookupSegment        PropLookupSegment;
struct PropLookupSingle {
  UInt16              glyph;
  PropCharProperties  props;
};
typedef struct PropLookupSingle         PropLookupSingle;
/* --------------------------------------------------------------------------- */
/* FORMATS FOR TABLE: 'trak' */
/* CONSTANTS */
enum {
  kTRAKTag                      = 0x7472616B, /* 'trak' */
  kTRAKCurrentVersion           = 0x00010000, /* current version number for 'trak' table */
  kTRAKUniformFormat            = 0     /*    kTRAKPerGlyphFormat         = 2*/
};

/* TYPES */

typedef SInt16                          TrakValue;
struct TrakTableEntry {
  Fixed               track;
  UInt16              nameTableIndex;
  UInt16              sizesOffset;            /* offset to array of TrackingValues */
};
typedef struct TrakTableEntry           TrakTableEntry;
struct TrakTableData {
  UInt16              nTracks;
  UInt16              nSizes;
  UInt32              sizeTableOffset;
  TrakTableEntry      trakTable[1];
};
typedef struct TrakTableData            TrakTableData;
struct TrakTable {
  Fixed               version;
  UInt16              format;
  UInt16              horizOffset;
  UInt16              vertOffset;
};
typedef struct TrakTable                TrakTable;
/* --------------------------------------------------------------------------- */
/* FORMATS FOR TABLE: 'kern' */
/* CONSTANTS */
enum {
  kKERNTag                      = 0x6B65726E, /* 'kern' */
  kKERNCurrentVersion           = 0x00010000,
  kKERNVertical                 = 0x8000, /* set if this table has vertical kerning information */
  kKERNResetCrossStream         = 0x8000, /* this value in a cross-stream table means reset to zero */
  kKERNCrossStream              = 0x4000, /* set if this table contains cross-stream kerning values */
  kKERNVariation                = 0x2000, /* set if this table contains variation kerning values */
  kKERNUnusedBits               = 0x1F00, /* UNUSED, MUST BE ZERO */
  kKERNFormatMask               = 0x00FF /* format of this subtable */
};

enum {
  kKERNOrderedList              = 0,    /* ordered list of kerning pairs */
  kKERNStateTable               = 1,    /* state table for n-way contextual kerning */
  kKERNSimpleArray              = 2,    /* simple n X m array of kerning values */
  kKERNIndexArray               = 3     /* modifed version of SimpleArray */
};

/* Message Type Flags */
enum {
  kKERNLineStart                = 0x00000001, /* Array of glyphs starts a line */
  kKERNLineEndKerning           = 0x00000002, /* Array of glyphs ends a line */
  kKERNNoCrossKerning           = 0x00000004, /* Prohibit cross kerning */
  kKERNNotesRequested           = 0x00000008, /* Caller wants kerning notes */
  kKERNNoStakeNote              = 1,    /* Indicates a glyph was involved in a kerning pair/group */
  kKERNCrossStreamResetNote     = 2,    /* Indicates a return-to-baseline in cross-stream kerning */
  kKERNNotApplied               = 0x00000001 /* All kerning values were zero, kerning call had no effect */
};

/* TYPES */

typedef UInt8                           KernTableFormat;
typedef UInt16                          KernSubtableInfo;
typedef SInt16                          KernKerningValue;
typedef UInt16                          KernArrayOffset;
/* header for version 0 kerning table */
struct KernVersion0Header {
  UInt16              version;                /* font version number (will be 0!) */
  UInt16              nTables;                /* number of subtables present */
  UInt16              firstSubtable[1];       /* first subtable starts here */
};
typedef struct KernVersion0Header       KernVersion0Header;
/* Header for a kerning table */
struct KernTableHeader {
  Fixed               version;                /* font version number (currently 1.0) */
  SInt32              nTables;                /* number of subtables present */
  UInt16              firstSubtable[1];       /* first subtable starts here */
};
typedef struct KernTableHeader          KernTableHeader;
typedef KernTableHeader *               KernTableHeaderPtr;
typedef KernTableHeaderPtr *            KernTableHeaderHandle;
/*
    F O R M A T   S P E C I F I C   D E F I N I T I O N S

    kernOrderedList:
    
    The table is a sorted list of [left glyph, right glyph, value] triples.
    There's enough information in the header so that the list can be
    efficiently binary searched. 
*/
/* defines a single kerning pair of Glyphcodes  */
struct KernKerningPair {
  UInt16              left;
  UInt16              right;
};
typedef struct KernKerningPair          KernKerningPair;
/* a single list entry */
struct KernOrderedListEntry {
  KernKerningPair     pair;                   /* the kerning pair */
  KernKerningValue    value;                  /* the kerning value for the above pair */
};
typedef struct KernOrderedListEntry     KernOrderedListEntry;
typedef KernOrderedListEntry *          KernOrderedListEntryPtr;
/* the header information for binary searching the list */
struct KernOrderedListHeader {
  UInt16              nPairs;                 /* number of kerning pairs in table */
  UInt16              searchRange;            /* (largest power of two <= nPairs) * entry size */
  UInt16              entrySelector;          /* log2 (largest power of two <= nPairs) */
  UInt16              rangeShift;             /* (nPairs - largest power of two <= nPairs) * entry size */
  UInt16              table[1];               /* entries are first glyph, second glyph, and value */
};
typedef struct KernOrderedListHeader    KernOrderedListHeader;
/* KernStateTable: like the the generic state tables */
struct KernStateHeader {
  STHeader            header;                 /* state table header */
  UInt16              valueTable;             /* offset to kerning value table */
  UInt8               firstTable[1];          /* first table starts here */
};
typedef struct KernStateHeader          KernStateHeader;
struct KernStateEntry {
  UInt16              newState;
  UInt16              flags;                  /* flags per above enum */
};
typedef struct KernStateEntry           KernStateEntry;
/*
    Kern offset table header.
    The offset table is a trimmed array from firstGlyph to limitGlyph.
    Glyphs outside of this range should get zero for right-hand glyphs
    and the offset of the beginning of the kerning array for left-hand glyphs.
*/
struct KernOffsetTable {
  UInt16              firstGlyph;             /* first glyph in class range */
  UInt16              nGlyphs;                /* number of glyphs in class range */
  KernArrayOffset     offsetTable[1];         /* offset table starts here */
};
typedef struct KernOffsetTable          KernOffsetTable;
typedef KernOffsetTable *               KernOffsetTablePtr;
/* Header information for accessing offset tables and kerning array */
/*
    KernSimpleArray:
    
    The array is an nXm array of kenring values. Each row in the array
    represents one left-hand glyph, and each column one right-hand glyph.
    The zeroth row and column always represent glyphs that are out of bounds
    and will always contain zero.
    
    A pair is looked up by indexing the left-hand glyph through the left
    offset table, the right-hand glyph through the right offset table,
    adding both offsets to the starting address of the kerning array,
    and fetching the kerning value pointed to.
*/
/* Kern offset table header. */
/* The offset table is a trimmed array from firstGlyph to limitGlyph. */
/* Glyphs outside of this range should get zero for right-hand glyphs */
/* and the offset of the beginning of the kerning array for left- */
/* hand glyphs. */
struct KernSimpleArrayHeader {
  UInt16              rowWidth;               /* width, in bytes, of a row in the table */
  UInt16              leftOffsetTable;        /* offset to left-hand offset table */
  UInt16              rightOffsetTable;       /* offset to right-hand offset table */
  KernArrayOffset     theArray;               /* offset to start of kerning array */
  UInt16              firstTable[1];          /* first offset table starts here... */
};
typedef struct KernSimpleArrayHeader    KernSimpleArrayHeader;
/* Index Array */
struct KernIndexArrayHeader {
  UInt16              glyphCount;
  UInt8               kernValueCount;
  UInt8               leftClassCount;
  UInt8               rightClassCount;
  UInt8               flags;                  /* set to 0 for now */
  SInt16              kernValue[1];           /* actual kerning values reference by index in kernIndex */
  UInt8               leftClass[1];           /* maps left glyph to offset into kern index */
  UInt8               rightClass[1];          /* maps right glyph to offset into kern index */
  UInt8               kernIndex[1];           /* contains indicies into kernValue */
};
typedef struct KernIndexArrayHeader     KernIndexArrayHeader;
/* format specific part of subtable header */
union KernFormatSpecificHeader {
  KernOrderedListHeader  orderedList;
  KernStateHeader     stateTable;
  KernSimpleArrayHeader  simpleArray;
  KernIndexArrayHeader  indexArray;
};
typedef union KernFormatSpecificHeader  KernFormatSpecificHeader;
/* version 0 subtable header */
struct KernVersion0SubtableHeader {
  UInt16              version;                /* kerning table version number */
  UInt16              length;                 /* length in bytes (including this header) */
  KernSubtableInfo    stInfo;                 /* sub-table info */
  KernFormatSpecificHeader  fsHeader;         /* format specific sub-header */
};
typedef struct KernVersion0SubtableHeader KernVersion0SubtableHeader;
/* Overall Subtable header format */
struct KernSubtableHeader {
  SInt32              length;                 /* length in bytes (including this header) */
  KernSubtableInfo    stInfo;                 /* subtable info */
  SInt16              tupleIndex;             /* tuple index for variation subtables */
  KernFormatSpecificHeader  fsHeader;         /* format specific sub-header */
};
typedef struct KernSubtableHeader       KernSubtableHeader;
typedef KernSubtableHeader *            KernSubtableHeaderPtr;
/* --------------------------------------------------------------------------- */
/* FORMATS FOR TABLE: 'bsln' */
/* CONSTANTS */
enum {
  kBSLNTag                      = 0x62736C6E, /* 'bsln' */
  kBSLNCurrentVersion           = 0x00010000, /* current version number for 'bsln' table */
  kBSLNDistanceFormatNoMap      = 0,
  kBSLNDistanceFormatWithMap    = 1,
  kBSLNControlPointFormatNoMap  = 2,
  kBSLNControlPointFormatWithMap = 3
};

/* Baseline classes and constants */
enum {
  kBSLNRomanBaseline            = 0,
  kBSLNIdeographicCenterBaseline = 1,
  kBSLNIdeographicLowBaseline   = 2,
  kBSLNHangingBaseline          = 3,
  kBSLNMathBaseline             = 4,
  kBSLNLastBaseline             = 31,
  kBSLNNumBaselineClasses       = kBSLNLastBaseline + 1,
  kBSLNNoBaselineOverride       = 255
};

/* TYPES */
typedef UInt32                          BslnBaselineClass;
/* The BslnBaselineRecord array defines the baseline deltas for the line. */
typedef Fixed                           BslnBaselineRecord[32];
/*
    BslnFormat0Part is the format-specific data for a distance table with no mapping (i.e.
    all the glyphs belong to the defaultBaseline).
*/
struct BslnFormat0Part {
  SInt16              deltas[32];
};
typedef struct BslnFormat0Part          BslnFormat0Part;
/* BslnFormat1Part is the format-specific data for a distance table with a gxMapping. */
struct BslnFormat1Part {
  SInt16              deltas[32];
  SFNTLookupTable     mappingData;
};
typedef struct BslnFormat1Part          BslnFormat1Part;
/*
    BslnFormat2Part is the format-specific data for a control-point table with no
    mapping (i.e. all the glyphs belong to the defaultBaseline). It specifies a single
    glyph to use and the set of control points in that glyph that designate each of
    the baselines.
*/
struct BslnFormat2Part {
  UInt16              stdGlyph;
  SInt16              ctlPoints[32];
};
typedef struct BslnFormat2Part          BslnFormat2Part;
/*
    BslnFormat3Part is the format-specific data for a distance table with a mapping. Like
    format 2, it contains a single glyph and its set of control-point values for each
    of the baselines.
*/
struct BslnFormat3Part {
  UInt16              stdGlyph;
  SInt16              ctlPoints[32];
  SFNTLookupTable     mappingData;
};
typedef struct BslnFormat3Part          BslnFormat3Part;
/* The BslnFormatUnion is a union containing the format-specific parts of the baseline table. */
union BslnFormatUnion {
  BslnFormat0Part     fmt0Part;
  BslnFormat1Part     fmt1Part;
  BslnFormat2Part     fmt2Part;
  BslnFormat3Part     fmt3Part;
};
typedef union BslnFormatUnion           BslnFormatUnion;
/* The table format used in BaselineTable */

typedef UInt16                          BslnTableFormat;
/* BaselineTable defines the top-level format of the baseline table in the font. */
struct BslnTable {
  Fixed               version;
  BslnTableFormat     format;
  UInt16              defaultBaseline;
  BslnFormatUnion     parts;
};
typedef struct BslnTable                BslnTable;
typedef BslnTable *                     BslnTablePtr;
/* --------------------------------------------------------------------------- */

#if PRAGMA_STRUCT_ALIGN
    #pragma options align=reset
#elif PRAGMA_STRUCT_PACKPUSH
    #pragma pack(pop)
#elif PRAGMA_STRUCT_PACK
    #pragma pack()
#endif

#ifdef PRAGMA_IMPORT_OFF
#pragma import off
#elif PRAGMA_IMPORT
#pragma import reset
#endif


#endif /* __SFNTLAYOUTTYPES__ */