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