aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sfnt
diff options
context:
space:
mode:
authorGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-25 14:26:48 +0000
committerGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-25 14:26:48 +0000
commitec95a4ae45e9bff1a92627372fd771b389813fec (patch)
treec2f4f0da101da9e51f47eb41f9388956e0deeb37 /src/sfnt
parent5df2a99861c61b5d967f8def1ff13514d0e1ed33 (diff)
Remove multi-byte character constants.
Diffstat (limited to 'src/sfnt')
-rw-r--r--src/sfnt/SkOTTableTypes.h11
-rw-r--r--src/sfnt/SkOTTable_OS_2.h40
-rw-r--r--src/sfnt/SkOTTable_head.h6
-rw-r--r--src/sfnt/SkOTTable_hhea.h6
-rw-r--r--src/sfnt/SkOTTable_name.h6
-rw-r--r--src/sfnt/SkOTTable_post.h6
-rw-r--r--src/sfnt/SkOTUtils.cpp4
-rw-r--r--src/sfnt/SkSFNTHeader.h32
8 files changed, 89 insertions, 22 deletions
diff --git a/src/sfnt/SkOTTableTypes.h b/src/sfnt/SkOTTableTypes.h
index 4073bd2c4e..5167e3c8a5 100644
--- a/src/sfnt/SkOTTableTypes.h
+++ b/src/sfnt/SkOTTableTypes.h
@@ -32,4 +32,15 @@ typedef uint64_t SK_OT_LONGDATETIME;
#define SK_OT_BYTE_BITFIELD SK_UINT8_BITFIELD
+template<typename T> class SkOTTableTAG {
+public:
+ /**
+ * SkOTTableTAG<T>::value is the big endian value of an OpenType table tag.
+ * It may be directly compared with raw big endian table data.
+ */
+ static const SK_OT_ULONG value = SkTEndian_SwapBE32(
+ SkSetFourByteTag(T::TAG0, T::TAG1, T::TAG2, T::TAG3)
+ );
+};
+
#endif
diff --git a/src/sfnt/SkOTTable_OS_2.h b/src/sfnt/SkOTTable_OS_2.h
index 9e1f8a419b..3f744264ab 100644
--- a/src/sfnt/SkOTTable_OS_2.h
+++ b/src/sfnt/SkOTTable_OS_2.h
@@ -17,26 +17,34 @@
#pragma pack(push, 1)
-union SkOTTableOS2 {
- //original V0 TT
- struct VA : SkOTTableOS2_VA { } vA;
- struct V0 : SkOTTableOS2_V0 { } v0;
- struct V1 : SkOTTableOS2_V1 { } v1;
- struct V2 : SkOTTableOS2_V2 { } v2;
- //makes fsType 0-3 exclusive
- struct V3 : SkOTTableOS2_V3 { } v3;
- //defines fsSelection bits 7-9
- struct V4 : SkOTTableOS2_V4 { } v4;
+struct SkOTTableOS2 {
+ static const SK_OT_CHAR TAG0 = 'O';
+ static const SK_OT_CHAR TAG1 = 'S';
+ static const SK_OT_CHAR TAG2 = '/';
+ static const SK_OT_CHAR TAG3 = '2';
+ static const SK_OT_ULONG TAG = SkOTTableTAG<SkOTTableOS2>::value;
+
+ union Version {
+ //original V0 TT
+ struct VA : SkOTTableOS2_VA { } vA;
+ struct V0 : SkOTTableOS2_V0 { } v0;
+ struct V1 : SkOTTableOS2_V1 { } v1;
+ struct V2 : SkOTTableOS2_V2 { } v2;
+ //makes fsType 0-3 exclusive
+ struct V3 : SkOTTableOS2_V3 { } v3;
+ //defines fsSelection bits 7-9
+ struct V4 : SkOTTableOS2_V4 { } v4;
+ } version;
};
#pragma pack(pop)
-SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::VA) == 68, sizeof_SkOTTableOS2__VA_not_68);
-SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::V0) == 78, sizeof_SkOTTableOS2__V0_not_78);
-SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::V1) == 86, sizeof_SkOTTableOS2__V1_not_86);
-SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::V2) == 96, sizeof_SkOTTableOS2__V2_not_96);
-SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::V3) == 96, sizeof_SkOTTableOS2__V3_not_96);
-SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::V4) == 96, sizeof_SkOTTableOS2__V4_not_96);
+SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::Version::VA) == 68, sizeof_SkOTTableOS2__VA_not_68);
+SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::Version::V0) == 78, sizeof_SkOTTableOS2__V0_not_78);
+SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::Version::V1) == 86, sizeof_SkOTTableOS2__V1_not_86);
+SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::Version::V2) == 96, sizeof_SkOTTableOS2__V2_not_96);
+SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::Version::V3) == 96, sizeof_SkOTTableOS2__V3_not_96);
+SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::Version::V4) == 96, sizeof_SkOTTableOS2__V4_not_96);
#endif
diff --git a/src/sfnt/SkOTTable_head.h b/src/sfnt/SkOTTable_head.h
index 627e9f067f..67b696f49a 100644
--- a/src/sfnt/SkOTTable_head.h
+++ b/src/sfnt/SkOTTable_head.h
@@ -15,6 +15,12 @@
#pragma pack(push, 1)
struct SkOTTableHead {
+ static const SK_OT_CHAR TAG0 = 'h';
+ static const SK_OT_CHAR TAG1 = 'e';
+ static const SK_OT_CHAR TAG2 = 'a';
+ static const SK_OT_CHAR TAG3 = 'd';
+ static const SK_OT_ULONG TAG = SkOTTableTAG<SkOTTableHead>::value;
+
SK_OT_Fixed version;
static const SK_OT_Fixed version1 = SkTEndian_SwapBE32(0x00010000);
SK_OT_Fixed fontRevision;
diff --git a/src/sfnt/SkOTTable_hhea.h b/src/sfnt/SkOTTable_hhea.h
index 0874bfd5da..b8a2070199 100644
--- a/src/sfnt/SkOTTable_hhea.h
+++ b/src/sfnt/SkOTTable_hhea.h
@@ -15,6 +15,12 @@
#pragma pack(push, 1)
struct SkOTTableHorizontalHeader {
+ static const SK_OT_CHAR TAG0 = 'h';
+ static const SK_OT_CHAR TAG1 = 'h';
+ static const SK_OT_CHAR TAG2 = 'e';
+ static const SK_OT_CHAR TAG3 = 'a';
+ static const SK_OT_ULONG TAG = SkOTTableTAG<SkOTTableHorizontalHeader>::value;
+
SK_OT_Fixed version;
static const SK_OT_Fixed version1 = SkTEndian_SwapBE32(0x00010000);
SK_OT_FWORD Ascender;
diff --git a/src/sfnt/SkOTTable_name.h b/src/sfnt/SkOTTable_name.h
index 67620865d9..3ee72f2590 100644
--- a/src/sfnt/SkOTTable_name.h
+++ b/src/sfnt/SkOTTable_name.h
@@ -15,6 +15,12 @@
#pragma pack(push, 1)
struct SkOTTableName {
+ static const SK_OT_CHAR TAG0 = 'n';
+ static const SK_OT_CHAR TAG1 = 'a';
+ static const SK_OT_CHAR TAG2 = 'm';
+ static const SK_OT_CHAR TAG3 = 'e';
+ static const SK_OT_ULONG TAG = SkOTTableTAG<SkOTTableName>::value;
+
SK_OT_USHORT format;
static const SK_OT_USHORT format_0 = SkTEndian_SwapBE16(0);
static const SK_OT_USHORT format_1 = SkTEndian_SwapBE16(1);
diff --git a/src/sfnt/SkOTTable_post.h b/src/sfnt/SkOTTable_post.h
index a5525d4780..f563b08b22 100644
--- a/src/sfnt/SkOTTable_post.h
+++ b/src/sfnt/SkOTTable_post.h
@@ -15,6 +15,12 @@
#pragma pack(push, 1)
struct SkOTTablePostScript {
+ static const SK_OT_CHAR TAG0 = 'p';
+ static const SK_OT_CHAR TAG1 = 'o';
+ static const SK_OT_CHAR TAG2 = 's';
+ static const SK_OT_CHAR TAG3 = 't';
+ static const SK_OT_ULONG TAG = SkOTTableTAG<SkOTTablePostScript>::value;
+
struct Format {
SK_TYPED_ENUM(Value, SK_OT_Fixed,
((version1, SkTEndian_SwapBE32(0x00010000)))
diff --git a/src/sfnt/SkOTUtils.cpp b/src/sfnt/SkOTUtils.cpp
index 8d57f853bb..61edabd02d 100644
--- a/src/sfnt/SkOTUtils.cpp
+++ b/src/sfnt/SkOTUtils.cpp
@@ -40,7 +40,7 @@ SkData* SkOTUtils::RenameFont(SkStream* fontData,
if (fontData->read(&tableEntry, sizeof(tableEntry)) < sizeof(tableEntry)) {
return NULL;
}
- if ('name' == SkEndian_SwapBE32(tableEntry.tag)) {
+ if (SkOTTableName::TAG == tableEntry.tag) {
break;
}
}
@@ -96,7 +96,7 @@ SkData* SkOTUtils::RenameFont(SkStream* fontData,
if (oldOffset > oldNameTableOffset) {
currentEntry->offset = SkEndian_SwapBE32(oldOffset - oldNameTablePhysicalSize);
}
- if ('head' == SkEndian_SwapBE32(tableEntry.tag)) {
+ if (SkOTTableHead::TAG == tableEntry.tag) {
headTableEntry = currentEntry;
}
}
diff --git a/src/sfnt/SkSFNTHeader.h b/src/sfnt/SkSFNTHeader.h
index bf01ac916e..c22065648a 100644
--- a/src/sfnt/SkSFNTHeader.h
+++ b/src/sfnt/SkSFNTHeader.h
@@ -19,10 +19,34 @@ typedef uint32_t SK_SFNT_ULONG;
struct SkSFNTHeader {
SK_SFNT_ULONG fontType;
- static const SK_OT_ULONG fontType_WindowsTrueType = SkTEndian_SwapBE32(0x00010000);
- static const SK_OT_ULONG fontType_MacTrueType = SkTEndian_SwapBE32('true');
- static const SK_OT_ULONG fontType_PostScript = SkTEndian_SwapBE32('typ1');
- static const SK_OT_ULONG fontType_OpenTypeCFF = SkTEndian_SwapBE32('OTTO');
+ struct fontType_WindowsTrueType {
+ static const SK_OT_CHAR TAG0 = 0;
+ static const SK_OT_CHAR TAG1 = 1;
+ static const SK_OT_CHAR TAG2 = 0;
+ static const SK_OT_CHAR TAG3 = 0;
+ static const SK_OT_ULONG TAG = SkOTTableTAG<fontType_WindowsTrueType>::value;
+ };
+ struct fontType_MacTrueType {
+ static const SK_OT_CHAR TAG0 = 't';
+ static const SK_OT_CHAR TAG1 = 'r';
+ static const SK_OT_CHAR TAG2 = 'u';
+ static const SK_OT_CHAR TAG3 = 'e';
+ static const SK_OT_ULONG TAG = SkOTTableTAG<fontType_MacTrueType>::value;
+ };
+ struct fontType_PostScript {
+ static const SK_OT_CHAR TAG0 = 't';
+ static const SK_OT_CHAR TAG1 = 'y';
+ static const SK_OT_CHAR TAG2 = 'p';
+ static const SK_OT_CHAR TAG3 = '1';
+ static const SK_OT_ULONG TAG = SkOTTableTAG<fontType_PostScript>::value;
+ };
+ struct fontType_OpenTypeCFF {
+ static const SK_OT_CHAR TAG0 = 'O';
+ static const SK_OT_CHAR TAG1 = 'T';
+ static const SK_OT_CHAR TAG2 = 'T';
+ static const SK_OT_CHAR TAG3 = 'O';
+ static const SK_OT_ULONG TAG = SkOTTableTAG<fontType_OpenTypeCFF>::value;
+ };
SK_SFNT_USHORT numTables;
SK_SFNT_USHORT searchRange;