Inline font getters

This commit is contained in:
Behdad Esfahbod 2012-08-01 19:03:46 -04:00
parent 6adf417bc1
commit 8fbfda920e
11 changed files with 277 additions and 166 deletions

View File

@ -95,9 +95,8 @@ _hb_fallback_shape (hb_shape_plan_t *shape_plan,
const hb_feature_t *features HB_UNUSED,
unsigned int num_features HB_UNUSED)
{
/* TODO Save the space character in the font? */
hb_codepoint_t space;
hb_font_get_glyph (font, ' ', 0, &space);
font->get_glyph (' ', 0, &space);
buffer->guess_properties ();
buffer->clear_positions ();
@ -112,15 +111,15 @@ _hb_fallback_shape (hb_shape_plan_t *shape_plan,
buffer->pos[i].y_advance = 0;
continue;
}
hb_font_get_glyph (font, buffer->info[i].codepoint, 0, &buffer->info[i].codepoint);
hb_font_get_glyph_advance_for_direction (font, buffer->info[i].codepoint,
buffer->props.direction,
&buffer->pos[i].x_advance,
&buffer->pos[i].y_advance);
hb_font_subtract_glyph_origin_for_direction (font, buffer->info[i].codepoint,
buffer->props.direction,
&buffer->pos[i].x_offset,
&buffer->pos[i].y_offset);
font->get_glyph (buffer->info[i].codepoint, 0, &buffer->info[i].codepoint);
font->get_glyph_advance_for_direction (buffer->info[i].codepoint,
buffer->props.direction,
&buffer->pos[i].x_advance,
&buffer->pos[i].y_advance);
font->subtract_glyph_origin_for_direction (buffer->info[i].codepoint,
buffer->props.direction,
&buffer->pos[i].x_offset,
&buffer->pos[i].y_offset);
}
if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction))

View File

