[glyf][gvar] Make HB_NO_VAR buildable

This commit is contained in:
Ebrahim Byagowi 2019-10-05 23:51:50 +03:30
parent 8e33510343
commit 5752863640
3 changed files with 16 additions and 0 deletions

View File

@ -315,6 +315,7 @@ hb_ot_font_set_funcs (hb_font_t *font)
nullptr);
}
#ifndef HB_NO_VAR
int
hb_ot_get_side_bearing_var_tt (hb_font_t *font, hb_codepoint_t glyph, bool is_vertical)
{
@ -326,6 +327,7 @@ hb_ot_get_advance_var_tt (hb_font_t *font, hb_codepoint_t glyph, bool is_vertica
{
return font->face->table.glyf->get_advance_var (glyph, font->coords, font->num_coords, is_vertical);
}
#endif
#endif

View File

@ -726,6 +726,7 @@ struct glyf
contour_point_t max;
};
#ifndef HB_NO_VAR
/* Note: Recursively calls itself.
* all_points includes phantom points
*/
@ -855,6 +856,7 @@ struct glyf
const int *coords, unsigned int coord_count,
hb_glyph_extents_t *extents) const
{ return get_var_extents_and_phantoms (glyph, coords, coord_count, extents); }
#endif
public:
/* based on FontTools _g_l_y_f.py::trim */
@ -1015,6 +1017,7 @@ struct glyf
return true;
}
#ifndef HB_NO_VAR
unsigned int get_advance_var (hb_codepoint_t glyph,
const int *coords, unsigned int coord_count,
bool vertical) const
@ -1046,13 +1049,16 @@ struct glyf
return vertical ? ceil (phantoms[PHANTOM_TOP].y) - extents.y_bearing : floor (phantoms[PHANTOM_LEFT].x);
}
#endif
bool get_extents (hb_font_t *font, hb_codepoint_t glyph, hb_glyph_extents_t *extents) const
{
#ifndef HB_NO_VAR
unsigned int coord_count;
const int *coords = hb_font_get_var_coords_normalized (font, &coord_count);
if (coords && coord_count > 0 && coord_count == face->table.gvar->get_axis_count ())
return get_extents_var (glyph, coords, coord_count, extents);
#endif
unsigned int start_offset, end_offset;
if (!get_offsets (glyph, &start_offset, &end_offset))

View File

@ -211,6 +211,7 @@ struct hmtxvmtx
{
int side_bearing = get_side_bearing (glyph);
#ifndef HB_NO_VAR
if (unlikely (glyph >= num_metrics) || !font->num_coords)
return side_bearing;
@ -218,6 +219,9 @@ struct hmtxvmtx
return hb_ot_get_side_bearing_var_tt (font, glyph, T::tableTag == HB_OT_TAG_vmtx);
return side_bearing + var_table->get_side_bearing_var (glyph, font->coords, font->num_coords); // TODO Optimize?!
#else
return side_bearing;
#endif
}
unsigned int get_advance (hb_codepoint_t glyph) const
@ -241,6 +245,7 @@ struct hmtxvmtx
{
unsigned int advance = get_advance (glyph);
#ifndef HB_NO_VAR
if (unlikely (glyph >= num_metrics) || !font->num_coords)
return advance;
@ -248,6 +253,9 @@ struct hmtxvmtx
return hb_ot_get_advance_var_tt (font, glyph, T::tableTag == HB_OT_TAG_vmtx);
return advance + roundf (var_table->get_advance_var (glyph, font->coords, font->num_coords)); // TODO Optimize?!
#else
return advance;
#endif
}
unsigned int num_advances_for_subset (const hb_subset_plan_t *plan) const