michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef SkSFNTHeader_DEFINED michael@0: #define SkSFNTHeader_DEFINED michael@0: michael@0: #include "SkEndian.h" michael@0: #include "SkOTTableTypes.h" michael@0: michael@0: //All SK_SFNT_ prefixed types should be considered as big endian. michael@0: typedef uint16_t SK_SFNT_USHORT; michael@0: typedef uint32_t SK_SFNT_ULONG; michael@0: michael@0: #pragma pack(push, 1) michael@0: michael@0: struct SkSFNTHeader { michael@0: SK_SFNT_ULONG fontType; michael@0: struct fontType_WindowsTrueType { michael@0: static const SK_OT_CHAR TAG0 = 0; michael@0: static const SK_OT_CHAR TAG1 = 1; michael@0: static const SK_OT_CHAR TAG2 = 0; michael@0: static const SK_OT_CHAR TAG3 = 0; michael@0: static const SK_OT_ULONG TAG = SkOTTableTAG::value; michael@0: }; michael@0: struct fontType_MacTrueType { michael@0: static const SK_OT_CHAR TAG0 = 't'; michael@0: static const SK_OT_CHAR TAG1 = 'r'; michael@0: static const SK_OT_CHAR TAG2 = 'u'; michael@0: static const SK_OT_CHAR TAG3 = 'e'; michael@0: static const SK_OT_ULONG TAG = SkOTTableTAG::value; michael@0: }; michael@0: struct fontType_PostScript { michael@0: static const SK_OT_CHAR TAG0 = 't'; michael@0: static const SK_OT_CHAR TAG1 = 'y'; michael@0: static const SK_OT_CHAR TAG2 = 'p'; michael@0: static const SK_OT_CHAR TAG3 = '1'; michael@0: static const SK_OT_ULONG TAG = SkOTTableTAG::value; michael@0: }; michael@0: struct fontType_OpenTypeCFF { michael@0: static const SK_OT_CHAR TAG0 = 'O'; michael@0: static const SK_OT_CHAR TAG1 = 'T'; michael@0: static const SK_OT_CHAR TAG2 = 'T'; michael@0: static const SK_OT_CHAR TAG3 = 'O'; michael@0: static const SK_OT_ULONG TAG = SkOTTableTAG::value; michael@0: }; michael@0: michael@0: SK_SFNT_USHORT numTables; michael@0: SK_SFNT_USHORT searchRange; michael@0: SK_SFNT_USHORT entrySelector; michael@0: SK_SFNT_USHORT rangeShift; michael@0: michael@0: struct TableDirectoryEntry { michael@0: SK_SFNT_ULONG tag; michael@0: SK_SFNT_ULONG checksum; michael@0: SK_SFNT_ULONG offset; //From beginning of header. michael@0: SK_SFNT_ULONG logicalLength; michael@0: }; //tableDirectoryEntries[numTables] michael@0: }; michael@0: michael@0: #pragma pack(pop) michael@0: michael@0: michael@0: SK_COMPILE_ASSERT(sizeof(SkSFNTHeader) == 12, sizeof_SkSFNTHeader_not_12); michael@0: SK_COMPILE_ASSERT(sizeof(SkSFNTHeader::TableDirectoryEntry) == 16, sizeof_SkSFNTHeader_TableDirectoryEntry_not_16); michael@0: michael@0: #endif