@ -174,6 +174,210 @@ struct hb_font_t {
}
/* Public getters */
inline hb_bool_t get_glyph (hb_codepoint_t unicode, hb_codepoint_t variation_selector,
hb_codepoint_t *glyph)
{
*glyph = 0;
return klass->get.glyph (this, user_data,
unicode, variation_selector, glyph,
klass->user_data.glyph);
}
inline hb_position_t get_glyph_h_advance (hb_codepoint_t glyph)
{
return klass->get.glyph_h_advance (this, user_data,
glyph,
klass->user_data.glyph_h_advance);
}
inline hb_position_t get_glyph_v_advance (hb_codepoint_t glyph)
{
return klass->get.glyph_v_advance (this, user_data,
glyph,
klass->user_data.glyph_v_advance);
}
inline hb_bool_t get_glyph_h_origin (hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y)
{
*x = *y = 0;
return klass->get.glyph_h_origin (this, user_data,
glyph, x, y,
klass->user_data.glyph_h_origin);
}
inline hb_bool_t get_glyph_v_origin (hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y)
{
*x = *y = 0;
return klass->get.glyph_v_origin (this, user_data,
glyph, x, y,
klass->user_data.glyph_v_origin);
}
inline hb_position_t get_glyph_h_kerning (hb_codepoint_t left_glyph, hb_codepoint_t right_glyph)
{
return klass->get.glyph_h_kerning (this, user_data,
left_glyph, right_glyph,
klass->user_data.glyph_h_kerning);
}
inline hb_position_t get_glyph_v_kerning (hb_codepoint_t left_glyph, hb_codepoint_t right_glyph)
{
return klass->get.glyph_v_kerning (this, user_data,
left_glyph, right_glyph,
klass->user_data.glyph_v_kerning);
}
inline hb_bool_t get_glyph_extents (hb_codepoint_t glyph,
hb_glyph_extents_t *extents)
{
memset (extents, 0, sizeof (*extents));
return klass->get.glyph_extents (this, user_data,
glyph,
extents,
klass->user_data.glyph_extents);
}
inline hb_bool_t get_glyph_contour_point (hb_codepoint_t glyph, unsigned int point_index,
hb_position_t *x, hb_position_t *y)
{
*x = *y = 0;
return klass->get.glyph_contour_point (this, user_data,
glyph, point_index,
x, y,
klass->user_data.glyph_contour_point);
}
inline hb_bool_t get_glyph_name (hb_codepoint_t glyph,
char *name, unsigned int size)
{
return klass->get.glyph_name (this, user_data,
glyph,
name, size,
klass->user_data.glyph_name);
}
inline hb_bool_t get_glyph_from_name (const char *name, int len, /* -1 means nul-terminated */
hb_codepoint_t *glyph)
{
return klass->get.glyph_from_name (this, user_data,
name, len,
glyph,
klass->user_data.glyph_from_name);
}
/* A bit higher-level, and with fallback */
inline void get_glyph_advance_for_direction (hb_codepoint_t glyph,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y)
{
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
*x = get_glyph_h_advance (glyph);
*y = 0;
} else {
*x = 0;
*y = get_glyph_v_advance (glyph);
}
}
/* Internal only */
inline void guess_v_origin_minus_h_origin (hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y)
{
*x = get_glyph_h_advance (glyph) / 2;
/* TODO use font_metics.ascent */
*y = y_scale;
}
inline void get_glyph_origin_for_direction (hb_codepoint_t glyph,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y)
{
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
hb_bool_t ret = get_glyph_h_origin (glyph, x, y);
if (!ret && (ret = get_glyph_v_origin (glyph, x, y))) {
hb_position_t dx, dy;
guess_v_origin_minus_h_origin (glyph, &dx, &dy);
*x -= dx; *y -= dy;
}
} else {
hb_bool_t ret = get_glyph_v_origin (glyph, x, y);
if (!ret && (ret = get_glyph_h_origin (glyph, x, y))) {
hb_position_t dx, dy;
guess_v_origin_minus_h_origin (glyph, &dx, &dy);
*x += dx; *y += dy;
}
}
}
inline void add_glyph_origin_for_direction (hb_codepoint_t glyph,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y)
{
hb_position_t origin_x, origin_y;
get_glyph_origin_for_direction (glyph, direction, &origin_x, &origin_y);
*x += origin_x;
*y += origin_y;
}
inline void subtract_glyph_origin_for_direction (hb_codepoint_t glyph,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y)
{
hb_position_t origin_x, origin_y;
get_glyph_origin_for_direction (glyph, direction, &origin_x, &origin_y);
*x -= origin_x;
*y -= origin_y;
}
inline void get_glyph_kerning_for_direction (hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y)
{
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
*x = get_glyph_h_kerning (first_glyph, second_glyph);
*y = 0;
} else {
*x = 0;
*y = get_glyph_v_kerning (first_glyph, second_glyph);
}
}
inline hb_bool_t get_glyph_extents_for_origin (hb_codepoint_t glyph,
hb_direction_t direction,
hb_glyph_extents_t *extents)
{
hb_bool_t ret = get_glyph_extents (glyph, extents);
if (ret)
subtract_glyph_origin_for_direction (glyph, direction, &extents->x_bearing, &extents->y_bearing);
return ret;
}
inline hb_bool_t get_glyph_contour_point_for_origin (hb_codepoint_t glyph, unsigned int point_index,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y)
{
hb_bool_t ret = get_glyph_contour_point (glyph, point_index, x, y);
if (ret)
subtract_glyph_origin_for_direction (glyph, direction, x, y);
return ret;
}
private:
inline hb_position_t em_scale (int16_t v, int scale) { return v * (int64_t) scale / hb_face_get_upem (this->face); }
};

View File

