blob: bf01ac916ed4927f25f415bd8b4dda5e61739035 [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"
bungeman@google.coma5501992012-05-18 19:06:41 +000012#include "SkOTTableTypes.h"
bungeman@google.com8ec99562012-02-07 21:30:21 +000013
14//All SK_SFNT_ prefixed types should be considered as big endian.
15typedef uint16_t SK_SFNT_USHORT;
16typedef uint32_t SK_SFNT_ULONG;
17
18#pragma pack(push, 1)
19
20struct 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
33struct 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
43SK_COMPILE_ASSERT(sizeof(SkSFNTHeader) == 12, sizeof_SkSFNTHeader_not_12);
44SK_COMPILE_ASSERT(sizeof(SkSFNTTableDirectoryEntry) == 16, sizeof_SkSFNTTableDirectoryEntry_not_16);
45
46#endif