提交 b713c139 编写于 作者: B Behdad Esfahbod

[kerx] Implement tuple-kerning in Format0

上级 0a3b7a0f
......@@ -78,12 +78,14 @@ struct KerxSubTableHeader
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 @@ struct KerxSubTableFormat0
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 @@ struct KerxSubTableFormat2
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 @@ struct KerxSubTableFormat2
{ 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. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册