@ -336,33 +336,28 @@ HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_FONT_FUNC_IMPLEMENT
/* Public getters */
hb_bool_t
hb_font_get_glyph (hb_font_t *font,
hb_codepoint_t unicode, hb_codepoint_t variation_selector,
hb_codepoint_t *glyph)
{
*glyph = 0;
return font->klass->get.glyph (font, font->user_data,
unicode, variation_selector, glyph,
font->klass->user_data.glyph);
return font->get_glyph (unicode, variation_selector, glyph);
}
hb_position_t
hb_font_get_glyph_h_advance (hb_font_t *font,
hb_codepoint_t glyph)
{
return font->klass->get.glyph_h_advance (font, font->user_data,
glyph,
font->klass->user_data.glyph_h_advance);
return font->get_glyph_h_advance (glyph);
}
hb_position_t
hb_font_get_glyph_v_advance (hb_font_t *font,
hb_codepoint_t glyph)
{
return font->klass->get.glyph_v_advance (font, font->user_data,
glyph,
font->klass->user_data.glyph_v_advance);
return font->get_glyph_v_advance (glyph);
}
hb_bool_t
@ -370,10 +365,7 @@ hb_font_get_glyph_h_origin (hb_font_t *font,
hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y)
{
*x = *y = 0;
return font->klass->get.glyph_h_origin (font, font->user_data,
glyph, x, y,
font->klass->user_data.glyph_h_origin);
return font->get_glyph_h_origin (glyph, x, y);
}
hb_bool_t
@ -381,28 +373,21 @@ hb_font_get_glyph_v_origin (hb_font_t *font,
hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y)
{
*x = *y = 0;
return font->klass->get.glyph_v_origin (font, font->user_data,
glyph, x, y,
font->klass->user_data.glyph_v_origin);
return font->get_glyph_v_origin (glyph, x, y);
}
hb_position_t
hb_font_get_glyph_h_kerning (hb_font_t *font,
hb_codepoint_t left_glyph, hb_codepoint_t right_glyph)
{
return font->klass->get.glyph_h_kerning (font, font->user_data,
left_glyph, right_glyph,
font->klass->user_data.glyph_h_kerning);
return font->get_glyph_h_kerning (left_glyph, right_glyph);
}
hb_position_t
hb_font_get_glyph_v_kerning (hb_font_t *font,
hb_codepoint_t left_glyph, hb_codepoint_t right_glyph)
{
return font->klass->get.glyph_v_kerning (font, font->user_data,
left_glyph, right_glyph,
font->klass->user_data.glyph_v_kerning);
return font->get_glyph_v_kerning (left_glyph, right_glyph);
}
hb_bool_t
@ -410,11 +395,7 @@ hb_font_get_glyph_extents (hb_font_t *font,
hb_codepoint_t glyph,
hb_glyph_extents_t *extents)
{
memset (extents, 0, sizeof (*extents));
return font->klass->get.glyph_extents (font, font->user_data,
glyph,
extents,
font->klass->user_data.glyph_extents);
return font->get_glyph_extents (glyph, extents);
}
hb_bool_t
@ -422,11 +403,7 @@ hb_font_get_glyph_contour_point (hb_font_t *font,
hb_codepoint_t glyph, unsigned int point_index,
hb_position_t *x, hb_position_t *y)
{
*x = *y = 0;
return font->klass->get.glyph_contour_point (font, font->user_data,
glyph, point_index,
x, y,
font->klass->user_data.glyph_contour_point);
return font->get_glyph_contour_point (glyph, point_index, x, y);
}
hb_bool_t
@ -434,10 +411,7 @@ hb_font_get_glyph_name (hb_font_t *font,
hb_codepoint_t glyph,
char *name, unsigned int size)
{
return font->klass->get.glyph_name (font, font->user_data,
glyph,
name, size,
font->klass->user_data.glyph_name);
return font->get_glyph_name (glyph, name, size);
}
hb_bool_t
@ -445,10 +419,7 @@ hb_font_get_glyph_from_name (hb_font_t *font,
const char *name, int len, /* -1 means nul-terminated */
hb_codepoint_t *glyph)
{
return font->klass->get.glyph_from_name (font, font->user_data,
name, len,
glyph,
font->klass->user_data.glyph_from_name);
return font->get_glyph_from_name (name, len, glyph);
}
@ -460,48 +431,16 @@ hb_font_get_glyph_advance_for_direction (hb_font_t *font,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y)
{
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
*x = hb_font_get_glyph_h_advance (font, glyph);
*y = 0;
} else {
*x = 0;
*y = hb_font_get_glyph_v_advance (font, glyph);
}
return font->get_glyph_advance_for_direction (glyph, direction, x, y);
}
static void
guess_v_origin_minus_h_origin (hb_font_t *font,
hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y)
{
*x = hb_font_get_glyph_h_advance (font, glyph) / 2;
/* TODO use font_metics.ascent */
*y = font->y_scale;
}
void
hb_font_get_glyph_origin_for_direction (hb_font_t *font,
hb_codepoint_t glyph,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y)
{
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
hb_bool_t ret = hb_font_get_glyph_h_origin (font, glyph, x, y);
if (!ret && (ret = hb_font_get_glyph_v_origin (font, glyph, x, y))) {
hb_position_t dx, dy;
guess_v_origin_minus_h_origin (font, glyph, &dx, &dy);
*x -= dx; *y -= dy;
}
} else {
hb_bool_t ret = hb_font_get_glyph_v_origin (font, glyph, x, y);
if (!ret && (ret = hb_font_get_glyph_h_origin (font, glyph, x, y))) {
hb_position_t dx, dy;
guess_v_origin_minus_h_origin (font, glyph, &dx, &dy);
*x += dx; *y += dy;
}
}
return font->get_glyph_origin_for_direction (glyph, direction, x, y);
}
void
@ -510,12 +449,7 @@ hb_font_add_glyph_origin_for_direction (hb_font_t *font,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y)
{
hb_position_t origin_x, origin_y;
hb_font_get_glyph_origin_for_direction (font, glyph, direction, &origin_x, &origin_y);
*x += origin_x;
*y += origin_y;
return font->add_glyph_origin_for_direction (glyph, direction, x, y);
}
void
@ -524,12 +458,7 @@ hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y)
{
hb_position_t origin_x, origin_y;
hb_font_get_glyph_origin_for_direction (font, glyph, direction, &origin_x, &origin_y);
*x -= origin_x;
*y -= origin_y;
return font->subtract_glyph_origin_for_direction (glyph, direction, x, y);
}
void
@ -538,13 +467,7 @@ hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y)
{
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
*x = hb_font_get_glyph_h_kerning (font, first_glyph, second_glyph);
*y = 0;
} else {
*x = 0;
*y = hb_font_get_glyph_v_kerning (font, first_glyph, second_glyph);
}
return font->get_glyph_kerning_for_direction (first_glyph, second_glyph, direction, x, y);
}
hb_bool_t
@ -553,12 +476,7 @@ hb_font_get_glyph_extents_for_origin (hb_font_t *font,
hb_direction_t direction,
hb_glyph_extents_t *extents)
{
hb_bool_t ret = hb_font_get_glyph_extents (font, glyph, extents);
if (ret)
hb_font_subtract_glyph_origin_for_direction (font, glyph, direction, &extents->x_bearing, &extents->y_bearing);
return ret;
return font->get_glyph_extents_for_origin (glyph, direction, extents);
}
hb_bool_t
@ -567,12 +485,7 @@ hb_font_get_glyph_contour_point_for_origin (hb_font_t *font,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y)
{
hb_bool_t ret = hb_font_get_glyph_contour_point (font, glyph, point_index, x, y);
if (ret)
hb_font_subtract_glyph_origin_for_direction (font, glyph, direction, x, y);
return ret;
return font->get_glyph_contour_point_for_origin (glyph, point_index, direction, x, y);
}
@ -1058,5 +971,3 @@ hb_font_get_ppem (hb_font_t *font,
if (x_ppem) *x_ppem = font->x_ppem;
if (y_ppem) *y_ppem = font->y_ppem;
}

