move rounding advance width to glyf
This commit is contained in:
parent
c7edd14dc9
commit
560bcd7744
|
@ -788,22 +788,24 @@ struct glyf
|
|||
return true;
|
||||
}
|
||||
|
||||
float get_advance_var (hb_codepoint_t glyph,
|
||||
unsigned int get_advance_var (hb_codepoint_t glyph,
|
||||
const int *coords, unsigned int coord_count,
|
||||
bool vertical) const
|
||||
{
|
||||
float advance = 0.f;
|
||||
if (coord_count != gvar_accel.get_axis_count ()) return advance;
|
||||
|
||||
bool success = false;
|
||||
hb_vector_t<contour_point_t> phantoms;
|
||||
phantoms.resize (PHANTOM_COUNT);
|
||||
|
||||
if (unlikely (!get_var_metrics (glyph, coords, coord_count, phantoms.as_array ()))) return advance;
|
||||
if (likely (coord_count == gvar_accel.get_axis_count ()))
|
||||
success = get_var_metrics (glyph, coords, coord_count, phantoms.as_array ());
|
||||
|
||||
if (unlikely (!success))
|
||||
return vertical? vmtx_accel.get_advance (glyph): hmtx_accel.get_advance (glyph);
|
||||
|
||||
if (vertical)
|
||||
return -(phantoms[PHANTOM_BOTTOM].y - phantoms[PHANTOM_TOP].y); // is this sign correct?
|
||||
return (unsigned int)roundf (phantoms[PHANTOM_TOP].y - phantoms[PHANTOM_BOTTOM].y);
|
||||
else
|
||||
return phantoms[PHANTOM_RIGHT].x - phantoms[PHANTOM_LEFT].x;
|
||||
return (unsigned int)roundf (phantoms[PHANTOM_RIGHT].x - phantoms[PHANTOM_LEFT].x);
|
||||
}
|
||||
|
||||
int get_side_bearing_var (hb_codepoint_t glyph, const int *coords, unsigned int coord_count, bool vertical) const
|
||||
|
@ -811,7 +813,9 @@ struct glyf
|
|||
hb_vector_t<contour_point_t> phantoms;
|
||||
phantoms.resize (PHANTOM_COUNT);
|
||||
|
||||
if (unlikely (!get_var_metrics (glyph, coords, coord_count, phantoms))) return 0;
|
||||
if (unlikely (!get_var_metrics (glyph, coords, coord_count, phantoms)))
|
||||
return vertical? vmtx_accel.get_side_bearing (glyph): hmtx_accel.get_side_bearing (glyph);
|
||||
|
||||
return (int)(vertical? -ceilf (phantoms[PHANTOM_TOP].y): floorf (phantoms[PHANTOM_LEFT].x));
|
||||
}
|
||||
|
||||
|
|
|
@ -34,10 +34,10 @@ int hmtxvmtx_accelerator_base_t::get_side_bearing_var_tt (hb_font_t *font, hb_co
|
|||
glyf::accelerator_t glyf_accel;
|
||||
glyf_accel.init (font->face);
|
||||
|
||||
float side_bearing = glyf_accel.get_side_bearing_var (glyph, font->coords, font->num_coords, vertical);
|
||||
int side_bearing = glyf_accel.get_side_bearing_var (glyph, font->coords, font->num_coords, vertical);
|
||||
glyf_accel.fini ();
|
||||
|
||||
return (int)roundf (side_bearing);
|
||||
return side_bearing;
|
||||
}
|
||||
|
||||
unsigned int hmtxvmtx_accelerator_base_t::get_advance_var_tt (hb_font_t *font, hb_codepoint_t glyph, bool vertical)
|
||||
|
@ -45,10 +45,10 @@ unsigned int hmtxvmtx_accelerator_base_t::get_advance_var_tt (hb_font_t *font, h
|
|||
glyf::accelerator_t glyf_accel;
|
||||
glyf_accel.init (font->face);
|
||||
|
||||
float advance = glyf_accel.get_advance_var (glyph, font->coords, font->num_coords, vertical);
|
||||
unsigned int advance = glyf_accel.get_advance_var (glyph, font->coords, font->num_coords, vertical);
|
||||
glyf_accel.fini ();
|
||||
|
||||
return (unsigned int)roundf (advance);
|
||||
return advance;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue