Make default font-funcs chain-up to the parent

This commit is contained in:
Behdad Esfahbod 2011-05-10 20:49:02 -04:00
parent b9d975b931
commit 1ded6d8bbf
2 changed files with 60 additions and 25 deletions

View File

@ -49,7 +49,16 @@ hb_font_get_contour_point_nil (hb_font_t *font HB_UNUSED,
hb_position_t *x HB_UNUSED,
hb_position_t *y HB_UNUSED,
const void *user_data HB_UNUSED)
{ return false; }
{
if (font->parent)
return hb_font_get_contour_point (font->parent,
point_index, glyph,
x, y);
*x = *y = 0;
return false;
}
static void
hb_font_get_glyph_advance_nil (hb_font_t *font HB_UNUSED,
@ -58,7 +67,14 @@ hb_font_get_glyph_advance_nil (hb_font_t *font HB_UNUSED,
hb_position_t *x_advance HB_UNUSED,
hb_position_t *y_advance HB_UNUSED,
const void *user_data HB_UNUSED)
{ }
{
if (font->parent) {
hb_font_get_glyph_advance (font->parent, glyph, x_advance, y_advance);
return;
}
*x_advance = *y_advance = 0;
}
static void
hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED,
@ -66,7 +82,15 @@ hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED,
hb_codepoint_t glyph HB_UNUSED,
hb_glyph_extents_t *extents HB_UNUSED,
const void *user_data HB_UNUSED)
{ }
{
if (font->parent) {
hb_font_get_glyph_extents (font->parent, glyph, extents);
return;
}
extents->x_bearing = extents->y_bearing = 0;
extents->width = extents->height = 0;
}
static hb_codepoint_t
hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED,
@ -74,7 +98,12 @@ hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED,
hb_codepoint_t unicode HB_UNUSED,
hb_codepoint_t variation_selector HB_UNUSED,
const void *user_data HB_UNUSED)
{ return 0; }
{
if (font->parent)
return hb_font_get_glyph (font->parent, unicode, variation_selector);
return 0;
}
static hb_position_t
hb_font_get_kerning_nil (hb_font_t *font HB_UNUSED,
@ -82,7 +111,12 @@ hb_font_get_kerning_nil (hb_font_t *font HB_UNUSED,
hb_codepoint_t first_glyph HB_UNUSED,
hb_codepoint_t second_glyph HB_UNUSED,
const void *user_data HB_UNUSED)
{ return 0; }
{
if (font->parent)
return hb_font_get_kerning (font->parent, first_glyph, second_glyph);
return 0;
}
static hb_font_funcs_t _hb_font_funcs_nil = {

View File

@ -121,9 +121,11 @@ typedef struct _hb_glyph_extents_t
hb_position_t height;
} hb_glyph_extents_t;
typedef hb_codepoint_t (*hb_font_get_glyph_func_t) (hb_font_t *font, const void *font_data,
hb_codepoint_t unicode, hb_codepoint_t variation_selector,
const void *user_data);
typedef hb_bool_t (*hb_font_get_contour_point_func_t) (hb_font_t *font, const void *font_data,
unsigned int point_index, hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y,
const void *user_data);
typedef void (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, const void *font_data,
hb_codepoint_t glyph,
hb_position_t *x_advance, hb_position_t *y_advance,
@ -132,19 +134,18 @@ typedef void (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, const void *f
hb_codepoint_t glyph,
hb_glyph_extents_t *extents,
const void *user_data);
typedef hb_bool_t (*hb_font_get_contour_point_func_t) (hb_font_t *font, const void *font_data,
unsigned int point_index, hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y,
const void *user_data);
typedef hb_codepoint_t (*hb_font_get_glyph_func_t) (hb_font_t *font, const void *font_data,
hb_codepoint_t unicode, hb_codepoint_t variation_selector,
const void *user_data);
typedef hb_position_t (*hb_font_get_kerning_func_t) (hb_font_t *font, const void *font_data,
hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
const void *user_data);
void
hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_func_t glyph_func,
void *user_data, hb_destroy_func_t destroy);
hb_font_funcs_set_contour_point_func (hb_font_funcs_t *ffuncs,
hb_font_get_contour_point_func_t contour_point_func,
void *user_data, hb_destroy_func_t destroy);
void
hb_font_funcs_set_glyph_advance_func (hb_font_funcs_t *ffuncs,
@ -157,9 +158,9 @@ hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
void *user_data, hb_destroy_func_t destroy);
void
hb_font_funcs_set_contour_point_func (hb_font_funcs_t *ffuncs,
hb_font_get_contour_point_func_t contour_point_func,
void *user_data, hb_destroy_func_t destroy);
hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_func_t glyph_func,
void *user_data, hb_destroy_func_t destroy);
void
hb_font_funcs_set_kerning_func (hb_font_funcs_t *ffuncs,
@ -167,9 +168,10 @@ hb_font_funcs_set_kerning_func (hb_font_funcs_t *ffuncs,
void *user_data, hb_destroy_func_t destroy);
hb_codepoint_t
hb_font_get_glyph (hb_font_t *font,
hb_codepoint_t unicode, hb_codepoint_t variation_selector);
hb_bool_t
hb_font_get_contour_point (hb_font_t *font,
unsigned int point_index, hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y);
void
hb_font_get_glyph_advance (hb_font_t *font,
@ -181,10 +183,9 @@ hb_font_get_glyph_extents (hb_font_t *font,
hb_codepoint_t glyph,
hb_glyph_extents_t *extents);
hb_bool_t
hb_font_get_contour_point (hb_font_t *font,
unsigned int point_index, hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y);
hb_codepoint_t
hb_font_get_glyph (hb_font_t *font,
hb_codepoint_t unicode, hb_codepoint_t variation_selector);
hb_position_t
hb_font_get_kerning (hb_font_t *font,