1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/sfnt/SkSFNTHeader.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,70 @@ 1.4 +/* 1.5 + * Copyright 2012 Google Inc. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license that can be 1.8 + * found in the LICENSE file. 1.9 + */ 1.10 + 1.11 +#ifndef SkSFNTHeader_DEFINED 1.12 +#define SkSFNTHeader_DEFINED 1.13 + 1.14 +#include "SkEndian.h" 1.15 +#include "SkOTTableTypes.h" 1.16 + 1.17 +//All SK_SFNT_ prefixed types should be considered as big endian. 1.18 +typedef uint16_t SK_SFNT_USHORT; 1.19 +typedef uint32_t SK_SFNT_ULONG; 1.20 + 1.21 +#pragma pack(push, 1) 1.22 + 1.23 +struct SkSFNTHeader { 1.24 + SK_SFNT_ULONG fontType; 1.25 + struct fontType_WindowsTrueType { 1.26 + static const SK_OT_CHAR TAG0 = 0; 1.27 + static const SK_OT_CHAR TAG1 = 1; 1.28 + static const SK_OT_CHAR TAG2 = 0; 1.29 + static const SK_OT_CHAR TAG3 = 0; 1.30 + static const SK_OT_ULONG TAG = SkOTTableTAG<fontType_WindowsTrueType>::value; 1.31 + }; 1.32 + struct fontType_MacTrueType { 1.33 + static const SK_OT_CHAR TAG0 = 't'; 1.34 + static const SK_OT_CHAR TAG1 = 'r'; 1.35 + static const SK_OT_CHAR TAG2 = 'u'; 1.36 + static const SK_OT_CHAR TAG3 = 'e'; 1.37 + static const SK_OT_ULONG TAG = SkOTTableTAG<fontType_MacTrueType>::value; 1.38 + }; 1.39 + struct fontType_PostScript { 1.40 + static const SK_OT_CHAR TAG0 = 't'; 1.41 + static const SK_OT_CHAR TAG1 = 'y'; 1.42 + static const SK_OT_CHAR TAG2 = 'p'; 1.43 + static const SK_OT_CHAR TAG3 = '1'; 1.44 + static const SK_OT_ULONG TAG = SkOTTableTAG<fontType_PostScript>::value; 1.45 + }; 1.46 + struct fontType_OpenTypeCFF { 1.47 + static const SK_OT_CHAR TAG0 = 'O'; 1.48 + static const SK_OT_CHAR TAG1 = 'T'; 1.49 + static const SK_OT_CHAR TAG2 = 'T'; 1.50 + static const SK_OT_CHAR TAG3 = 'O'; 1.51 + static const SK_OT_ULONG TAG = SkOTTableTAG<fontType_OpenTypeCFF>::value; 1.52 + }; 1.53 + 1.54 + SK_SFNT_USHORT numTables; 1.55 + SK_SFNT_USHORT searchRange; 1.56 + SK_SFNT_USHORT entrySelector; 1.57 + SK_SFNT_USHORT rangeShift; 1.58 + 1.59 + struct TableDirectoryEntry { 1.60 + SK_SFNT_ULONG tag; 1.61 + SK_SFNT_ULONG checksum; 1.62 + SK_SFNT_ULONG offset; //From beginning of header. 1.63 + SK_SFNT_ULONG logicalLength; 1.64 + }; //tableDirectoryEntries[numTables] 1.65 +}; 1.66 + 1.67 +#pragma pack(pop) 1.68 + 1.69 + 1.70 +SK_COMPILE_ASSERT(sizeof(SkSFNTHeader) == 12, sizeof_SkSFNTHeader_not_12); 1.71 +SK_COMPILE_ASSERT(sizeof(SkSFNTHeader::TableDirectoryEntry) == 16, sizeof_SkSFNTHeader_TableDirectoryEntry_not_16); 1.72 + 1.73 +#endif