View File

@ -108,7 +108,7 @@ static const void *hb_gr_get_table (const void *data, unsigned int tag, size_t *
static float hb_gr_get_advance (const void *hb_font, unsigned short gid)
{
return hb_font_get_glyph_h_advance ((hb_font_t *) hb_font, gid);
return ((hb_font_t *) font)->get_glyph_h_advance (gid);
}
static void _hb_gr_face_data_destroy (void *data)
@ -191,9 +191,7 @@ _hb_gr_font_get_data (hb_font_t *font)
}
data->grface = _hb_gr_face_get_data (font->face)->grface;
int scale;
hb_font_get_scale (font, &scale, NULL);
data->grfont = gr_make_font_with_advance_fn (scale, font, &hb_gr_get_advance, data->grface);
data->grfont = gr_make_font_with_advance_fn (font->x_scale, font, &hb_gr_get_advance, data->grface);
if (unlikely (!hb_font_set_user_data (font, &hb_gr_data_key, data,

View File

@ -90,13 +90,13 @@ hb_old_convertStringToGlyphIndices (HB_Font old_font,
{
hb_codepoint_t u;
/* TODO Handle UTF-16. Ugh */
/* XXX Handle UTF-16. Ugh */
u = string[i];
if (rightToLeft)
u = hb_unicode_funcs_get_default ()->mirroring (u);
hb_font_get_glyph (font, u, 0, &u); /* TODO Variation selectors */
font->get_glyph (u, 0, &u); /* TODO Variation selectors */
glyphs[i] = u;
}
@ -115,7 +115,7 @@ hb_old_getGlyphAdvances (HB_Font old_font,
hb_font_t *font = (hb_font_t *) old_font->userData;
for (unsigned int i = 0; i < numGlyphs; i++)
advances[i] = hb_font_get_glyph_h_advance (font, glyphs[i]);
advances[i] = font->get_glyph_h_advance (glyphs[i]);
}
static HB_Bool
@ -147,13 +147,13 @@ hb_old_getGlyphMetrics (HB_Font old_font,
hb_glyph_extents_t extents;
hb_font_get_glyph_extents (font, glyph, &extents);
font->get_glyph_extents (glyph, &extents);
metrics->x = extents.x_bearing;
metrics->y = extents.y_bearing;
metrics->width = extents.width;
metrics->height = -extents.height;
metrics->xOffset = hb_font_get_glyph_h_advance (font, glyph);
metrics->xOffset = font->get_glyph_h_advance (glyph);
metrics->yOffset = 0;
}

View File

@ -119,7 +119,7 @@ struct CaretValueFormat2
inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const
{
hb_position_t x, y;
if (hb_font_get_glyph_contour_point_for_origin (font, glyph_id, caretValuePoint, direction, &x, &y))
if (font->get_glyph_contour_point_for_origin (glyph_id, caretValuePoint, direction, &x, &y))
return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y;
else
return 0;

View File

@ -247,7 +247,7 @@ struct AnchorFormat2
hb_bool_t ret = false;
if (x_ppem || y_ppem)
ret = hb_font_get_glyph_contour_point_for_origin (font, glyph_id, anchorPoint, HB_DIRECTION_LTR, &cx, &cy);
ret = font->get_glyph_contour_point_for_origin (glyph_id, anchorPoint, HB_DIRECTION_LTR, &cx, &cy);
*x = x_ppem && ret ? cx : font->em_scale_x (xCoordinate);
*y = y_ppem && ret ? cy : font->em_scale_y (yCoordinate);
}

View File

@ -211,7 +211,7 @@ arabic_fallback_shape (hb_font_t *font, hb_buffer_t *buffer)
for (unsigned int i = 0; i < count; i++) {
hb_codepoint_t u = buffer->info[i].codepoint;
hb_codepoint_t shaped = get_arabic_shape (u, buffer->info[i].arabic_shaping_action());
if (shaped != u && hb_font_get_glyph (font, shaped, 0, &glyph))
if (shaped != u && font->get_glyph (shaped, 0, &glyph))
buffer->info[i].codepoint = shaped;
}
@ -220,7 +220,7 @@ arabic_fallback_shape (hb_font_t *font, hb_buffer_t *buffer)
for (buffer->idx = 0; buffer->idx + 1 < count;) {
hb_codepoint_t ligature = get_ligature (buffer->cur().codepoint,
buffer->cur(+1).codepoint);
if (likely (!ligature) || !(hb_font_get_glyph (font, ligature, 0, &glyph))) {
if (likely (!ligature) || !(font->get_glyph (ligature, 0, &glyph))) {
buffer->next_glyph ();
continue;
}

View File

@ -130,10 +130,10 @@ consonant_position (hb_codepoint_t u,
hb_codepoint_t glyphs[2];
unsigned int virama_pos = IS_OLD_INDIC_TAG (map->get_chosen_script (0)) ? 1 : 0;
hb_font_get_glyph (font, virama, 0, &glyphs[virama_pos]);
hb_font_get_glyph (font, u, 0, &glyphs[1-virama_pos]);
font->get_glyph (virama, 0, &glyphs[virama_pos]);
font->get_glyph (u, 0, &glyphs[1-virama_pos]);
hb_face_t *face = hb_font_get_face (font);
hb_face_t *face = font->face;
if (would_substitute (glyphs, ARRAY_LENGTH (glyphs), HB_TAG('p','r','e','f'), map, face)) return POS_BELOW_C;
if (would_substitute (glyphs, ARRAY_LENGTH (glyphs), HB_TAG('b','l','w','f'), map, face)) return POS_BELOW_C;
if (would_substitute (glyphs, ARRAY_LENGTH (glyphs), HB_TAG('p','s','t','f'), map, face)) return POS_POST_C;

View File

@ -96,10 +96,10 @@ decompose (hb_font_t *font, hb_buffer_t *buffer,
hb_codepoint_t a, b, glyph;
if (!buffer->unicode->decompose (ab, &a, &b) ||
(b && !hb_font_get_glyph (font, b, 0, &glyph)))
(b && !font->get_glyph (b, 0, &glyph)))
return false;
bool has_a = hb_font_get_glyph (font, a, 0, &glyph);
bool has_a = font->get_glyph (a, 0, &glyph);
if (shortest && has_a) {
/* Output a and b */
output_glyph (buffer, a);
@ -137,7 +137,7 @@ decompose_compatibility (hb_font_t *font, hb_buffer_t *buffer,
hb_codepoint_t glyph;
for (i = 0; i < len; i++)
if (!hb_font_get_glyph (font, decomposed[i], 0, &glyph))
if (!font->get_glyph (decomposed[i], 0, &glyph))
return false;
for (i = 0; i < len; i++)
@ -153,11 +153,11 @@ decompose_current_character (hb_font_t *font, hb_buffer_t *buffer,
hb_codepoint_t glyph;
/* Kind of a cute waterfall here... */
if (shortest && hb_font_get_glyph (font, buffer->cur().codepoint, 0, &glyph))
if (shortest && font->get_glyph (buffer->cur().codepoint, 0, &glyph))
buffer->next_glyph ();
else if (decompose (font, buffer, shortest, buffer->cur().codepoint))
buffer->skip_glyph ();
else if (!shortest && hb_font_get_glyph (font, buffer->cur().codepoint, 0, &glyph))
else if (!shortest && font->get_glyph (buffer->cur().codepoint, 0, &glyph))
buffer->next_glyph ();
else if (decompose_compatibility (font, buffer, buffer->cur().codepoint))
buffer->skip_glyph ();
@ -285,7 +285,7 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer,
buffer->cur().codepoint,
&composed) &&
/* And the font has glyph for the composite. */
hb_font_get_glyph (font, composed, 0, &glyph))
font->get_glyph (composed, 0, &glyph))
{
/* Composes. */
buffer->next_glyph (); /* Copy to out-buffer. */

View File

@ -328,15 +328,15 @@ hb_map_glyphs (hb_font_t *font,
unsigned int count = buffer->len - 1;
for (buffer->idx = 0; buffer->idx < count;) {
if (unlikely (buffer->unicode->is_variation_selector (buffer->cur(+1).codepoint))) {
hb_font_get_glyph (font, buffer->cur().codepoint, buffer->cur(+1).codepoint, &glyph);
font->get_glyph (buffer->cur().codepoint, buffer->cur(+1).codepoint, &glyph);
buffer->replace_glyphs (2, 1, &glyph);
} else {
hb_font_get_glyph (font, buffer->cur().codepoint, 0, &glyph);
font->get_glyph (buffer->cur().codepoint, 0, &glyph);
buffer->replace_glyph (glyph);
}
}
if (likely (buffer->idx < buffer->len)) {
hb_font_get_glyph (font, buffer->cur().codepoint, 0, &glyph);
font->get_glyph (buffer->cur().codepoint, 0, &glyph);
buffer->replace_glyph (glyph);
}
buffer->swap_buffers ();
@ -390,14 +390,14 @@ hb_position_default (hb_ot_shape_context_t *c)
unsigned int count = c->buffer->len;
for (unsigned int i = 0; i < count; i++) {
hb_font_get_glyph_advance_for_direction (c->font, c->buffer->info[i].codepoint,
c->buffer->props.direction,
&c->buffer->pos[i].x_advance,
&c->buffer->pos[i].y_advance);
hb_font_subtract_glyph_origin_for_direction (c->font, c->buffer->info[i].codepoint,
c->buffer->props.direction,
&c->buffer->pos[i].x_offset,
&c->buffer->pos[i].y_offset);
c->font->get_glyph_advance_for_direction (c->buffer->info[i].codepoint,
c->buffer->props.direction,
&c->buffer->pos[i].x_advance,
&c->buffer->pos[i].y_advance);
c->font->subtract_glyph_origin_for_direction (c->buffer->info[i].codepoint,
c->buffer->props.direction,
&c->buffer->pos[i].x_offset,
&c->buffer->pos[i].y_offset);
}
}
@ -423,19 +423,19 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
unsigned int count = c->buffer->len;
for (unsigned int i = 0; i < count; i++) {
hb_font_add_glyph_origin_for_direction (c->font, c->buffer->info[i].codepoint,
HB_DIRECTION_LTR,
&c->buffer->pos[i].x_offset,
&c->buffer->pos[i].y_offset);
c->font->add_glyph_origin_for_direction (c->buffer->info[i].codepoint,
HB_DIRECTION_LTR,
&c->buffer->pos[i].x_offset,
&c->buffer->pos[i].y_offset);
}
c->plan->map.position (c->font, c->buffer);
for (unsigned int i = 0; i < count; i++) {
hb_font_subtract_glyph_origin_for_direction (c->font, c->buffer->info[i].codepoint,
HB_DIRECTION_LTR,
&c->buffer->pos[i].x_offset,
&c->buffer->pos[i].y_offset);
c->font->subtract_glyph_origin_for_direction (c->buffer->info[i].codepoint,
HB_DIRECTION_LTR,
&c->buffer->pos[i].x_offset,
&c->buffer->pos[i].y_offset);
}
c->applied_position_complex = true;
@ -460,10 +460,9 @@ hb_truetype_kern (hb_ot_shape_context_t *c)
unsigned int count = c->buffer->len;
for (unsigned int i = 1; i < count; i++) {
hb_position_t x_kern, y_kern, kern1, kern2;
hb_font_get_glyph_kerning_for_direction (c->font,
c->buffer->info[i - 1].codepoint, c->buffer->info[i].codepoint,
c->buffer->props.direction,
&x_kern, &y_kern);
c->font->get_glyph_kerning_for_direction (c->buffer->info[i - 1].codepoint, c->buffer->info[i].codepoint,
c->buffer->props.direction,
&x_kern, &y_kern);
kern1 = x_kern >> 1;
kern2 = x_kern - kern1;
@ -489,7 +488,7 @@ static void
hb_hide_zerowidth (hb_ot_shape_context_t *c)
{
hb_codepoint_t space;
if (!hb_font_get_glyph (c->font, ' ', 0, &space))
if (!c->font->get_glyph (' ', 0, &space))
return; /* No point! */
unsigned int count = c->buffer->len;