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_head_DEFINED |
9 | #define SkOTTable_head_DEFINED |
10 | |
11 | #include "src/core/SkEndian.h" |
12 | #include "src/sfnt/SkOTTableTypes.h" |
13 | |
14 | #pragma pack(push, 1) |
15 | |
16 | struct SkOTTableHead { |
17 | static const SK_OT_CHAR TAG0 = 'h'; |
18 | static const SK_OT_CHAR TAG1 = 'e'; |
19 | static const SK_OT_CHAR TAG2 = 'a'; |
20 | static const SK_OT_CHAR TAG3 = 'd'; |
21 | static const SK_OT_ULONG TAG = SkOTTableTAG<SkOTTableHead>::value; |
22 | |
23 | SK_OT_Fixed version; |
24 | static const SK_OT_Fixed version1 = SkTEndian_SwapBE32(0x00010000); |
25 | SK_OT_Fixed fontRevision; |
26 | static const uint32_t fontChecksum = 0xB1B0AFBA; //checksum of all TT fonts |
27 | SK_OT_ULONG checksumAdjustment; |
28 | SK_OT_ULONG magicNumber; |
29 | static const SK_OT_ULONG magicNumberConst = SkTEndian_SwapBE32(0x5F0F3CF5); |
30 | union Flags { |
31 | struct Field { |
32 | //8-15 |
33 | SK_OT_BYTE_BITFIELD( |
34 | GXMetamorphosis_Apple, |
35 | HasStrongRTL_Apple, |
36 | HasIndicStyleRearrangement, |
37 | AgfaMicroTypeExpressProcessed, |
38 | FontConverted, |
39 | DesignedForClearType, |
40 | LastResort, |
41 | Reserved15) |
42 | //0-7 |
43 | SK_OT_BYTE_BITFIELD( |
44 | BaselineAtY0, |
45 | LeftSidebearingAtX0, |
46 | InstructionsDependOnPointSize, |
47 | IntegerScaling, |
48 | InstructionsAlterAdvanceWidth, |
49 | VerticalCenteredGlyphs_Apple, |
50 | Reserved06, |
51 | RequiresLayout_Apple) |
52 | } field; |
53 | struct Raw { |
54 | static const SK_OT_USHORT BaselineAtY0Mask = SkTEndian_SwapBE16(1 << 0); |
55 | static const SK_OT_USHORT LeftSidebearingAtX0Mask = SkTEndian_SwapBE16(1 << 1); |
56 | static const SK_OT_USHORT InstructionsDependOnPointSizeMask = SkTEndian_SwapBE16(1 << 2); |
57 | static const SK_OT_USHORT IntegerScalingMask = SkTEndian_SwapBE16(1 << 3); |
58 | static const SK_OT_USHORT InstructionsAlterAdvanceWidthMask = SkTEndian_SwapBE16(1 << 4); |
59 | static const SK_OT_USHORT VerticalCenteredGlyphs_AppleMask = SkTEndian_SwapBE16(1 << 5); |
60 | //Reserved |
61 | static const SK_OT_USHORT RequiresLayout_AppleMask = SkTEndian_SwapBE16(1 << 7); |
62 | |
63 | static const SK_OT_USHORT GXMetamorphosis_AppleMask = SkTEndian_SwapBE16(1 << 8); |
64 | static const SK_OT_USHORT HasStrongRTL_AppleMask = SkTEndian_SwapBE16(1 << 9); |
65 | static const SK_OT_USHORT HasIndicStyleRearrangementMask = SkTEndian_SwapBE16(1 << 10); |
66 | static const SK_OT_USHORT AgfaMicroTypeExpressProcessedMask = SkTEndian_SwapBE16(1 << 11); |
67 | static const SK_OT_USHORT FontConvertedMask = SkTEndian_SwapBE16(1 << 12); |
68 | static const SK_OT_USHORT DesignedForClearTypeMask = SkTEndian_SwapBE16(1 << 13); |
69 | static const SK_OT_USHORT LastResortMask = SkTEndian_SwapBE16(1 << 14); |
70 | //Reserved |
71 | SK_OT_USHORT value; |
72 | } raw; |
73 | } flags; |
74 | SK_OT_USHORT unitsPerEm; |
75 | SK_OT_LONGDATETIME created; |
76 | SK_OT_LONGDATETIME modified; |
77 | SK_OT_SHORT xMin; |
78 | SK_OT_SHORT yMin; |
79 | SK_OT_SHORT xMax; |
80 | SK_OT_SHORT yMax; |
81 | union MacStyle { |
82 | struct Field { |
83 | //8-15 |
84 | SK_OT_BYTE_BITFIELD( |
85 | Reserved08, |
86 | Reserved09, |
87 | Reserved10, |
88 | Reserved11, |
89 | Reserved12, |
90 | Reserved13, |
91 | Reserved14, |
92 | Reserved15) |
93 | //0-7 |
94 | SK_OT_BYTE_BITFIELD( |
95 | Bold, |
96 | Italic, |
97 | Underline, |
98 | Outline, |
99 | Shadow, |
100 | Condensed, |
101 | Extended, |
102 | Reserved07) |
103 | } field; |
104 | struct Raw { |
105 | static const SK_OT_USHORT BoldMask = SkTEndian_SwapBE16(1); |
106 | static const SK_OT_USHORT ItalicMask = SkTEndian_SwapBE16(1 << 1); |
107 | static const SK_OT_USHORT UnderlineMask = SkTEndian_SwapBE16(1 << 2); |
108 | static const SK_OT_USHORT OutlineMask = SkTEndian_SwapBE16(1 << 3); |
109 | static const SK_OT_USHORT ShadowMask = SkTEndian_SwapBE16(1 << 4); |
110 | static const SK_OT_USHORT CondensedMask = SkTEndian_SwapBE16(1 << 5); |
111 | static const SK_OT_USHORT ExtendedMask = SkTEndian_SwapBE16(1 << 6); |
112 | |
113 | SK_OT_USHORT value; |
114 | } raw; |
115 | } macStyle; |
116 | SK_OT_USHORT lowestRecPPEM; |
117 | struct FontDirectionHint { |
118 | enum Value : SK_OT_SHORT { |
119 | FullyMixedDirectionalGlyphs = SkTEndian_SwapBE16(0), |
120 | OnlyStronglyLTR = SkTEndian_SwapBE16(1), |
121 | StronglyLTR = SkTEndian_SwapBE16(2), |
122 | OnlyStronglyRTL = static_cast<SK_OT_SHORT>(SkTEndian_SwapBE16((uint16_t)-1)), |
123 | StronglyRTL = static_cast<SK_OT_SHORT>(SkTEndian_SwapBE16((uint16_t)-2)), |
124 | } value; |
125 | } fontDirectionHint; |
126 | struct IndexToLocFormat { |
127 | enum Value : SK_OT_SHORT { |
128 | ShortOffsets = SkTEndian_SwapBE16(0), |
129 | LongOffsets = SkTEndian_SwapBE16(1), |
130 | } value; |
131 | } indexToLocFormat; |
132 | struct GlyphDataFormat { |
133 | enum Value : SK_OT_SHORT { |
134 | CurrentFormat = SkTEndian_SwapBE16(0), |
135 | } value; |
136 | } glyphDataFormat; |
137 | }; |
138 | |
139 | #pragma pack(pop) |
140 | |
141 | |
142 | #include <stddef.h> |
143 | static_assert(offsetof(SkOTTableHead, glyphDataFormat) == 52, "SkOTTableHead_glyphDataFormat_not_at_52" ); |
144 | static_assert(sizeof(SkOTTableHead) == 54, "sizeof_SkOTTableHead_not_54" ); |
145 | |
146 | #endif |
147 | |