提交 19c0eab8 编写于 作者: B Behdad Esfahbod

Add getters for all setter APIs

One in particular is not a straight getter: hb_font_unset_funcs() is
special because of the specific needs of the lifecycle management of
the user_data object.
上级 f0feb084
......@@ -183,6 +183,32 @@ hb_font_funcs_set_kerning_func (hb_font_funcs_t *ffuncs,
}
hb_font_get_glyph_func_t
hb_font_funcs_get_glyph_func (hb_font_funcs_t *ffuncs)
{
return ffuncs->v.get_glyph;
}
hb_font_get_contour_point_func_t
hb_font_funcs_get_contour_point_func (hb_font_funcs_t *ffuncs)
{
return ffuncs->v.get_contour_point;
}
hb_font_get_glyph_metrics_func_t
hb_font_funcs_get_glyph_metrics_func (hb_font_funcs_t *ffuncs)
{
return ffuncs->v.get_glyph_metrics;
}
hb_font_get_kerning_func_t
hb_font_funcs_get_kerning_func (hb_font_funcs_t *ffuncs)
{
return ffuncs->v.get_kerning;
}
hb_codepoint_t
hb_font_get_glyph (hb_font_t *font, hb_face_t *face,
hb_codepoint_t unicode, hb_codepoint_t variation_selector)
......@@ -443,6 +469,26 @@ hb_font_set_funcs (hb_font_t *font,
font->user_data = user_data;
}
void
hb_font_unset_funcs (hb_font_t *font,
hb_font_funcs_t **klass,
hb_destroy_func_t *destroy,
void **user_data)
{
/* None of the input arguments can be NULL. */
*klass = font->klass;
*destroy = font->destroy;
*user_data = font->user_data;
if (HB_OBJECT_IS_INERT (font))
return;
font->klass = NULL;
font->destroy = NULL;
font->user_data = NULL;
}
void
hb_font_set_scale (hb_font_t *font,
unsigned int x_scale,
......@@ -455,6 +501,15 @@ hb_font_set_scale (hb_font_t *font,
font->y_scale = y_scale;
}
void
hb_font_get_scale (hb_font_t *font,
unsigned int *x_scale,
unsigned int *y_scale)
{
if (x_scale) *x_scale = font->x_scale;
if (y_scale) *y_scale = font->y_scale;
}
void
hb_font_set_ppem (hb_font_t *font,
unsigned int x_ppem,
......@@ -467,5 +522,14 @@ hb_font_set_ppem (hb_font_t *font,
font->y_ppem = y_ppem;
}
void
hb_font_get_ppem (hb_font_t *font,
unsigned int *x_ppem,
unsigned int *y_ppem)
{
if (x_ppem) *x_ppem = font->x_ppem;
if (y_ppem) *y_ppem = font->y_ppem;
}
HB_END_DECLS
......@@ -132,6 +132,21 @@ hb_font_funcs_set_kerning_func (hb_font_funcs_t *ffuncs,
hb_font_get_kerning_func_t kerning_func);
/* These never return NULL. Return fallback defaults instead. */
hb_font_get_glyph_func_t
hb_font_funcs_get_glyph_func (hb_font_funcs_t *ffuncs);
hb_font_get_contour_point_func_t
hb_font_funcs_get_contour_point_func (hb_font_funcs_t *ffuncs);
hb_font_get_glyph_metrics_func_t
hb_font_funcs_get_glyph_metrics_func (hb_font_funcs_t *ffuncs);
hb_font_get_kerning_func_t
hb_font_funcs_get_kerning_func (hb_font_funcs_t *ffuncs);
hb_codepoint_t
hb_font_get_glyph (hb_font_t *font, hb_face_t *face,
hb_codepoint_t unicode, hb_codepoint_t variation_selector);
......@@ -174,6 +189,21 @@ hb_font_set_funcs (hb_font_t *font,
hb_destroy_func_t destroy,
void *user_data);
/* Returns what was set and unsets it, but doesn't destroy(user_data).
* This is useful for wrapping / chaining font_funcs_t's.
*
* The client is responsible for:
*
* - Take ownership of the reference on the returned klass
* - Calling "destroy(user_data)" exactly once if returned destroy func
* is not NULL and the returned info is not needed anymore.
*/
void
hb_font_unset_funcs (hb_font_t *font,
hb_font_funcs_t **klass,
hb_destroy_func_t *destroy,
void **user_data);
/*
* We should add support for full matrices.
......@@ -183,6 +213,11 @@ hb_font_set_scale (hb_font_t *font,
unsigned int x_scale,
unsigned int y_scale);
void
hb_font_get_scale (hb_font_t *font,
unsigned int *x_scale,
unsigned int *y_scale);
/*
* A zero value means "no hinting in that direction"
*/
......@@ -191,6 +226,11 @@ hb_font_set_ppem (hb_font_t *font,
unsigned int x_ppem,
unsigned int y_ppem);
void
hb_font_get_ppem (hb_font_t *font,
unsigned int *x_ppem,
unsigned int *y_ppem);
HB_END_DECLS
......
......@@ -160,6 +160,38 @@ hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
}
hb_unicode_get_mirroring_func_t
hb_unicode_funcs_get_mirroring_func (hb_unicode_funcs_t *ufuncs)
{
return ufuncs->v.get_mirroring;
}
hb_unicode_get_general_category_func_t
hb_unicode_funcs_get_general_category_func (hb_unicode_funcs_t *ufuncs)
{
return ufuncs->v.get_general_category;
}
hb_unicode_get_script_func_t
hb_unicode_funcs_get_script_func (hb_unicode_funcs_t *ufuncs)
{
return ufuncs->v.get_script;
}
hb_unicode_get_combining_class_func_t
hb_unicode_funcs_get_combining_class_func (hb_unicode_funcs_t *ufuncs)
{
return ufuncs->v.get_combining_class;
}
hb_unicode_get_eastasian_width_func_t
hb_unicode_funcs_get_eastasian_width_func (hb_unicode_funcs_t *ufuncs)
{
return ufuncs->v.get_eastasian_width;
}
hb_codepoint_t
hb_unicode_get_mirroring (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t unicode)
......
......@@ -202,7 +202,12 @@ void
hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs);
/* funcs */
/*
* funcs
*/
/* typedefs */
typedef hb_codepoint_t (*hb_unicode_get_mirroring_func_t) (hb_codepoint_t unicode);
typedef hb_category_t (*hb_unicode_get_general_category_func_t) (hb_codepoint_t unicode);
......@@ -211,6 +216,8 @@ typedef unsigned int (*hb_unicode_get_combining_class_func_t) (hb_codepoint_t un
typedef unsigned int (*hb_unicode_get_eastasian_width_func_t) (hb_codepoint_t unicode);
/* setters */
void
hb_unicode_funcs_set_mirroring_func (hb_unicode_funcs_t *ufuncs,
hb_unicode_get_mirroring_func_t mirroring_func);
......@@ -232,6 +239,28 @@ hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
hb_unicode_get_eastasian_width_func_t eastasian_width_func);
/* getters */
/* These never return NULL. Return fallback defaults instead. */
hb_unicode_get_mirroring_func_t
hb_unicode_funcs_get_mirroring_func (hb_unicode_funcs_t *ufuncs);
hb_unicode_get_general_category_func_t
hb_unicode_funcs_get_general_category_func (hb_unicode_funcs_t *ufuncs);
hb_unicode_get_script_func_t
hb_unicode_funcs_get_script_func (hb_unicode_funcs_t *ufuncs);
hb_unicode_get_combining_class_func_t
hb_unicode_funcs_get_combining_class_func (hb_unicode_funcs_t *ufuncs);
hb_unicode_get_eastasian_width_func_t
hb_unicode_funcs_get_eastasian_width_func (hb_unicode_funcs_t *ufuncs);
/* accessors */
hb_codepoint_t
hb_unicode_get_mirroring (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t unicode);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册