1/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkOTTable_OS_2_VA_DEFINED
9#define SkOTTable_OS_2_VA_DEFINED
10
11#include "SkEndian.h"
12#include "SkIBMFamilyClass.h"
13#include "SkOTTableTypes.h"
14#include "SkPanose.h"
15#include "SkTypedEnum.h"
16
17#pragma pack(push, 1)
18
19//Original V0 TT
20struct SkOTTableOS2_VA {
21    SK_OT_USHORT version;
22    //SkOTTableOS2_VA::VERSION and SkOTTableOS2_V0::VERSION are both 0.
23    //The only way to differentiate these two versions is by the size of the table.
24    static const SK_OT_USHORT VERSION = SkTEndian_SwapBE16(0);
25
26    SK_OT_SHORT xAvgCharWidth;
27    struct WeightClass {
28        SK_TYPED_ENUM(Value, SK_OT_USHORT,
29            ((UltraLight, SkTEndian_SwapBE16(1)))
30            ((ExtraLight, SkTEndian_SwapBE16(2)))
31            ((Light, SkTEndian_SwapBE16(3)))
32            ((SemiLight, SkTEndian_SwapBE16(4)))
33            ((Medium, SkTEndian_SwapBE16(5)))
34            ((SemiBold, SkTEndian_SwapBE16(6)))
35            ((Bold, SkTEndian_SwapBE16(7)))
36            ((ExtraBold, SkTEndian_SwapBE16(8)))
37            ((UltraBold, SkTEndian_SwapBE16(9)))
38            SK_SEQ_END,
39        (value)SK_SEQ_END)
40    } usWeightClass;
41    struct WidthClass {
42        SK_TYPED_ENUM(Value, SK_OT_USHORT,
43            ((UltraCondensed, SkTEndian_SwapBE16(1)))
44            ((ExtraCondensed, SkTEndian_SwapBE16(2)))
45            ((Condensed, SkTEndian_SwapBE16(3)))
46            ((SemiCondensed, SkTEndian_SwapBE16(4)))
47            ((Medium, SkTEndian_SwapBE16(5)))
48            ((SemiExpanded, SkTEndian_SwapBE16(6)))
49            ((Expanded, SkTEndian_SwapBE16(7)))
50            ((ExtraExpanded, SkTEndian_SwapBE16(8)))
51            ((UltraExpanded, SkTEndian_SwapBE16(9)))
52            SK_SEQ_END,
53        (value)SK_SEQ_END)
54    } usWidthClass;
55    union Type {
56        struct Field {
57            //8-15
58            SK_OT_BYTE_BITFIELD(
59                Reserved08,
60                Reserved09,
61                Reserved10,
62                Reserved11,
63                Reserved12,
64                Reserved13,
65                Reserved14,
66                Reserved15)
67            //0-7
68            SK_OT_BYTE_BITFIELD(
69                Reserved00,
70                Restricted,
71                PreviewPrint,
72                Editable,
73                Reserved04,
74                Reserved05,
75                Reserved06,
76                Reserved07)
77        } field;
78        struct Raw {
79            static const SK_OT_USHORT Installable = 0;
80            static const SK_OT_USHORT RestrictedMask = SkOTSetUSHORTBit<1>::value;
81            static const SK_OT_USHORT PreviewPrintMask = SkOTSetUSHORTBit<2>::value;
82            static const SK_OT_USHORT EditableMask = SkOTSetUSHORTBit<3>::value;
83            SK_OT_USHORT value;
84        } raw;
85    } fsType;
86    SK_OT_SHORT ySubscriptXSize;
87    SK_OT_SHORT ySubscriptYSize;
88    SK_OT_SHORT ySubscriptXOffset;
89    SK_OT_SHORT ySubscriptYOffset;
90    SK_OT_SHORT ySuperscriptXSize;
91    SK_OT_SHORT ySuperscriptYSize;
92    SK_OT_SHORT ySuperscriptXOffset;
93    SK_OT_SHORT ySuperscriptYOffset;
94    SK_OT_SHORT yStrikeoutSize;
95    SK_OT_SHORT yStrikeoutPosition;
96    SkIBMFamilyClass sFamilyClass;
97    SkPanose panose;
98    SK_OT_ULONG ulCharRange[4];
99    SK_OT_CHAR achVendID[4];
100    union Selection {
101        struct Field {
102            //8-15
103            SK_OT_BYTE_BITFIELD(
104                Reserved08,
105                Reserved09,
106                Reserved10,
107                Reserved11,
108                Reserved12,
109                Reserved13,
110                Reserved14,
111                Reserved15)
112            //0-7
113            SK_OT_BYTE_BITFIELD(
114                Italic,
115                Underscore,
116                Negative,
117                Outlined,
118                Strikeout,
119                Bold,
120                Reserved06,
121                Reserved07)
122        } field;
123        struct Raw {
124            static const SK_OT_USHORT ItalicMask = SkOTSetUSHORTBit<0>::value;
125            static const SK_OT_USHORT UnderscoreMask = SkOTSetUSHORTBit<1>::value;
126            static const SK_OT_USHORT NegativeMask = SkOTSetUSHORTBit<2>::value;
127            static const SK_OT_USHORT OutlinedMask = SkOTSetUSHORTBit<3>::value;
128            static const SK_OT_USHORT StrikeoutMask = SkOTSetUSHORTBit<4>::value;
129            static const SK_OT_USHORT BoldMask = SkOTSetUSHORTBit<5>::value;
130            SK_OT_USHORT value;
131        } raw;
132    } fsSelection;
133    SK_OT_USHORT usFirstCharIndex;
134    SK_OT_USHORT usLastCharIndex;
135};
136
137#pragma pack(pop)
138
139
140SK_COMPILE_ASSERT(sizeof(SkOTTableOS2_VA) == 68, sizeof_SkOTTableOS2_VA_not_68);
141
142#endif
143