| bungeman@google.com | 8ec9956 | 2012-02-07 21:30:21 +0000 | [diff] [blame] | 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 SkSFNTHeader_DEFINED |
| 9 | #define SkSFNTHeader_DEFINED |
| 10 | |
| 11 | #include "SkEndian.h" |
| bungeman@google.com | a550199 | 2012-05-18 19:06:41 +0000 | [diff] [blame^] | 12 | #include "SkOTTableTypes.h" |
| bungeman@google.com | 8ec9956 | 2012-02-07 21:30:21 +0000 | [diff] [blame] | 13 | |
| 14 | //All SK_SFNT_ prefixed types should be considered as big endian. |
| 15 | typedef uint16_t SK_SFNT_USHORT; |
| 16 | typedef uint32_t SK_SFNT_ULONG; |
| 17 | |
| 18 | #pragma pack(push, 1) |
| 19 | |
| 20 | struct SkSFNTHeader { |
| 21 | SK_SFNT_ULONG fontType; |
| 22 | static const SK_OT_ULONG fontType_WindowsTrueType = SkTEndian_SwapBE32(0x00010000); |
| 23 | static const SK_OT_ULONG fontType_MacTrueType = SkTEndian_SwapBE32('true'); |
| 24 | static const SK_OT_ULONG fontType_PostScript = SkTEndian_SwapBE32('typ1'); |
| 25 | static const SK_OT_ULONG fontType_OpenTypeCFF = SkTEndian_SwapBE32('OTTO'); |
| 26 | |
| 27 | SK_SFNT_USHORT numTables; |
| 28 | SK_SFNT_USHORT searchRange; |
| 29 | SK_SFNT_USHORT entrySelector; |
| 30 | SK_SFNT_USHORT rangeShift; |
| 31 | }; |
| 32 | |
| 33 | struct SkSFNTTableDirectoryEntry { |
| 34 | SK_SFNT_ULONG tag; |
| 35 | SK_SFNT_ULONG checksum; |
| 36 | SK_SFNT_ULONG offset; //From beginning of header. |
| 37 | SK_SFNT_ULONG logicalLength; |
| 38 | }; |
| 39 | |
| 40 | #pragma pack(pop) |
| 41 | |
| 42 | |
| 43 | SK_COMPILE_ASSERT(sizeof(SkSFNTHeader) == 12, sizeof_SkSFNTHeader_not_12); |
| 44 | SK_COMPILE_ASSERT(sizeof(SkSFNTTableDirectoryEntry) == 16, sizeof_SkSFNTTableDirectoryEntry_not_16); |
| 45 | |
| 46 | #endif |