[kern] Implement Format0

pull/602/head
Behdad Esfahbod 7 years ago
parent ac3d937c6c
commit 4c43a23bf4
  1. 51
      src/hb-ot-kern-table.hh

@ -38,23 +38,62 @@ namespace OT {
#define HB_OT_TAG_kern HB_TAG('k','e','r','n')
struct hb_glyph_pair_t
{
hb_codepoint_t left;
hb_codepoint_t right;
};
struct KernSubTableFormat0
struct KernPair
{
inline unsigned int get_size (void) const
inline int get_kerning (void) const
{ return value; }
inline int cmp (const hb_glyph_pair_t &o) const
{
/* XXX */
return 0;
int ret = left.cmp (o.left);
if (ret) return ret;
return right.cmp (o.right);
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this));
}
/* XXX */
protected:
GlyphID left;
GlyphID right;
FWORD value;
public:
DEFINE_SIZE_STATIC (6);
};
return_trace (true);
struct KernSubTableFormat0
{
inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
{
hb_glyph_pair_t pair = {left, right};
int i = pairs.bsearch (pair);
if (i == -1)
return 0;
return pairs[i].get_kerning ();
}
inline unsigned int get_size (void) const
{ return pairs.get_size (); }
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
return_trace (pairs.sanitize (c));
}
protected:
BinSearchArrayOf<KernPair> pairs; /* Array of kerning pairs. */
public:
DEFINE_SIZE_ARRAY (8, pairs);
};
struct KernSubTableFormat2

Loading…
Cancel
Save