From b5e34e22aa0e019e25f9f913f0e119a9a97e5562 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Tue, 7 May 2013 15:28:15 +0000 Subject: XPS ttc handling. R=reed@google.com Author: bungeman@google.com Review URL: https://chromiumcodereview.appspot.com/14873006 git-svn-id: http://skia.googlecode.com/svn/trunk@9037 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/sfnt/SkOTTable_name.cpp | 13 +++-------- src/sfnt/SkTTCFHeader.h | 56 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 src/sfnt/SkTTCFHeader.h (limited to 'src/sfnt') diff --git a/src/sfnt/SkOTTable_name.cpp b/src/sfnt/SkOTTable_name.cpp index 177cd8fd7c..0b309cd47d 100644 --- a/src/sfnt/SkOTTable_name.cpp +++ b/src/sfnt/SkOTTable_name.cpp @@ -10,6 +10,7 @@ #include "SkEndian.h" #include "SkString.h" #include "SkTSearch.h" +#include "SkTemplates.h" #include "SkUtils.h" static SkUnichar SkUTF16BE_NextUnichar(const uint16_t** srcPtr) { @@ -435,14 +436,6 @@ int BCP47FromLanguageIdCompare(const BCP47FromLanguageId* a, const BCP47FromLang } } -template static D* SkTAfter(S const * const ptr, size_t count = 1) { - return (D*)(ptr + count); -} - -template static D* SkTAddOffset(S const * const ptr, size_t byteOffset) { - return (D*)((char*)ptr + byteOffset); -} - bool SkOTTableName::Iterator::next(SkOTTableName::Iterator::Record& record) { const size_t nameRecordsCount = SkEndian_SwapBE16(fName.count); const SkOTTableName::Record* nameRecords = SkTAfter(&fName); @@ -459,12 +452,12 @@ bool SkOTTableName::Iterator::next(SkOTTableName::Iterator::Record& record) { } while (fType != -1 && nameRecord->nameID.fontSpecific != fType); const uint16_t stringTableOffset = SkEndian_SwapBE16(fName.stringOffset); - const char* stringTable = SkTAddOffset(&fName, stringTableOffset); + const char* stringTable = SkTAddOffset(&fName, stringTableOffset); // Decode the name into UTF-8. const uint16_t nameOffset = SkEndian_SwapBE16(nameRecord->offset); const uint16_t nameLength = SkEndian_SwapBE16(nameRecord->length); - const char* nameString = SkTAddOffset(stringTable, nameOffset); + const char* nameString = SkTAddOffset(stringTable, nameOffset); switch (nameRecord->platformID.value) { case SkOTTableName::Record::PlatformID::Windows: SkASSERT(SkOTTableName::Record::EncodingID::Windows::UnicodeBMPUCS2 diff --git a/src/sfnt/SkTTCFHeader.h b/src/sfnt/SkTTCFHeader.h new file mode 100644 index 0000000000..ffe792b857 --- /dev/null +++ b/src/sfnt/SkTTCFHeader.h @@ -0,0 +1,56 @@ +/* + * Copyright 2013 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkTTCFHeader_DEFINED +#define SkTTCFHeader_DEFINED + +#include "SkOTTableTypes.h" + +#pragma pack(push, 1) + +struct SkTTCFHeader { + SK_SFNT_ULONG ttcTag; + static const SK_OT_CHAR TAG0 = 't'; + static const SK_OT_CHAR TAG1 = 't'; + static const SK_OT_CHAR TAG2 = 'c'; + static const SK_OT_CHAR TAG3 = 'f'; + static const SK_OT_ULONG TAG = SkOTTableTAG::value; + + SK_OT_Fixed version; + static const SK_OT_Fixed version_1 = SkTEndian_SwapBE32(1 << 16); + static const SK_OT_Fixed version_2 = SkTEndian_SwapBE32(2 << 16); + + SK_OT_ULONG numOffsets; + //SK_OT_ULONG offset[numOffsets] + + struct Version2Ext { + SK_OT_ULONG dsigType; + struct dsigType_None { + static const SK_OT_CHAR TAG0 = 0; + static const SK_OT_CHAR TAG1 = 0; + static const SK_OT_CHAR TAG2 = 0; + static const SK_OT_CHAR TAG3 = 0; + static const SK_OT_ULONG TAG = SkOTTableTAG::value; + }; + struct dsigType_Format1 { + static const SK_OT_CHAR TAG0 = 'D'; + static const SK_OT_CHAR TAG1 = 'S'; + static const SK_OT_CHAR TAG2 = 'I'; + static const SK_OT_CHAR TAG3 = 'G'; + static const SK_OT_ULONG TAG = SkOTTableTAG::value; + }; + SK_OT_ULONG dsigLength; //Length of DSIG table (in bytes). + SK_OT_ULONG dsigOffset; //Offset of DSIG table from the beginning of file (in bytes). + };// version2ext (if version == version_2) +}; + +#pragma pack(pop) + + +SK_COMPILE_ASSERT(sizeof(SkTTCFHeader) == 12, sizeof_SkTTCFHeader_not_12); + +#endif -- cgit v1.2.3