/* Convert from font-space to user-space */
- int dir_scale (hb_direction_t direction)
- { return HB_DIRECTION_IS_VERTICAL(direction) ? y_scale : x_scale; }
- hb_position_t em_scale_x (int16_t v) { return em_scale (v, x_scale); }
- hb_position_t em_scale_y (int16_t v) { return em_scale (v, y_scale); }
- hb_position_t em_scalef_x (float v) { return em_scalef (v, this->x_scale); }
- hb_position_t em_scalef_y (float v) { return em_scalef (v, this->y_scale); }
+ int64_t dir_mult (hb_direction_t direction)
+ { return HB_DIRECTION_IS_VERTICAL(direction) ? y_mult : x_mult; }
+ hb_position_t em_scale_x (int16_t v) { return em_mult (v, x_mult); }
+ hb_position_t em_scale_y (int16_t v) { return em_mult (v, y_mult); }
+ hb_position_t em_scalef_x (float v) { return em_scalef (v, x_scale); }
+ hb_position_t em_scalef_y (float v) { return em_scalef (v, y_scale); }
float em_fscale_x (int16_t v) { return em_fscale (v, x_scale); }
float em_fscale_y (int16_t v) { return em_fscale (v, y_scale); }
hb_position_t em_scale_dir (int16_t v, hb_direction_t direction)
- { return em_scale (v, dir_scale (direction)); }
+ { return em_mult (v, dir_mult (direction)); }
/* Convert from parent-font user-space to our user-space */
hb_position_t parent_scale_x_distance (hb_position_t v)
y_mult = ((int64_t) y_scale << 16) / upem;
}
- hb_position_t em_scale (int16_t v, int scale)
+ hb_position_t em_mult (int16_t v, int64_t mult)
{
- signed upem = face->get_upem ();
- signed upem2 = upem >> 1;
- int64_t scaled = v * (int64_t) scale;
-
- scaled += scaled >= 0 ? upem2 : -upem2; /* Round. */
- return (hb_position_t) (scaled / upem);
+ return (hb_position_t) ((v * mult) >> 16);
}
hb_position_t em_scalef (float v, int scale)
{ return (hb_position_t) roundf (v * scale / face->get_upem ()); }
}
void extract (hb_ot_math_glyph_part_t &out,
- int scale,
+ int64_t mult,
hb_font_t *font) const
{
out.glyph = glyph;
- out.start_connector_length = font->em_scale (startConnectorLength, scale);
- out.end_connector_length = font->em_scale (endConnectorLength, scale);
- out.full_advance = font->em_scale (fullAdvance, scale);
+ out.start_connector_length = font->em_mult (startConnectorLength, mult);
+ out.end_connector_length = font->em_mult (endConnectorLength, mult);
+ out.full_advance = font->em_mult (fullAdvance, mult);
static_assert ((unsigned int) HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER ==
(unsigned int) PartFlags::Extender, "");
{
if (parts_count)
{
- int scale = font->dir_scale (direction);
+ int64_t mult = font->dir_mult (direction);
hb_array_t<const MathGlyphPartRecord> arr = partRecords.sub_array (start_offset, parts_count);
unsigned int count = arr.length;
for (unsigned int i = 0; i < count; i++)
- arr[i].extract (parts[i], scale, font);
+ arr[i].extract (parts[i], mult, font);
}
if (italics_correction)
{
if (variants_count)
{
- int scale = font->dir_scale (direction);
+ int64_t mult = font->dir_mult (direction);
hb_array_t<const MathGlyphVariantRecord> arr = mathGlyphVariantRecord.sub_array (start_offset, variants_count);
unsigned int count = arr.length;
for (unsigned int i = 0; i < count; i++)
{
variants[i].glyph = arr[i].variantGlyph;
- variants[i].advance = font->em_scale (arr[i].advanceMeasurement, scale);
+ variants[i].advance = font->em_mult (arr[i].advanceMeasurement, mult);
}
}
return mathGlyphVariantRecord.len;