aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sfnt
diff options
context:
space:
mode:
authorGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-20 18:52:23 +0000
committerGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-20 18:52:23 +0000
commita544f29496758de6ed2ebf5a53558574019c9da1 (patch)
treea69ac43e4d7e0babbcd08f788eb5b7179f9c3ef8 /src/sfnt
parent336b4da6b0d20f27f9980b03415354a2f0698e18 (diff)
Additional OpenType tables.
Diffstat (limited to 'src/sfnt')
-rw-r--r--src/sfnt/SkOTTableTypes.h10
-rw-r--r--src/sfnt/SkOTTable_OS_2.h2
-rw-r--r--src/sfnt/SkOTTable_OS_2_V0.h6
-rw-r--r--src/sfnt/SkOTTable_OS_2_V1.h3
-rw-r--r--src/sfnt/SkOTTable_OS_2_V2.h3
-rw-r--r--src/sfnt/SkOTTable_OS_2_V3.h3
-rw-r--r--src/sfnt/SkOTTable_OS_2_V4.h3
-rw-r--r--src/sfnt/SkOTTable_OS_2_VA.h6
-rw-r--r--src/sfnt/SkOTTable_glyf.h214
-rw-r--r--src/sfnt/SkOTTable_loca.h31
-rw-r--r--src/sfnt/SkOTTable_maxp.h34
-rw-r--r--src/sfnt/SkOTTable_maxp_CFF.h30
-rw-r--r--src/sfnt/SkOTTable_maxp_TT.h49
-rw-r--r--src/sfnt/SkOTUtils.cpp23
-rw-r--r--src/sfnt/SkOTUtils.h4
-rw-r--r--src/sfnt/SkSFNTHeader.h16
16 files changed, 408 insertions, 29 deletions
diff --git a/src/sfnt/SkOTTableTypes.h b/src/sfnt/SkOTTableTypes.h
index 5167e3c8a5..9adec9b81e 100644
--- a/src/sfnt/SkOTTableTypes.h
+++ b/src/sfnt/SkOTTableTypes.h
@@ -18,14 +18,16 @@ typedef signed char SK_OT_CHAR; //easier to debug
#else
typedef int8_t SK_OT_CHAR;
#endif
-typedef int16_t SK_OT_SHORT;
+typedef uint16_t SK_OT_SHORT;
typedef uint16_t SK_OT_USHORT;
typedef uint32_t SK_OT_ULONG;
-typedef int32_t SK_OT_LONG;
-//16.16 Fixed point representation.
+typedef uint32_t SK_OT_LONG;
+//16.16 Signed fixed point representation.
typedef int32_t SK_OT_Fixed;
+//2.14 Signed fixed point representation.
+typedef uint16_t SK_OT_F2DOT14;
//F units are the units of measurement in em space.
-typedef int16_t SK_OT_FWORD;
+typedef uint16_t SK_OT_FWORD;
typedef uint16_t SK_OT_UFWORD;
//Number of seconds since 12:00 midnight, January 1, 1904.
typedef uint64_t SK_OT_LONGDATETIME;
diff --git a/src/sfnt/SkOTTable_OS_2.h b/src/sfnt/SkOTTable_OS_2.h
index 3f744264ab..b89c944b2a 100644
--- a/src/sfnt/SkOTTable_OS_2.h
+++ b/src/sfnt/SkOTTable_OS_2.h
@@ -25,6 +25,8 @@ struct SkOTTableOS2 {
static const SK_OT_ULONG TAG = SkOTTableTAG<SkOTTableOS2>::value;
union Version {
+ SK_OT_USHORT version;
+
//original V0 TT
struct VA : SkOTTableOS2_VA { } vA;
struct V0 : SkOTTableOS2_V0 { } v0;
diff --git a/src/sfnt/SkOTTable_OS_2_V0.h b/src/sfnt/SkOTTable_OS_2_V0.h
index 25e8c9c3e0..26aa832f79 100644
--- a/src/sfnt/SkOTTable_OS_2_V0.h
+++ b/src/sfnt/SkOTTable_OS_2_V0.h
@@ -18,8 +18,10 @@
struct SkOTTableOS2_V0 {
SK_OT_USHORT version;
- //The only way to differentiate versionA and version0 is by size.
- static const SK_OT_USHORT version0 = SkTEndian_SwapBE16(0);
+ //SkOTTableOS2_VA::VERSION and SkOTTableOS2_V0::VERSION are both 0.
+ //The only way to differentiate these two versions is by the size of the table.
+ static const SK_OT_USHORT VERSION = SkTEndian_SwapBE16(0);
+
SK_OT_SHORT xAvgCharWidth;
struct WeightClass {
SK_TYPED_ENUM(Value, SK_OT_USHORT,
diff --git a/src/sfnt/SkOTTable_OS_2_V1.h b/src/sfnt/SkOTTable_OS_2_V1.h
index 47d9921c41..5136071b2a 100644
--- a/src/sfnt/SkOTTable_OS_2_V1.h
+++ b/src/sfnt/SkOTTable_OS_2_V1.h
@@ -18,7 +18,8 @@
struct SkOTTableOS2_V1 {
SK_OT_USHORT version;
- static const SK_OT_USHORT version1 = SkTEndian_SwapBE16(1);
+ static const SK_OT_USHORT VERSION = SkTEndian_SwapBE16(1);
+
SK_OT_SHORT xAvgCharWidth;
struct WeightClass {
SK_TYPED_ENUM(Value, SK_OT_USHORT,
diff --git a/src/sfnt/SkOTTable_OS_2_V2.h b/src/sfnt/SkOTTable_OS_2_V2.h
index ee1a2ddc95..69e8d6e9d8 100644
--- a/src/sfnt/SkOTTable_OS_2_V2.h
+++ b/src/sfnt/SkOTTable_OS_2_V2.h
@@ -18,7 +18,8 @@
struct SkOTTableOS2_V2 {
SK_OT_USHORT version;
- static const SK_OT_USHORT version2 = SkTEndian_SwapBE16(2);
+ static const SK_OT_USHORT VERSION = SkTEndian_SwapBE16(2);
+
SK_OT_SHORT xAvgCharWidth;
struct WeightClass {
SK_TYPED_ENUM(Value, SK_OT_USHORT,
diff --git a/src/sfnt/SkOTTable_OS_2_V3.h b/src/sfnt/SkOTTable_OS_2_V3.h
index ffd6d6a579..710078b315 100644
--- a/src/sfnt/SkOTTable_OS_2_V3.h
+++ b/src/sfnt/SkOTTable_OS_2_V3.h
@@ -18,7 +18,8 @@
struct SkOTTableOS2_V3 {
SK_OT_USHORT version;
- static const SK_OT_USHORT version3 = SkTEndian_SwapBE16(3);
+ static const SK_OT_USHORT VERSION = SkTEndian_SwapBE16(3);
+
SK_OT_SHORT xAvgCharWidth;
struct WeightClass {
SK_TYPED_ENUM(Value, SK_OT_USHORT,
diff --git a/src/sfnt/SkOTTable_OS_2_V4.h b/src/sfnt/SkOTTable_OS_2_V4.h
index 64c6e8cb9b..48c6eb0907 100644
--- a/src/sfnt/SkOTTable_OS_2_V4.h
+++ b/src/sfnt/SkOTTable_OS_2_V4.h
@@ -18,7 +18,8 @@
struct SkOTTableOS2_V4 {
SK_OT_USHORT version;
- static const SK_OT_USHORT version4 = SkTEndian_SwapBE16(4);
+ static const SK_OT_USHORT VERSION = SkTEndian_SwapBE16(4);
+
SK_OT_SHORT xAvgCharWidth;
struct WeightClass {
SK_TYPED_ENUM(Value, SK_OT_USHORT,
diff --git a/src/sfnt/SkOTTable_OS_2_VA.h b/src/sfnt/SkOTTable_OS_2_VA.h
index 22a022c2a6..a0d9a36593 100644
--- a/src/sfnt/SkOTTable_OS_2_VA.h
+++ b/src/sfnt/SkOTTable_OS_2_VA.h
@@ -19,8 +19,10 @@
//Original V0 TT
struct SkOTTableOS2_VA {
SK_OT_USHORT version;
- //The only way to differentiate versionA and version0 is by size.
- static const SK_OT_USHORT version0 = SkTEndian_SwapBE16(0);
+ //SkOTTableOS2_VA::VERSION and SkOTTableOS2_V0::VERSION are both 0.
+ //The only way to differentiate these two versions is by the size of the table.
+ static const SK_OT_USHORT VERSION = SkTEndian_SwapBE16(0);
+
SK_OT_SHORT xAvgCharWidth;
struct WeightClass {
SK_TYPED_ENUM(Value, SK_OT_USHORT,
diff --git a/src/sfnt/SkOTTable_glyf.h b/src/sfnt/SkOTTable_glyf.h
new file mode 100644
index 0000000000..c6741a2e9e
--- /dev/null
+++ b/src/sfnt/SkOTTable_glyf.h
@@ -0,0 +1,214 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkOTTable_glyf_DEFINED
+#define SkOTTable_glyf_DEFINED
+
+#include "SkEndian.h"
+#include "SkOTTableTypes.h"
+#include "SkOTTable_head.h"
+#include "SkOTTable_loca.h"
+#include "SkTypedEnum.h"
+
+#pragma pack(push, 1)
+
+struct SkOTTableGlyphData;
+
+extern uint8_t const * const SK_OT_GlyphData_NoOutline;
+
+struct SkOTTableGlyph {
+ static const SK_OT_CHAR TAG0 = 'g';
+ static const SK_OT_CHAR TAG1 = 'l';
+ static const SK_OT_CHAR TAG2 = 'y';
+ static const SK_OT_CHAR TAG3 = 'f';
+ static const SK_OT_ULONG TAG = SkOTTableTAG<SkOTTableGlyph>::value;
+
+ class Iterator {
+ public:
+ Iterator(const SkOTTableGlyph& glyf,
+ const SkOTTableIndexToLocation& loca,
+ SkOTTableHead::IndexToLocFormat locaFormat)
+ : fGlyf(glyf)
+ , fLocaFormat(SkOTTableHead::IndexToLocFormat::ShortOffsets == locaFormat.value ? 0 : 1)
+ , fCurrentGlyphOffset(0)
+ { fLocaPtr.shortOffset = reinterpret_cast<const SK_OT_USHORT*>(&loca); }
+
+ void advance(uint16_t num) {
+ fLocaPtr.shortOffset += num << fLocaFormat;
+ fCurrentGlyphOffset = fLocaFormat ? SkEndian_SwapBE32(*fLocaPtr.longOffset)
+ : SkEndian_SwapBE16(*fLocaPtr.shortOffset);
+ }
+ const SkOTTableGlyphData* next() {
+ uint32_t previousGlyphOffset = fCurrentGlyphOffset;
+ advance(1);
+ if (previousGlyphOffset == fCurrentGlyphOffset) {
+ return reinterpret_cast<const SkOTTableGlyphData*>(&SK_OT_GlyphData_NoOutline);
+ } else {
+ return reinterpret_cast<const SkOTTableGlyphData*>(
+ reinterpret_cast<const SK_OT_BYTE*>(&fGlyf) + previousGlyphOffset
+ );
+ }
+ }
+ private:
+ const SkOTTableGlyph& fGlyf;
+ uint16_t fLocaFormat; //0 or 1
+ uint32_t fCurrentGlyphOffset;
+ union LocaPtr {
+ const SK_OT_USHORT* shortOffset;
+ const SK_OT_ULONG* longOffset;
+ } fLocaPtr;
+ };
+};
+
+struct SkOTTableGlyphData {
+ SK_OT_SHORT numberOfContours; //== -1 Composite, > 0 Simple
+ SK_OT_FWORD xMin;
+ SK_OT_FWORD yMin;
+ SK_OT_FWORD xMax;
+ SK_OT_FWORD yMax;
+
+ struct Simple {
+ SK_OT_USHORT endPtsOfContours[1/*numberOfContours*/];
+
+ struct Instructions {
+ SK_OT_USHORT length;
+ SK_OT_BYTE data[1/*length*/];
+ };
+
+ union Flags {
+ struct Field {
+ SK_OT_BYTE_BITFIELD(
+ OnCurve,
+ xShortVector,
+ yShortVector,
+ Repeat,
+ xIsSame_xShortVectorPositive,
+ yIsSame_yShortVectorPositive,
+ Reserved6,
+ Reserved7)
+ } field;
+ struct Raw {
+ static const SK_OT_USHORT OnCurveMask = SkTEndian_SwapBE16(1 << 0);
+ static const SK_OT_USHORT xShortVectorMask = SkTEndian_SwapBE16(1 << 1);
+ static const SK_OT_USHORT yShortVectorMask = SkTEndian_SwapBE16(1 << 2);
+ static const SK_OT_USHORT RepeatMask = SkTEndian_SwapBE16(1 << 3);
+ static const SK_OT_USHORT xIsSame_xShortVectorPositiveMask = SkTEndian_SwapBE16(1 << 4);
+ static const SK_OT_USHORT yIsSame_yShortVectorPositiveMask = SkTEndian_SwapBE16(1 << 5);
+ SK_OT_BYTE value;
+ } raw;
+ };
+
+ //xCoordinates
+ //yCoordinates
+ };
+
+ struct Composite {
+ struct Component {
+ union Flags {
+ struct Field {
+ //8-15
+ SK_OT_BYTE_BITFIELD(
+ WE_HAVE_INSTRUCTIONS,
+ USE_MY_METRICS,
+ OVERLAP_COMPOUND,
+ SCALED_COMPONENT_OFFSET,
+ UNSCALED_COMPONENT_OFFSET,
+ Reserved13,
+ Reserved14,
+ Reserved15)
+ //0-7
+ SK_OT_BYTE_BITFIELD(
+ ARG_1_AND_2_ARE_WORDS,
+ ARGS_ARE_XY_VALUES,
+ ROUND_XY_TO_GRID,
+ WE_HAVE_A_SCALE,
+ RESERVED,
+ MORE_COMPONENTS,
+ WE_HAVE_AN_X_AND_Y_SCALE,
+ WE_HAVE_A_TWO_BY_TWO)
+ } field;
+ struct Raw {
+ static const SK_OT_USHORT ARG_1_AND_2_ARE_WORDS_Mask = SkTEndian_SwapBE16(1 << 0);
+ static const SK_OT_USHORT ARGS_ARE_XY_VALUES_Mask = SkTEndian_SwapBE16(1 << 1);
+ static const SK_OT_USHORT ROUND_XY_TO_GRID_Mask = SkTEndian_SwapBE16(1 << 2);
+ static const SK_OT_USHORT WE_HAVE_A_SCALE_Mask = SkTEndian_SwapBE16(1 << 3);
+ static const SK_OT_USHORT RESERVED_Mask = SkTEndian_SwapBE16(1 << 4);
+ static const SK_OT_USHORT MORE_COMPONENTS_Mask = SkTEndian_SwapBE16(1 << 5);
+ static const SK_OT_USHORT WE_HAVE_AN_X_AND_Y_SCALE_Mask = SkTEndian_SwapBE16(1 << 6);
+ static const SK_OT_USHORT WE_HAVE_A_TWO_BY_TWO_Mask = SkTEndian_SwapBE16(1 << 7);
+
+ static const SK_OT_USHORT WE_HAVE_INSTRUCTIONS_Mask = SkTEndian_SwapBE16(1 << 8);
+ static const SK_OT_USHORT USE_MY_METRICS_Mask = SkTEndian_SwapBE16(1 << 9);
+ static const SK_OT_USHORT OVERLAP_COMPOUND_Mask = SkTEndian_SwapBE16(1 << 10);
+ static const SK_OT_USHORT SCALED_COMPONENT_OFFSET_Mask = SkTEndian_SwapBE16(1 << 11);
+ static const SK_OT_USHORT UNSCALED_COMPONENT_OFFSET_mask = SkTEndian_SwapBE16(1 << 12);
+ //Reserved
+ //Reserved
+ //Reserved
+ SK_OT_USHORT value;
+ } raw;
+ } flags;
+ SK_OT_USHORT glyphIndex;
+ union Transform {
+ union Matrix {
+ /** !WE_HAVE_A_SCALE & !WE_HAVE_AN_X_AND_Y_SCALE & !WE_HAVE_A_TWO_BY_TWO */
+ struct None { } none;
+ /** WE_HAVE_A_SCALE */
+ struct Scale {
+ SK_OT_F2DOT14 a_d;
+ } scale;
+ /** WE_HAVE_AN_X_AND_Y_SCALE */
+ struct ScaleXY {
+ SK_OT_F2DOT14 a;
+ SK_OT_F2DOT14 d;
+ } scaleXY;
+ /** WE_HAVE_A_TWO_BY_TWO */
+ struct TwoByTwo {
+ SK_OT_F2DOT14 a;
+ SK_OT_F2DOT14 b;
+ SK_OT_F2DOT14 c;
+ SK_OT_F2DOT14 d;
+ } twoByTwo;
+ };
+ /** ARG_1_AND_2_ARE_WORDS & ARGS_ARE_XY_VALUES */
+ struct WordValue {
+ SK_OT_FWORD e;
+ SK_OT_FWORD f;
+ SkOTTableGlyphData::Composite::Component::Transform::Matrix matrix;
+ } wordValue;
+ /** !ARG_1_AND_2_ARE_WORDS & ARGS_ARE_XY_VALUES */
+ struct ByteValue {
+ SK_OT_CHAR e;
+ SK_OT_CHAR f;
+ SkOTTableGlyphData::Composite::Component::Transform::Matrix matrix;
+ } byteValue;
+ /** ARG_1_AND_2_ARE_WORDS & !ARGS_ARE_XY_VALUES */
+ struct WordIndex {
+ SK_OT_USHORT compoundPointIndex;
+ SK_OT_USHORT componentPointIndex;
+ SkOTTableGlyphData::Composite::Component::Transform::Matrix matrix;
+ } wordIndex;
+ /** !ARG_1_AND_2_ARE_WORDS & !ARGS_ARE_XY_VALUES */
+ struct ByteIndex {
+ SK_OT_BYTE compoundPointIndex;
+ SK_OT_BYTE componentPointIndex;
+ SkOTTableGlyphData::Composite::Component::Transform::Matrix matrix;
+ } byteIndex;
+ } transform;
+ } component;//[] last element does not set MORE_COMPONENTS
+
+ /** Comes after the last Component if the last component has WE_HAVE_INSTR. */
+ struct Instructions {
+ SK_OT_USHORT length;
+ SK_OT_BYTE data[1/*length*/];
+ };
+ };
+};
+
+#pragma pack(pop)
+
+#endif
diff --git a/src/sfnt/SkOTTable_loca.h b/src/sfnt/SkOTTable_loca.h
new file mode 100644
index 0000000000..1d22b30c82
--- /dev/null
+++ b/src/sfnt/SkOTTable_loca.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkOTTable_loca_DEFINED
+#define SkOTTable_loca_DEFINED
+
+#include "SkEndian.h"
+#include "SkOTTableTypes.h"
+
+#pragma pack(push, 1)
+
+struct SkOTTableIndexToLocation {
+ static const SK_OT_CHAR TAG0 = 'l';
+ static const SK_OT_CHAR TAG1 = 'o';
+ static const SK_OT_CHAR TAG2 = 'c';
+ static const SK_OT_CHAR TAG3 = 'a';
+ static const SK_OT_ULONG TAG = SkOTTableTAG<SkOTTableIndexToLocation>::value;
+
+ union Offsets {
+ SK_OT_USHORT shortOffset[1];
+ SK_OT_ULONG longOffset[1];
+ } offsets;
+};
+
+#pragma pack(pop)
+
+#endif
diff --git a/src/sfnt/SkOTTable_maxp.h b/src/sfnt/SkOTTable_maxp.h
new file mode 100644
index 0000000000..3120cd4db2
--- /dev/null
+++ b/src/sfnt/SkOTTable_maxp.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkOTTable_maxp_DEFINED
+#define SkOTTable_maxp_DEFINED
+
+#include "SkOTTableTypes.h"
+#include "SkOTTable_maxp_CFF.h"
+#include "SkOTTable_maxp_TT.h"
+
+#pragma pack(push, 1)
+
+struct SkOTTableMaximumProfile {
+ static const SK_OT_CHAR TAG0 = 'm';
+ static const SK_OT_CHAR TAG1 = 'a';
+ static const SK_OT_CHAR TAG2 = 'x';
+ static const SK_OT_CHAR TAG3 = 'p';
+ static const SK_OT_ULONG TAG = SkOTTableTAG<SkOTTableMaximumProfile>::value;
+
+ union Version {
+ SK_OT_Fixed version;
+
+ struct CFF : SkOTTableMaximumProfile_CFF { } cff;
+ struct TT : SkOTTableMaximumProfile_TT { } tt;
+ } version;
+};
+
+#pragma pack(pop)
+
+#endif
diff --git a/src/sfnt/SkOTTable_maxp_CFF.h b/src/sfnt/SkOTTable_maxp_CFF.h
new file mode 100644
index 0000000000..da9f9c6f09
--- /dev/null
+++ b/src/sfnt/SkOTTable_maxp_CFF.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkOTTable_maxp_CFF_DEFINED
+#define SkOTTable_maxp_CFF_DEFINED
+
+#include "SkEndian.h"
+#include "SkOTTableTypes.h"
+
+#pragma pack(push, 1)
+
+struct SkOTTableMaximumProfile_CFF {
+ SK_OT_Fixed version;
+ static const SK_OT_Fixed VERSION = SkTEndian_SwapBE32(0x00005000);
+
+ SK_OT_USHORT numGlyphs;
+};
+
+#pragma pack(pop)
+
+
+#include <stddef.h>
+SK_COMPILE_ASSERT(offsetof(SkOTTableMaximumProfile_CFF, numGlyphs) == 4, SkOTTableHead_glyphDataFormat_not_at_2);
+SK_COMPILE_ASSERT(sizeof(SkOTTableMaximumProfile_CFF) == 6, sizeof_SkOTTableHead_not_4);
+
+#endif
diff --git a/src/sfnt/SkOTTable_maxp_TT.h b/src/sfnt/SkOTTable_maxp_TT.h
new file mode 100644
index 0000000000..ac4dbf6777
--- /dev/null
+++ b/src/sfnt/SkOTTable_maxp_TT.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkOTTable_maxp_TT_DEFINED
+#define SkOTTable_maxp_TT_DEFINED
+
+#include "SkEndian.h"
+#include "SkOTTableTypes.h"
+#include "SkTypedEnum.h"
+
+#pragma pack(push, 1)
+
+struct SkOTTableMaximumProfile_TT {
+ SK_OT_Fixed version;
+ static const SK_OT_Fixed VERSION = SkTEndian_SwapBE32(0x00010000);
+
+ SK_OT_USHORT numGlyphs;
+ SK_OT_USHORT maxPoints;
+ SK_OT_USHORT maxContours;
+ SK_OT_USHORT maxCompositePoints;
+ SK_OT_USHORT maxCompositeContours;
+ struct MaxZones {
+ SK_TYPED_ENUM(Value, SK_OT_SHORT,
+ ((DoesNotUseTwilightZone, SkTEndian_SwapBE16(1)))
+ ((UsesTwilightZone, SkTEndian_SwapBE16(2)))
+ SK_SEQ_END,
+ (value)SK_SEQ_END)
+ } maxZones;
+ SK_OT_USHORT maxTwilightPoints;
+ SK_OT_USHORT maxStorage;
+ SK_OT_USHORT maxFunctionDefs;
+ SK_OT_USHORT maxInstructionDefs;
+ SK_OT_USHORT maxStackElements;
+ SK_OT_USHORT maxSizeOfInstructions;
+ SK_OT_USHORT maxComponentDepth;
+};
+
+#pragma pack(pop)
+
+
+#include <stddef.h>
+SK_COMPILE_ASSERT(offsetof(SkOTTableMaximumProfile_TT, maxComponentDepth) == 28, SkOTTableMaximumProfile_TT_maxComponentDepth_not_at_26);
+SK_COMPILE_ASSERT(sizeof(SkOTTableMaximumProfile_TT) == 30, sizeof_SkOTTableMaximumProfile_TT_not_28);
+
+#endif
diff --git a/src/sfnt/SkOTUtils.cpp b/src/sfnt/SkOTUtils.cpp
index 0925d0cda9..4eeaa36d04 100644
--- a/src/sfnt/SkOTUtils.cpp
+++ b/src/sfnt/SkOTUtils.cpp
@@ -14,6 +14,16 @@
#include "SkOTTableTypes.h"
#include "SkOTUtils.h"
+extern const uint8_t SK_OT_GlyphData_NoOutline[] = {
+ 0x0,0x0, //SkOTTableGlyphData::numberOfContours
+ 0x0,0x0, //SkOTTableGlyphData::xMin
+ 0x0,0x0, //SkOTTableGlyphData::yMin
+ 0x0,0x0, //SkOTTableGlyphData::xMax
+ 0x0,0x0, //SkOTTableGlyphData::yMax
+
+ 0x0,0x0, //SkOTTableGlyphDataInstructions::length
+};
+
uint32_t SkOTUtils::CalcTableChecksum(SK_OT_ULONG *data, size_t length) {
uint32_t sum = 0;
SK_OT_ULONG *dataEnd = data + ((length + 3) & ~3) / sizeof(SK_OT_ULONG);
@@ -23,8 +33,7 @@ uint32_t SkOTUtils::CalcTableChecksum(SK_OT_ULONG *data, size_t length) {
return sum;
}
-SkData* SkOTUtils::RenameFont(SkStream* fontData,
- const char* fontName, int fontNameLen) {
+SkData* SkOTUtils::RenameFont(SkStream* fontData, const char* fontName, int fontNameLen) {
// Get the sfnt header.
SkSFNTHeader sfntHeader;
@@ -34,7 +43,7 @@ SkData* SkOTUtils::RenameFont(SkStream* fontData,
// Find the existing 'name' table.
int tableIndex;
- SkSFNTTableDirectoryEntry tableEntry;
+ SkSFNTHeader::TableDirectoryEntry tableEntry;
int numTables = SkEndian_SwapBE16(sfntHeader.numTables);
for (tableIndex = 0; tableIndex < numTables; ++tableIndex) {
if (fontData->read(&tableEntry, sizeof(tableEntry)) < sizeof(tableEntry)) {
@@ -88,9 +97,9 @@ SkData* SkOTUtils::RenameFont(SkStream* fontData,
}
//Fix up the offsets of the directory entries after the old 'name' table entry.
- SkSFNTTableDirectoryEntry* currentEntry = reinterpret_cast<SkSFNTTableDirectoryEntry*>(data + sizeof(SkSFNTHeader));
- SkSFNTTableDirectoryEntry* endEntry = currentEntry + numTables;
- SkSFNTTableDirectoryEntry* headTableEntry = NULL;
+ SkSFNTHeader::TableDirectoryEntry* currentEntry = reinterpret_cast<SkSFNTHeader::TableDirectoryEntry*>(data + sizeof(SkSFNTHeader));
+ SkSFNTHeader::TableDirectoryEntry* endEntry = currentEntry + numTables;
+ SkSFNTHeader::TableDirectoryEntry* headTableEntry = NULL;
for (; currentEntry < endEntry; ++currentEntry) {
uint32_t oldOffset = SkEndian_SwapBE32(currentEntry->offset);
if (oldOffset > oldNameTableOffset) {
@@ -102,7 +111,7 @@ SkData* SkOTUtils::RenameFont(SkStream* fontData,
}
// Make the table directory entry point to the new 'name' table.
- SkSFNTTableDirectoryEntry* nameTableEntry = reinterpret_cast<SkSFNTTableDirectoryEntry*>(data + sizeof(SkSFNTHeader)) + tableIndex;
+ SkSFNTHeader::TableDirectoryEntry* nameTableEntry = reinterpret_cast<SkSFNTHeader::TableDirectoryEntry*>(data + sizeof(SkSFNTHeader)) + tableIndex;
nameTableEntry->logicalLength = SkEndian_SwapBE32(nameTableLogicalSize);
nameTableEntry->offset = SkEndian_SwapBE32(originalDataSize);
diff --git a/src/sfnt/SkOTUtils.h b/src/sfnt/SkOTUtils.h
index 1398de677b..3c5ada25eb 100644
--- a/src/sfnt/SkOTUtils.h
+++ b/src/sfnt/SkOTUtils.h
@@ -9,6 +9,7 @@
#define SkOTUtils_DEFINED
#include "SkOTTableTypes.h"
+class SkData;
class SkStream;
struct SkOTUtils {
@@ -30,8 +31,7 @@ struct SkOTUtils {
*
* fontName and fontNameLen must be specified in terms of ASCII chars.
*/
- static SkData* RenameFont(SkStream* fontData,
- const char* fontName, int fontNameLen);
+ static SkData* RenameFont(SkStream* fontData, const char* fontName, int fontNameLen);
};
#endif
diff --git a/src/sfnt/SkSFNTHeader.h b/src/sfnt/SkSFNTHeader.h
index c22065648a..ee1659e355 100644
--- a/src/sfnt/SkSFNTHeader.h
+++ b/src/sfnt/SkSFNTHeader.h
@@ -52,19 +52,19 @@ struct SkSFNTHeader {
SK_SFNT_USHORT searchRange;
SK_SFNT_USHORT entrySelector;
SK_SFNT_USHORT rangeShift;
-};
-
-struct SkSFNTTableDirectoryEntry {
- SK_SFNT_ULONG tag;
- SK_SFNT_ULONG checksum;
- SK_SFNT_ULONG offset; //From beginning of header.
- SK_SFNT_ULONG logicalLength;
+
+ struct TableDirectoryEntry {
+ SK_SFNT_ULONG tag;
+ SK_SFNT_ULONG checksum;
+ SK_SFNT_ULONG offset; //From beginning of header.
+ SK_SFNT_ULONG logicalLength;
+ }; //tableDirectoryEntries[numTables]
};
#pragma pack(pop)
SK_COMPILE_ASSERT(sizeof(SkSFNTHeader) == 12, sizeof_SkSFNTHeader_not_12);
-SK_COMPILE_ASSERT(sizeof(SkSFNTTableDirectoryEntry) == 16, sizeof_SkSFNTTableDirectoryEntry_not_16);
+SK_COMPILE_ASSERT(sizeof(SkSFNTHeader::TableDirectoryEntry) == 16, sizeof_SkSFNTHeader_TableDirectoryEntry_not_16);
#endif