aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sfnt
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-07 15:28:15 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-07 15:28:15 +0000
commitb5e34e22aa0e019e25f9f913f0e119a9a97e5562 (patch)
treec064647d66956478b92bf2adcb16025daafc29b3 /src/sfnt
parent2983ddd4b57a05e3262fe2c1964a34f1717a5a1c (diff)
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
Diffstat (limited to 'src/sfnt')
-rw-r--r--src/sfnt/SkOTTable_name.cpp13
-rw-r--r--src/sfnt/SkTTCFHeader.h56
2 files changed, 59 insertions, 10 deletions
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 <typename D, typename S> static D* SkTAfter(S const * const ptr, size_t count = 1) {
- return (D*)(ptr + count);
-}
-
-template <typename D, typename S> 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<const SkOTTableName::Record>(&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<char>(&fName, stringTableOffset);
+ const char* stringTable = SkTAddOffset<const char>(&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<char>(stringTable, nameOffset);
+ const char* nameString = SkTAddOffset<const char>(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<SkTTCFHeader>::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<dsigType_None>::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<dsigType_Format1>::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