[kerx] Implement tuple-kerning in Format0
diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index e8eb43b..960c37e 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -78,12 +78,14 @@
struct KerxSubTableFormat0
{
- inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
+ inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right,
+ hb_aat_apply_context_t *c) const
{
- if (header.tupleCount) return 0; /* TODO kerxTupleKern */
hb_glyph_pair_t pair = {left, right};
int i = pairs.bsearch (pair);
- return i == -1 ? 0 : pairs[i].get_kerning ();
+ if (i == -1) return 0;
+ int v = pairs[i].get_kerning ();
+ return kerxTupleKern (v, header.tupleCount, this, c);
}
inline bool apply (hb_aat_apply_context_t *c) const
@@ -93,13 +95,27 @@
if (!c->plan->requested_kerning)
return false;
- hb_kern_machine_t<KerxSubTableFormat0> machine (*this);
-
+ accelerator_t accel (*this, c);
+ hb_kern_machine_t<accelerator_t> machine (accel);
machine.kern (c->font, c->buffer, c->plan->kern_mask);
return_trace (true);
}
+ struct accelerator_t
+ {
+ const KerxSubTableFormat0 &table;
+ hb_aat_apply_context_t *c;
+
+ inline accelerator_t (const KerxSubTableFormat0 &table_,
+ hb_aat_apply_context_t *c_) :
+ table (table_), c (c_) {}
+
+ inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
+ { return table.get_kerning (left, right, c); }
+ };
+
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
@@ -273,15 +289,6 @@
return_trace (true);
}
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this) &&
- leftClassTable.sanitize (c, this) &&
- rightClassTable.sanitize (c, this) &&
- c->check_range (this, array)));
- }
-
struct accelerator_t
{
const KerxSubTableFormat2 &table;
@@ -295,6 +302,15 @@
{ return table.get_kerning (left, right, c); }
};
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (likely (c->check_struct (this) &&
+ leftClassTable.sanitize (c, this) &&
+ rightClassTable.sanitize (c, this) &&
+ c->check_range (this, array)));
+ }
+
protected:
KerxSubTableHeader header;
HBUINT32 rowWidth; /* The width, in bytes, of a row in the table. */