[HarfBuzz] harfbuzz: Branch 'master' - 6 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Tue Nov 6 17:27:20 UTC 2018
src/hb-aat-layout-kerx-table.hh | 12 +-
src/hb-ot-kern-table.hh | 231 +++++++++++++++++++---------------------
test/api/Makefile.am | 4
3 files changed, 118 insertions(+), 129 deletions(-)
New commits:
commit bfafe208da11817b5ebf3751f02af2dcdf57bd19
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Nov 6 12:11:45 2018 -0500
[kern] Switch to dispatch
diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index d2242c54..ca2fdb49 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -637,12 +637,12 @@ struct KerxTable
unsigned int subtable_type = get_type ();
TRACE_DISPATCH (this, subtable_type);
switch (subtable_type) {
- case 0 : return_trace (c->dispatch (u.format0));
- case 1 : return_trace (c->dispatch (u.format1));
- case 2 : return_trace (c->dispatch (u.format2));
- case 4 : return_trace (c->dispatch (u.format4));
- case 6 : return_trace (c->dispatch (u.format6));
- default: return_trace (c->default_return_value ());
+ case 0: return_trace (c->dispatch (u.format0));
+ case 1: return_trace (c->dispatch (u.format1));
+ case 2: return_trace (c->dispatch (u.format2));
+ case 4: return_trace (c->dispatch (u.format4));
+ case 6: return_trace (c->dispatch (u.format6));
+ default: return_trace (c->default_return_value ());
}
}
diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index 1073530d..66e827d1 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -476,6 +476,7 @@ template <typename KernSubTableHeader>
struct KernSubTable
{
inline unsigned int get_size (void) const { return u.header.length; }
+ inline unsigned int get_type (void) const { return u.header.format; }
inline bool is_simple (void) const
{ return !(u.header.coverage & (u.header.CrossStream | u.header.Variation)); }
@@ -488,21 +489,24 @@ struct KernSubTable
inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
{
- switch (u.header.format) {
+ switch (get_type ()) {
/* This method hooks up to hb_font_t's get_h_kerning. Only support Format0. */
case 0: return u.format0.get_kerning (left, right);
default:return 0;
}
}
- inline void apply (AAT::hb_aat_apply_context_t *c) const
+ template <typename context_t>
+ inline typename context_t::return_t dispatch (context_t *c) const
{
- switch (u.header.format) {
- case 0: u.format0.apply (c); return;
- case 1: u.format1.apply (c); return;
- case 2: u.format2.apply (c); return;
- case 3: u.format3.apply (c); return;
- default: return;
+ unsigned int subtable_type = get_type ();
+ TRACE_DISPATCH (this, subtable_type);
+ switch (subtable_type) {
+ case 0: return_trace (c->dispatch (u.format0));
+ case 1: return_trace (c->dispatch (u.format1));
+ case 2: return_trace (c->dispatch (u.format2));
+ case 3: return_trace (c->dispatch (u.format3));
+ default: return_trace (c->default_return_value ());
}
}
@@ -512,13 +516,8 @@ struct KernSubTable
if (unlikely (!u.header.sanitize (c) ||
u.header.length < u.header.min_size ||
!c->check_range (this, u.header.length))) return_trace (false);
- switch (u.header.format) {
- case 0: return_trace (u.format0.sanitize (c));
- case 1: return_trace (u.format1.sanitize (c));
- case 2: return_trace (u.format2.sanitize (c));
- case 3: return_trace (u.format3.sanitize (c));
- default:return_trace (true);
- }
+
+ return_trace (dispatch (c));
}
protected:
@@ -591,7 +590,7 @@ struct KernTable
c->sanitizer.set_object (*st);
- st->apply (c);
+ st->dispatch (c);
(void) c->buffer->message (c->font, "end kern subtable %d", c->lookup_index);
commit 213fa3bf711dae5028e3d041e305cdd35223de77
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Nov 6 12:07:15 2018 -0500
[kern] Refactor to include header in each subtable type
diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index e9d7e301..1073530d 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -155,6 +155,7 @@ struct KernPair
DEFINE_SIZE_STATIC (6);
};
+template <typename KernSubTableHeader>
struct KernSubTableFormat0
{
inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
@@ -186,11 +187,13 @@ struct KernSubTableFormat0
}
protected:
- BinSearchArrayOf<KernPair> pairs; /* Array of kerning pairs. */
+ KernSubTableHeader header;
+ BinSearchArrayOf<KernPair> pairs; /* Array of kerning pairs. */
public:
- DEFINE_SIZE_ARRAY (8, pairs);
+ DEFINE_SIZE_ARRAY (KernSubTableHeader::static_size + 8, pairs);
};
+template <typename KernSubTableHeader>
struct KernSubTableFormat1
{
typedef void EntryData;
@@ -309,10 +312,11 @@ struct KernSubTableFormat1
}
protected:
+ KernSubTableHeader header;
AAT::StateTable<AAT::MortTypes, EntryData> machine;
OffsetTo<UnsizedArrayOf<FWORD>, HBUINT16, false> kernAction;
public:
- DEFINE_SIZE_STATIC (10);
+ DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 10);
};
struct KernClassTable
@@ -333,6 +337,7 @@ struct KernClassTable
DEFINE_SIZE_ARRAY (4, classes);
};
+template <typename KernSubTableHeader>
struct KernSubTableFormat2
{
inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right,
@@ -393,20 +398,19 @@ struct KernSubTableFormat2
}
protected:
- HBUINT16 rowWidth; /* The width, in bytes, of a row in the table. */
- OffsetTo<KernClassTable>
- leftClassTable; /* Offset from beginning of this subtable to
- * left-hand class table. */
- OffsetTo<KernClassTable>
- rightClassTable;/* Offset from beginning of this subtable to
- * right-hand class table. */
- OffsetTo<FWORD>
- array; /* Offset from beginning of this subtable to
- * the start of the kerning array. */
+ KernSubTableHeader header;
+ HBUINT16 rowWidth; /* The width, in bytes, of a row in the table. */
+ OffsetTo<KernClassTable> leftClassTable; /* Offset from beginning of this subtable to
+ * left-hand class table. */
+ OffsetTo<KernClassTable> rightClassTable;/* Offset from beginning of this subtable to
+ * right-hand class table. */
+ OffsetTo<FWORD> array; /* Offset from beginning of this subtable to
+ * the start of the kerning array. */
public:
- DEFINE_SIZE_MIN (8);
+ DEFINE_SIZE_MIN (KernSubTableHeader::static_size + 8);
};
+template <typename KernSubTableHeader>
struct KernSubTableFormat3
{
inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
@@ -448,44 +452,52 @@ struct KernSubTableFormat3
}
protected:
- HBUINT16 glyphCount; /* The number of glyphs in this font. */
- HBUINT8 kernValueCount; /* The number of kerning values. */
- HBUINT8 leftClassCount; /* The number of left-hand classes. */
- HBUINT8 rightClassCount;/* The number of right-hand classes. */
- HBUINT8 flags; /* Set to zero (reserved for future use). */
- UnsizedArrayOf<FWORD>
- kernValueZ; /* The kerning values.
- * Length kernValueCount. */
+ KernSubTableHeader header;
+ HBUINT16 glyphCount; /* The number of glyphs in this font. */
+ HBUINT8 kernValueCount; /* The number of kerning values. */
+ HBUINT8 leftClassCount; /* The number of left-hand classes. */
+ HBUINT8 rightClassCount;/* The number of right-hand classes. */
+ HBUINT8 flags; /* Set to zero (reserved for future use). */
+ UnsizedArrayOf<FWORD> kernValueZ; /* The kerning values.
+ * Length kernValueCount. */
#if 0
- UnsizedArrayOf<HBUINT8>
- leftClass; /* The left-hand classes.
- * Length glyphCount. */
- UnsizedArrayOf<HBUINT8>
- RightClass; /* The right-hand classes.
- * Length glyphCount. */
- UnsizedArrayOf<HBUINT8>
- kernIndex; /* The indices into the kernValue array.
- * Length leftClassCount * rightClassCount */
+ UnsizedArrayOf<HBUINT8>leftClass; /* The left-hand classes.
+ * Length glyphCount. */
+ UnsizedArrayOf<HBUINT8>rightClass; /* The right-hand classes.
+ * Length glyphCount. */
+ UnsizedArrayOf<HBUINT8>kernIndex; /* The indices into the kernValue array.
+ * Length leftClassCount * rightClassCount */
#endif
public:
- DEFINE_SIZE_ARRAY (6, kernValueZ);
+ DEFINE_SIZE_ARRAY (KernSubTableHeader::static_size + 6, kernValueZ);
};
+template <typename KernSubTableHeader>
struct KernSubTable
{
- inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, unsigned int format) const
+ inline unsigned int get_size (void) const { return u.header.length; }
+
+ inline bool is_simple (void) const
+ { return !(u.header.coverage & (u.header.CrossStream | u.header.Variation)); }
+
+ inline bool is_horizontal (void) const
+ { return (u.header.coverage & u.header.Direction) == u.header.DirectionHorizontal; }
+
+ inline bool is_override (void) const
+ { return bool (u.header.coverage & u.header.Override); }
+
+ inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
{
- switch (format) {
+ switch (u.header.format) {
/* This method hooks up to hb_font_t's get_h_kerning. Only support Format0. */
case 0: return u.format0.get_kerning (left, right);
default:return 0;
}
}
- inline void apply (AAT::hb_aat_apply_context_t *c, unsigned int format) const
+ inline void apply (AAT::hb_aat_apply_context_t *c) const
{
- /* TODO Switch to dispatch(). */
- switch (format) {
+ switch (u.header.format) {
case 0: u.format0.apply (c); return;
case 1: u.format1.apply (c); return;
case 2: u.format2.apply (c); return;
@@ -494,10 +506,13 @@ struct KernSubTable
}
}
- inline bool sanitize (hb_sanitize_context_t *c, unsigned int format) const
+ inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- switch (format) {
+ if (unlikely (!u.header.sanitize (c) ||
+ u.header.length < u.header.min_size ||
+ !c->check_range (this, u.header.length))) return_trace (false);
+ switch (u.header.format) {
case 0: return_trace (u.format0.sanitize (c));
case 1: return_trace (u.format1.sanitize (c));
case 2: return_trace (u.format2.sanitize (c));
@@ -508,10 +523,11 @@ struct KernSubTable
protected:
union {
- KernSubTableFormat0 format0;
- KernSubTableFormat1 format1;
- KernSubTableFormat2 format2;
- KernSubTableFormat3 format3;
+ KernSubTableHeader header;
+ KernSubTableFormat0<KernSubTableHeader> format0;
+ KernSubTableFormat1<KernSubTableHeader> format1;
+ KernSubTableFormat2<KernSubTableHeader> format2;
+ KernSubTableFormat3<KernSubTableHeader> format3;
} u;
public:
DEFINE_SIZE_MIN (0);
@@ -519,39 +535,6 @@ struct KernSubTable
template <typename T>
-struct KernSubTableWrapper
-{
- /* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
- inline const T* thiz (void) const { return static_cast<const T *> (this); }
-
- inline bool is_simple (void) const
- { return !(thiz()->coverage & (T::CrossStream | T::Variation)); }
-
- inline bool is_horizontal (void) const
- { return (thiz()->coverage & T::Direction) == T::DirectionHorizontal; }
-
- inline bool is_override (void) const
- { return bool (thiz()->coverage & T::Override); }
-
- inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
- { return thiz()->subtable.get_kerning (left, right, thiz()->format); }
-
- inline void apply (AAT::hb_aat_apply_context_t *c) const
- { thiz()->subtable.apply (c, thiz()->format); }
-
- inline unsigned int get_size (void) const { return thiz()->length; }
-
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- return_trace (c->check_struct (thiz()) &&
- thiz()->length >= T::min_size &&
- c->check_range (thiz(), thiz()->length) &&
- thiz()->subtable.sanitize (c, thiz()->format));
- }
-};
-
-template <typename T>
struct KernTable
{
/* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
@@ -559,8 +542,10 @@ struct KernTable
inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
{
+ typedef KernSubTable<typename T::SubTableHeader> SubTable;
+
int v = 0;
- const typename T::SubTableWrapper *st = CastP<typename T::SubTableWrapper> (&thiz()->dataZ);
+ const SubTable *st = CastP<SubTable> (&thiz()->dataZ);
unsigned int count = thiz()->nTables;
for (unsigned int i = 0; i < count; i++)
{
@@ -569,15 +554,17 @@ struct KernTable
if (st->is_override ())
v = 0;
v += st->get_kerning (left, right);
- st = &StructAfter<typename T::SubTableWrapper> (*st);
+ st = &StructAfter<SubTable> (*st);
}
return v;
}
inline void apply (AAT::hb_aat_apply_context_t *c) const
{
+ typedef KernSubTable<typename T::SubTableHeader> SubTable;
+
c->set_lookup_index (0);
- const typename T::SubTableWrapper *st = CastP<typename T::SubTableWrapper> (&thiz()->dataZ);
+ const SubTable *st = CastP<SubTable> (&thiz()->dataZ);
unsigned int count = thiz()->nTables;
/* If there's an override subtable, skip subtables before that. */
unsigned int last_override = 0;
@@ -585,9 +572,9 @@ struct KernTable
{
if (st->is_simple () && st->is_override ())
last_override = i;
- st = &StructAfter<typename T::SubTableWrapper> (*st);
+ st = &StructAfter<SubTable> (*st);
}
- st = CastP<typename T::SubTableWrapper> (&thiz()->dataZ);
+ st = CastP<SubTable> (&thiz()->dataZ);
for (unsigned int i = 0; i < count; i++)
{
if (!st->is_simple ())
@@ -609,7 +596,7 @@ struct KernTable
(void) c->buffer->message (c->font, "end kern subtable %d", c->lookup_index);
skip:
- st = &StructAfter<typename T::SubTableWrapper> (*st);
+ st = &StructAfter<SubTable> (*st);
}
}
@@ -620,13 +607,15 @@ struct KernTable
thiz()->version != T::VERSION))
return_trace (false);
- const typename T::SubTableWrapper *st = CastP<typename T::SubTableWrapper> (&thiz()->dataZ);
+ typedef KernSubTable<typename T::SubTableHeader> SubTable;
+
+ const SubTable *st = CastP<SubTable> (&thiz()->dataZ);
unsigned int count = thiz()->nTables;
for (unsigned int i = 0; i < count; i++)
{
if (unlikely (!st->sanitize (c)))
return_trace (false);
- st = &StructAfter<typename T::SubTableWrapper> (*st);
+ st = &StructAfter<SubTable> (*st);
}
return_trace (true);
@@ -639,11 +628,8 @@ struct KernOT : KernTable<KernOT>
static const uint16_t VERSION = 0x0000u;
- struct SubTableWrapper : KernSubTableWrapper<SubTableWrapper>
+ struct SubTableHeader
{
- friend struct KernTable<KernOT>;
- friend struct KernSubTableWrapper<SubTableWrapper>;
-
enum Coverage
{
Direction = 0x01u,
@@ -656,14 +642,19 @@ struct KernOT : KernTable<KernOT>
DirectionHorizontal= 0x01u
};
- protected:
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this));
+ }
+
+ public:
HBUINT16 versionZ; /* Unused. */
HBUINT16 length; /* Length of the subtable (including this header). */
HBUINT8 format; /* Subtable format. */
HBUINT8 coverage; /* Coverage bits. */
- KernSubTable subtable; /* Subtable data. */
public:
- DEFINE_SIZE_MIN (6);
+ DEFINE_SIZE_STATIC (6);
};
protected:
@@ -680,11 +671,8 @@ struct KernAAT : KernTable<KernAAT>
static const uint32_t VERSION = 0x00010000u;
- struct SubTableWrapper : KernSubTableWrapper<SubTableWrapper>
+ struct SubTableHeader
{
- friend struct KernTable<KernAAT>;
- friend struct KernSubTableWrapper<SubTableWrapper>;
-
enum Coverage
{
Direction = 0x80u,
@@ -696,15 +684,20 @@ struct KernAAT : KernTable<KernAAT>
DirectionHorizontal= 0x00u
};
- protected:
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this));
+ }
+
+ public:
HBUINT32 length; /* Length of the subtable (including this header). */
HBUINT8 coverage; /* Coverage bits. */
HBUINT8 format; /* Subtable format. */
HBUINT16 tupleIndex; /* The tuple index (used for variations fonts).
* This value specifies which tuple this subtable covers. */
- KernSubTable subtable; /* Subtable data. */
public:
- DEFINE_SIZE_MIN (8);
+ DEFINE_SIZE_STATIC (8);
};
protected:
commit b0da2cd0b9c1346b7cda5997fb799e895e34aace
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Nov 6 11:16:45 2018 -0500
[kern] Some more
diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index 2f27dcf4..e9d7e301 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -536,9 +536,6 @@ struct KernSubTableWrapper
inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
{ return thiz()->subtable.get_kerning (left, right, thiz()->format); }
- inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
- { return is_simple () && is_horizontal () ? get_kerning (left, right) : 0; }
-
inline void apply (AAT::hb_aat_apply_context_t *c) const
{ thiz()->subtable.apply (c, thiz()->format); }
@@ -567,9 +564,11 @@ struct KernTable
unsigned int count = thiz()->nTables;
for (unsigned int i = 0; i < count; i++)
{
- if (st->is_simple () && st->is_override ())
+ if (!st->is_simple () || !st->is_horizontal ())
+ continue;
+ if (st->is_override ())
v = 0;
- v += st->get_h_kerning (left, right);
+ v += st->get_kerning (left, right);
st = &StructAfter<typename T::SubTableWrapper> (*st);
}
return v;
commit 75b00b51c8fca5d605c479333eb3abd608623613
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Nov 6 11:13:40 2018 -0500
[kern] Renames
diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index 5bc9e436..2f27dcf4 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -524,11 +524,11 @@ struct KernSubTableWrapper
/* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
inline const T* thiz (void) const { return static_cast<const T *> (this); }
- inline bool is_supported (void) const
- { return !(thiz()->coverage & T::CheckFlags); }
+ inline bool is_simple (void) const
+ { return !(thiz()->coverage & (T::CrossStream | T::Variation)); }
inline bool is_horizontal (void) const
- { return (thiz()->coverage & T::Direction) == T::CheckHorizontal; }
+ { return (thiz()->coverage & T::Direction) == T::DirectionHorizontal; }
inline bool is_override (void) const
{ return bool (thiz()->coverage & T::Override); }
@@ -537,7 +537,7 @@ struct KernSubTableWrapper
{ return thiz()->subtable.get_kerning (left, right, thiz()->format); }
inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
- { return is_supported () && is_horizontal () ? get_kerning (left, right) : 0; }
+ { return is_simple () && is_horizontal () ? get_kerning (left, right) : 0; }
inline void apply (AAT::hb_aat_apply_context_t *c) const
{ thiz()->subtable.apply (c, thiz()->format); }
@@ -567,7 +567,7 @@ struct KernTable
unsigned int count = thiz()->nTables;
for (unsigned int i = 0; i < count; i++)
{
- if (st->is_supported () && st->is_override ())
+ if (st->is_simple () && st->is_override ())
v = 0;
v += st->get_h_kerning (left, right);
st = &StructAfter<typename T::SubTableWrapper> (*st);
@@ -584,14 +584,14 @@ struct KernTable
unsigned int last_override = 0;
for (unsigned int i = 0; i < count; i++)
{
- if (st->is_supported () && st->is_override ())
+ if (st->is_simple () && st->is_override ())
last_override = i;
st = &StructAfter<typename T::SubTableWrapper> (*st);
}
st = CastP<typename T::SubTableWrapper> (&thiz()->dataZ);
for (unsigned int i = 0; i < count; i++)
{
- if (!st->is_supported ())
+ if (!st->is_simple ())
goto skip;
if (HB_DIRECTION_IS_HORIZONTAL (c->buffer->props.direction) != st->is_horizontal ())
@@ -654,8 +654,7 @@ struct KernOT : KernTable<KernOT>
Variation = 0x00u, /* Not supported. */
- CheckFlags = 0x06u,
- CheckHorizontal = 0x01u
+ DirectionHorizontal= 0x01u
};
protected:
@@ -695,8 +694,7 @@ struct KernAAT : KernTable<KernAAT>
Override = 0x00u, /* Not supported. */
- CheckFlags = 0x60u,
- CheckHorizontal = 0x00u
+ DirectionHorizontal= 0x00u
};
protected:
commit 5c3ccbc634158ba9f84d365c9a31a596f6d8825b
Author: Khaled Hosny <khaledhosny at eglug.org>
Date: Tue Nov 6 18:10:56 2018 +0200
Another missing backlash
Did this ever work?
diff --git a/test/api/Makefile.am b/test/api/Makefile.am
index 67044489..947832b8 100644
--- a/test/api/Makefile.am
+++ b/test/api/Makefile.am
@@ -150,7 +150,7 @@ check-gtester:
VALGRIND_FLAGS = \
--tool=memcheck \
--track-origins=yes \
- --leak-check=yes
+ --leak-check=yes \
$(EXTRA_VALGRIND_FLAGS)
# Can't do for now: --show-reachable=yes
CLEANFILES += log-valgrind.txt
commit d29602b962c13836f4c0d46796bc693f66f9b9fe
Author: Khaled Hosny <khaledhosny at eglug.org>
Date: Tue Nov 6 18:07:47 2018 +0200
Add missing backslash
diff --git a/test/api/Makefile.am b/test/api/Makefile.am
index e6e08a25..67044489 100644
--- a/test/api/Makefile.am
+++ b/test/api/Makefile.am
@@ -148,7 +148,7 @@ check-gtester:
# Check tests under valgrind. Saves log to log-valgrind.txt
VALGRIND_FLAGS = \
- --tool=memcheck
+ --tool=memcheck \
--track-origins=yes \
--leak-check=yes
$(EXTRA_VALGRIND_FLAGS)
More information about the HarfBuzz
mailing list