[trak] Fix, and hook up

Works beautifully!  Test coming.
This commit is contained in:
Behdad Esfahbod 2018-10-11 11:10:06 -04:00
parent 3d7dea6dfd
commit d6a12dba6d
5 changed files with 40 additions and 5 deletions

View File

@ -540,7 +540,7 @@ struct hb_aat_apply_context_t :
inline hb_aat_apply_context_t (hb_ot_shape_plan_t *plan_,
hb_font_t *font_,
hb_buffer_t *buffer_,
hb_blob_t *table,
hb_blob_t *blob = const_cast<hb_blob_t *> (&Null(hb_blob_t)),
const ankr &ankr_table_ = Null(ankr),
const char *ankr_end_ = nullptr) :
plan (plan_), font (font_), face (font->face), buffer (buffer_),
@ -548,7 +548,7 @@ struct hb_aat_apply_context_t :
ankr_table (ankr_table_), ankr_end (ankr_end_),
lookup_index (0), debug_depth (0)
{
sanitizer.init (table);
sanitizer.init (blob);
sanitizer.set_num_glyphs (face->get_num_glyphs ());
sanitizer.start_processing ();
sanitizer.set_max_ops (HB_SANITIZE_MAX_OPS_MAX);

View File

@ -125,9 +125,9 @@ struct TrackData
/* TODO bfind() */
unsigned int size_index;
UnsizedArrayOf<Fixed> size_table = base+sizeTable;
hb_array_t<Fixed> size_table ((base+sizeTable).arrayZ, sizes);
for (size_index = 0; size_index < sizes; size_index++)
if (size_table[size_index] >= fixed_size)
if ((int) size_table[size_index] >= (int) fixed_size)
break;
// TODO(ebraminio): We don't attempt to extrapolate to larger or
@ -169,6 +169,8 @@ struct trak
{
static const hb_tag_t tableTag = HB_AAT_TAG_trak;
inline bool has_data (void) const { return version.to_int () != 0; }
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);

View File

@ -37,7 +37,7 @@
#include "hb-aat-ltag-table.hh" // Just so we compile it; unused otherwise.
/*
* morx/kerx/trak/ankr
* morx/kerx/trak
*/
static inline const AAT::morx&
@ -82,6 +82,12 @@ _get_ankr (hb_face_t *face, hb_blob_t **blob = nullptr)
*blob = hb_ot_face_data (face)->ankr.get_blob ();
return ankr;
}
static inline const AAT::trak&
_get_trak (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(AAT::trak);
return *(hb_ot_face_data (face)->trak.get ());
}
hb_bool_t
@ -124,3 +130,20 @@ hb_aat_layout_position (hb_ot_shape_plan_t *plan,
ankr, ankr_blob->data + ankr_blob->length);
kerx.apply (&c);
}
hb_bool_t
hb_aat_layout_has_tracking (hb_face_t *face)
{
return _get_trak (face).has_data ();
}
void
hb_aat_layout_track (hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer)
{
const AAT::trak& trak = _get_trak (font->face);
AAT::hb_aat_apply_context_t c (plan, font, buffer);
trak.apply (&c);
}

View File

@ -47,4 +47,12 @@ hb_aat_layout_position (hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer);
HB_INTERNAL hb_bool_t
hb_aat_layout_has_tracking (hb_face_t *face);
HB_INTERNAL void
hb_aat_layout_track (hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer);
#endif /* HB_AAT_LAYOUT_HH */

View File

@ -838,6 +838,8 @@ hb_ot_position_complex (const hb_ot_shape_context_t *c)
else if (c->plan->apply_kerx)
hb_aat_layout_position (c->plan, c->font, c->buffer);
hb_aat_layout_track (c->plan, c->font, c->buffer);
if (!c->plan->apply_kerx)
switch (c->plan->shaper->zero_width_marks)
{