[HarfBuzz] harfbuzz: Branch 'master' - 2 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Wed Oct 10 22:24:21 UTC 2018
src/hb-aat-layout-kerx-table.hh | 85 ++++++++++++++++++++++++++--------------
src/hb-ot-kern-table.hh | 7 +++
src/hb-ot-shape.cc | 4 -
src/hb-ot-shape.hh | 1
4 files changed, 67 insertions(+), 30 deletions(-)
New commits:
commit 5d34164d98f04816aafaa0abfc44cd899c7d70b3
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Oct 10 18:14:41 2018 -0400
[kern/kerx] Fix offset base
Disable kern Format2.
Fix kerx Format2. Manually tested this with Tamil MN font and it works:
$ HB_OPTIONS=aat ./hb-shape Tamil\ MN.ttc -u 0B94,0B95
[tgv_au=0+3435|tgc_ka=1 at -75,0+1517]
HB_OPTIONS=aat ./hb-shape Tamil\ MN.ttc -u 0B94,0B95 --features=-kern
[tgv_au=0+3510|tgc_ka=1+1592]
diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index f5540b6e..2214265b 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -44,6 +44,22 @@ namespace AAT {
using namespace OT;
+struct KerxSubTableHeader
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this)));
+ }
+
+ public:
+ HBUINT32 length;
+ HBUINT32 coverage;
+ HBUINT32 tupleCount;
+ public:
+ DEFINE_SIZE_STATIC (12);
+};
+
struct KerxSubTableFormat0
{
inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
@@ -76,10 +92,11 @@ struct KerxSubTableFormat0
}
protected:
+ KerxSubTableHeader header;
BinSearchArrayOf<KernPair, HBUINT32>
- pairs; /* Sorted kern records. */
+ pairs; /* Sorted kern records. */
public:
- DEFINE_SIZE_ARRAY (16, pairs);
+ DEFINE_SIZE_ARRAY (28, pairs);
};
struct KerxSubTableFormat1
@@ -104,10 +121,11 @@ struct KerxSubTableFormat1
}
protected:
+ KerxSubTableHeader header;
StateTable<HBUINT16> stateHeader;
LOffsetTo<ArrayOf<HBUINT16> > valueTable;
public:
- DEFINE_SIZE_STATIC (20);
+ DEFINE_SIZE_STATIC (32);
};
struct KerxSubTableFormat2
@@ -168,18 +186,18 @@ struct KerxSubTableFormat2
};
protected:
- HBUINT32 rowWidth; /* The width, in bytes, of a row in the table. */
+ KerxSubTableHeader header;
+ HBUINT32 rowWidth; /* The width, in bytes, of a row in the table. */
LOffsetTo<Lookup<HBUINT16> >
- leftClassTable; /* Offset from beginning of this subtable to
- * left-hand class table. */
+ leftClassTable; /* Offset from beginning of this subtable to
+ * left-hand class table. */
LOffsetTo<Lookup<HBUINT16> >
- rightClassTable;/* Offset from beginning of this subtable to
- * right-hand class table. */
- LOffsetTo<FWORD>
- array; /* Offset from beginning of this subtable to
- * the start of the kerning array. */
+ rightClassTable;/* Offset from beginning of this subtable to
+ * right-hand class table. */
+ LOffsetTo<FWORD> array; /* Offset from beginning of this subtable to
+ * the start of the kerning array. */
public:
- DEFINE_SIZE_STATIC (16);
+ DEFINE_SIZE_STATIC (28);
};
struct KerxSubTableFormat4
@@ -202,8 +220,9 @@ struct KerxSubTableFormat4
}
protected:
+ KerxSubTableHeader header;
public:
- DEFINE_SIZE_STATIC (1);
+ DEFINE_SIZE_STATIC (12);
};
struct KerxSubTableFormat6
@@ -231,23 +250,24 @@ struct KerxSubTableFormat6
}
protected:
- HBUINT32 flags;
- HBUINT16 rowCount;
- HBUINT16 columnCount;
+ KerxSubTableHeader header;
+ HBUINT32 flags;
+ HBUINT16 rowCount;
+ HBUINT16 columnCount;
LOffsetTo<Lookup<HBUINT16> > rowIndexTable;
LOffsetTo<Lookup<HBUINT16> > columnIndexTable;
LOffsetTo<Lookup<HBUINT16> > kerningArray;
LOffsetTo<Lookup<HBUINT16> > kerningVector;
public:
- DEFINE_SIZE_STATIC (24);
+ DEFINE_SIZE_STATIC (36);
};
struct KerxTable
{
friend struct kerx;
- inline unsigned int get_size (void) const { return length; }
- inline unsigned int get_type (void) const { return coverage & SubtableType; }
+ inline unsigned int get_size (void) const { return u.header.length; }
+ inline unsigned int get_type (void) const { return u.header.coverage & SubtableType; }
enum Coverage
{
@@ -281,19 +301,16 @@ struct KerxTable
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- if (!length.sanitize (c) ||
- length < min_size ||
- !c->check_range (this, length))
+ if (!u.header.sanitize (c) ||
+ !c->check_range (this, u.header.length))
return_trace (false);
return_trace (dispatch (c));
}
protected:
- HBUINT32 length;
- HBUINT32 coverage;
- HBUINT32 tupleCount;
union {
+ KerxSubTableHeader header;
KerxSubTableFormat0 format0;
KerxSubTableFormat1 format1;
KerxSubTableFormat2 format2;
@@ -324,14 +341,14 @@ struct kerx
{
bool reverse;
- if (table->coverage & (KerxTable::CrossStream | KerxTable::Variation))
+ if (table->u.header.coverage & (KerxTable::CrossStream | KerxTable::Variation))
goto skip; /* We do NOT handle cross-stream or variation kerning. */
if (HB_DIRECTION_IS_VERTICAL (c->buffer->props.direction) !=
- bool (table->coverage & KerxTable::Vertical))
+ bool (table->u.header.coverage & KerxTable::Vertical))
goto skip;
- reverse = bool (table->coverage & KerxTable::Backwards) !=
+ reverse = bool (table->u.header.coverage & KerxTable::Backwards) !=
HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction);
if (!c->buffer->message (c->font, "start kerx subtable %d", c->lookup_index))
diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index ccb666e8..dab7a805 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -191,6 +191,12 @@ struct KernSubTableFormat2
{
inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end) const
{
+ /* This subtable is disabled. It's not cleaer to me *exactly* where the offests are
+ * based from. I *think* they should be based from beginning of kern subtable wrapper,
+ * *NOT* "this". Since we know of no fonts that use this subtable, we are disabling
+ * it. Someday fix it and re-enable. Better yet, find fonts that use it... Meh,
+ * Windows doesn't implement it. Maybe just remove... */
+ return 0;
unsigned int l = (this+leftClassTable).get_class (left);
unsigned int r = (this+rightClassTable).get_class (right);
unsigned int offset = l + r;
@@ -204,6 +210,7 @@ struct KernSubTableFormat2
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
+ return_trace (true); /* Disabled. See above. */
return_trace (rowWidth.sanitize (c) &&
leftClassTable.sanitize (c, this) &&
rightClassTable.sanitize (c, this) &&
commit 60f86d32d7c735ccf783b382e18ecdc096eaa682
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Oct 10 18:10:05 2018 -0400
[kerx] Don't loop over kerning subtables if kerning disabled
diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index 005208c6..f5540b6e 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -59,6 +59,9 @@ struct KerxSubTableFormat0
{
TRACE_APPLY (this);
+ if (!c->plan->requested_kerning)
+ return false;
+
hb_kern_machine_t<KerxSubTableFormat0> machine (*this);
machine.kern (c->font, c->buffer, c->plan->kern_mask);
@@ -85,6 +88,9 @@ struct KerxSubTableFormat1
{
TRACE_APPLY (this);
+ if (!c->plan->requested_kerning)
+ return false;
+
/* TODO */
return_trace (true);
@@ -123,6 +129,9 @@ struct KerxSubTableFormat2
{
TRACE_APPLY (this);
+ if (!c->plan->requested_kerning)
+ return false;
+
accelerator_t accel (*this,
c->sanitizer.end,
c->face->get_num_glyphs ());
@@ -203,6 +212,9 @@ struct KerxSubTableFormat6
{
TRACE_APPLY (this);
+ if (!c->plan->requested_kerning)
+ return false;
+
/* TODO */
return_trace (true);
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 7a15d523..3b1c93db 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -71,7 +71,7 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n');
plan.kern_mask = plan.map.get_mask (kern_tag);
- bool kerning_requested = !!plan.kern_mask;
+ plan.requested_kerning = !!plan.kern_mask;
bool has_gpos_kern = plan.map.get_feature_index (1, kern_tag) != HB_OT_LAYOUT_NO_FEATURE_INDEX;
bool disable_gpos = plan.shaper->gpos_tag &&
plan.shaper->gpos_tag != plan.map.chosen_script[1];
@@ -100,7 +100,7 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
else if (hb_aat_layout_has_positioning (face))
plan.apply_kerx = true;
- if (kerning_requested)
+ if (plan.requested_kerning)
{
if (plan.apply_kerx)
;/* kerx supercedes kern. */
diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh
index fc444b25..4943c515 100644
--- a/src/hb-ot-shape.hh
+++ b/src/hb-ot-shape.hh
@@ -43,6 +43,7 @@ struct hb_ot_shape_plan_t
hb_mask_t rtlm_mask, frac_mask, numr_mask, dnom_mask;
hb_mask_t kern_mask;
+ bool requested_kerning : 1;
bool has_frac : 1;
bool has_gpos_mark : 1;
bool fallback_glyph_classes : 1;
More information about the HarfBuzz
mailing list