[draw] Add hb_font_draw_glyph
hb_font_draw_glyph(), hb_font_draw_glyph_func_t and hb_font_funcs_set_draw_glyph_func() are just alternative names for hb_font_get_glyph_shape and friends, to better align with hb_font_paint_glyph.
This commit is contained in:
parent
08da126523
commit
14b026ff86
|
@ -35,6 +35,8 @@
|
||||||
* @include: hb.h
|
* @include: hb.h
|
||||||
*
|
*
|
||||||
* Functions for drawing (extracting) glyph shapes.
|
* Functions for drawing (extracting) glyph shapes.
|
||||||
|
*
|
||||||
|
* The #hb_draw_funcs_t struct can be used with hb_font_draw_glyph().
|
||||||
**/
|
**/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -504,7 +504,7 @@ hb_font_get_glyph_from_name_default (hb_font_t *font,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
hb_font_get_glyph_shape_nil (hb_font_t *font HB_UNUSED,
|
hb_font_draw_glyph_nil (hb_font_t *font HB_UNUSED,
|
||||||
void *font_data HB_UNUSED,
|
void *font_data HB_UNUSED,
|
||||||
hb_codepoint_t glyph,
|
hb_codepoint_t glyph,
|
||||||
hb_draw_funcs_t *draw_funcs,
|
hb_draw_funcs_t *draw_funcs,
|
||||||
|
@ -523,13 +523,13 @@ hb_font_paint_glyph_nil (hb_font_t *font HB_UNUSED,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct hb_font_get_glyph_shape_default_adaptor_t {
|
typedef struct hb_font_draw_glyph_default_adaptor_t {
|
||||||
hb_draw_funcs_t *draw_funcs;
|
hb_draw_funcs_t *draw_funcs;
|
||||||
void *draw_data;
|
void *draw_data;
|
||||||
float x_scale;
|
float x_scale;
|
||||||
float y_scale;
|
float y_scale;
|
||||||
float slant;
|
float slant;
|
||||||
} hb_font_get_glyph_shape_default_adaptor_t;
|
} hb_font_draw_glyph_default_adaptor_t;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
hb_draw_move_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
hb_draw_move_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
||||||
|
@ -538,7 +538,7 @@ hb_draw_move_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
||||||
float to_x, float to_y,
|
float to_x, float to_y,
|
||||||
void *user_data HB_UNUSED)
|
void *user_data HB_UNUSED)
|
||||||
{
|
{
|
||||||
hb_font_get_glyph_shape_default_adaptor_t *adaptor = (hb_font_get_glyph_shape_default_adaptor_t *) draw_data;
|
hb_font_draw_glyph_default_adaptor_t *adaptor = (hb_font_draw_glyph_default_adaptor_t *) draw_data;
|
||||||
float x_scale = adaptor->x_scale;
|
float x_scale = adaptor->x_scale;
|
||||||
float y_scale = adaptor->y_scale;
|
float y_scale = adaptor->y_scale;
|
||||||
float slant = adaptor->slant;
|
float slant = adaptor->slant;
|
||||||
|
@ -553,7 +553,7 @@ hb_draw_line_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED, void *draw_data,
|
||||||
float to_x, float to_y,
|
float to_x, float to_y,
|
||||||
void *user_data HB_UNUSED)
|
void *user_data HB_UNUSED)
|
||||||
{
|
{
|
||||||
hb_font_get_glyph_shape_default_adaptor_t *adaptor = (hb_font_get_glyph_shape_default_adaptor_t *) draw_data;
|
hb_font_draw_glyph_default_adaptor_t *adaptor = (hb_font_draw_glyph_default_adaptor_t *) draw_data;
|
||||||
float x_scale = adaptor->x_scale;
|
float x_scale = adaptor->x_scale;
|
||||||
float y_scale = adaptor->y_scale;
|
float y_scale = adaptor->y_scale;
|
||||||
float slant = adaptor->slant;
|
float slant = adaptor->slant;
|
||||||
|
@ -572,7 +572,7 @@ hb_draw_quadratic_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED, void *draw_data
|
||||||
float to_x, float to_y,
|
float to_x, float to_y,
|
||||||
void *user_data HB_UNUSED)
|
void *user_data HB_UNUSED)
|
||||||
{
|
{
|
||||||
hb_font_get_glyph_shape_default_adaptor_t *adaptor = (hb_font_get_glyph_shape_default_adaptor_t *) draw_data;
|
hb_font_draw_glyph_default_adaptor_t *adaptor = (hb_font_draw_glyph_default_adaptor_t *) draw_data;
|
||||||
float x_scale = adaptor->x_scale;
|
float x_scale = adaptor->x_scale;
|
||||||
float y_scale = adaptor->y_scale;
|
float y_scale = adaptor->y_scale;
|
||||||
float slant = adaptor->slant;
|
float slant = adaptor->slant;
|
||||||
|
@ -593,7 +593,7 @@ hb_draw_cubic_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED, void *draw_data,
|
||||||
float to_x, float to_y,
|
float to_x, float to_y,
|
||||||
void *user_data HB_UNUSED)
|
void *user_data HB_UNUSED)
|
||||||
{
|
{
|
||||||
hb_font_get_glyph_shape_default_adaptor_t *adaptor = (hb_font_get_glyph_shape_default_adaptor_t *) draw_data;
|
hb_font_draw_glyph_default_adaptor_t *adaptor = (hb_font_draw_glyph_default_adaptor_t *) draw_data;
|
||||||
float x_scale = adaptor->x_scale;
|
float x_scale = adaptor->x_scale;
|
||||||
float y_scale = adaptor->y_scale;
|
float y_scale = adaptor->y_scale;
|
||||||
float slant = adaptor->slant;
|
float slant = adaptor->slant;
|
||||||
|
@ -612,7 +612,7 @@ hb_draw_close_path_default (hb_draw_funcs_t *dfuncs HB_UNUSED, void *draw_data,
|
||||||
hb_draw_state_t *st,
|
hb_draw_state_t *st,
|
||||||
void *user_data HB_UNUSED)
|
void *user_data HB_UNUSED)
|
||||||
{
|
{
|
||||||
hb_font_get_glyph_shape_default_adaptor_t *adaptor = (hb_font_get_glyph_shape_default_adaptor_t *) draw_data;
|
hb_font_draw_glyph_default_adaptor_t *adaptor = (hb_font_draw_glyph_default_adaptor_t *) draw_data;
|
||||||
|
|
||||||
adaptor->draw_funcs->emit_close_path (adaptor->draw_data, *st);
|
adaptor->draw_funcs->emit_close_path (adaptor->draw_data, *st);
|
||||||
}
|
}
|
||||||
|
@ -628,14 +628,14 @@ static const hb_draw_funcs_t _hb_draw_funcs_default = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
hb_font_get_glyph_shape_default (hb_font_t *font,
|
hb_font_draw_glyph_default (hb_font_t *font,
|
||||||
void *font_data HB_UNUSED,
|
void *font_data HB_UNUSED,
|
||||||
hb_codepoint_t glyph,
|
hb_codepoint_t glyph,
|
||||||
hb_draw_funcs_t *draw_funcs,
|
hb_draw_funcs_t *draw_funcs,
|
||||||
void *draw_data,
|
void *draw_data,
|
||||||
void *user_data HB_UNUSED)
|
void *user_data HB_UNUSED)
|
||||||
{
|
{
|
||||||
hb_font_get_glyph_shape_default_adaptor_t adaptor = {
|
hb_font_draw_glyph_default_adaptor_t adaptor = {
|
||||||
draw_funcs,
|
draw_funcs,
|
||||||
draw_data,
|
draw_data,
|
||||||
font->parent->x_scale ? (float) font->x_scale / (float) font->parent->x_scale : 0.f,
|
font->parent->x_scale ? (float) font->x_scale / (float) font->parent->x_scale : 0.f,
|
||||||
|
@ -644,7 +644,7 @@ hb_font_get_glyph_shape_default (hb_font_t *font,
|
||||||
(float) font->x_scale / (float) font->parent->y_scale : 0.f
|
(float) font->x_scale / (float) font->parent->y_scale : 0.f
|
||||||
};
|
};
|
||||||
|
|
||||||
font->parent->get_glyph_shape (glyph,
|
font->parent->draw_glyph (glyph,
|
||||||
const_cast<hb_draw_funcs_t *> (&_hb_draw_funcs_default),
|
const_cast<hb_draw_funcs_t *> (&_hb_draw_funcs_default),
|
||||||
&adaptor);
|
&adaptor);
|
||||||
}
|
}
|
||||||
|
@ -1388,14 +1388,37 @@ hb_font_get_glyph_from_name (hb_font_t *font,
|
||||||
* The shape is returned by way of calls to the callbacks of the @dfuncs
|
* The shape is returned by way of calls to the callbacks of the @dfuncs
|
||||||
* objects, with @draw_data passed to them.
|
* objects, with @draw_data passed to them.
|
||||||
*
|
*
|
||||||
* Since: 4.0.0
|
* Since: REPLACEME
|
||||||
**/
|
*
|
||||||
|
* Deprecated: REPLACEME: Use hb_font_draw_glyph() instead.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
hb_font_get_glyph_shape (hb_font_t *font,
|
hb_font_get_glyph_shape (hb_font_t *font,
|
||||||
hb_codepoint_t glyph,
|
hb_codepoint_t glyph,
|
||||||
hb_draw_funcs_t *dfuncs, void *draw_data)
|
hb_draw_funcs_t *dfuncs, void *draw_data)
|
||||||
{
|
{
|
||||||
font->get_glyph_shape (glyph, dfuncs, draw_data);
|
hb_font_draw_glyph (font, glyph, dfuncs, draw_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hb_font_draw_glyph:
|
||||||
|
* @font: #hb_font_t to work upon
|
||||||
|
* @glyph: : The glyph ID
|
||||||
|
* @dfuncs: #hb_draw_funcs_t to draw to
|
||||||
|
* @draw_data: User data to pass to draw callbacks
|
||||||
|
*
|
||||||
|
* Fetches the glyph shape that corresponds to a glyph in the specified @font.
|
||||||
|
* The shape is returned by way of calls to the callbacks of the @dfuncs
|
||||||
|
* objects, with @draw_data passed to them.
|
||||||
|
*
|
||||||
|
* Since: REPLACEME
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
hb_font_draw_glyph (hb_font_t *font,
|
||||||
|
hb_codepoint_t glyph,
|
||||||
|
hb_draw_funcs_t *dfuncs, void *draw_data)
|
||||||
|
{
|
||||||
|
font->draw_glyph (glyph, dfuncs, draw_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2386,9 +2409,8 @@ hb_font_get_ptem (hb_font_t *font)
|
||||||
* HarfBuzz needs to know this value to adjust shaping results,
|
* HarfBuzz needs to know this value to adjust shaping results,
|
||||||
* metrics, and style values to match the slanted rendering.
|
* metrics, and style values to match the slanted rendering.
|
||||||
*
|
*
|
||||||
* <note>Note: The glyph shape fetched via the
|
* <note>Note: The glyph shape fetched via the hb_font_draw_glyph()
|
||||||
* hb_font_get_glyph_shape() is slanted to reflect this value
|
* function is slanted to reflect this value as well.</note>
|
||||||
* as well.</note>
|
|
||||||
*
|
*
|
||||||
* <note>Note: The slant value is a ratio. For example, a
|
* <note>Note: The slant value is a ratio. For example, a
|
||||||
* 20% slant would be represented as a 0.2 value.</note>
|
* 20% slant would be represented as a 0.2 value.</note>
|
||||||
|
@ -2812,3 +2834,13 @@ hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
|
||||||
trampoline_destroy);
|
trampoline_destroy);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
hb_font_funcs_set_glyph_shape_func (hb_font_funcs_t *ffuncs,
|
||||||
|
hb_font_get_glyph_shape_func_t func,
|
||||||
|
void *user_data,
|
||||||
|
hb_destroy_func_t destroy /* May be NULL. */)
|
||||||
|
{
|
||||||
|
hb_font_funcs_set_draw_glyph_func (ffuncs, func, user_data, destroy);
|
||||||
|
}
|
||||||
|
|
|
@ -507,12 +507,32 @@ typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *
|
||||||
*
|
*
|
||||||
* Since: 4.0.0
|
* Since: 4.0.0
|
||||||
*
|
*
|
||||||
|
* Deprecated: REPLACEME: Use #hb_font_draw_glyph_func_t instead
|
||||||
**/
|
**/
|
||||||
typedef void (*hb_font_get_glyph_shape_func_t) (hb_font_t *font, void *font_data,
|
typedef void (*hb_font_get_glyph_shape_func_t) (hb_font_t *font, void *font_data,
|
||||||
hb_codepoint_t glyph,
|
hb_codepoint_t glyph,
|
||||||
hb_draw_funcs_t *draw_funcs, void *draw_data,
|
hb_draw_funcs_t *draw_funcs, void *draw_data,
|
||||||
void *user_data);
|
void *user_data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hb_font_draw_glyph_func_t:
|
||||||
|
* @font: #hb_font_t to work upon
|
||||||
|
* @font_data: @font user data pointer
|
||||||
|
* @glyph: The glyph ID to query
|
||||||
|
* @draw_funcs: The draw functions to send the shape data to
|
||||||
|
* @draw_data: The data accompanying the draw functions
|
||||||
|
* @user_data: User data pointer passed by the caller
|
||||||
|
*
|
||||||
|
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
||||||
|
*
|
||||||
|
* Since: REPLACEME
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
typedef void (*hb_font_draw_glyph_func_t) (hb_font_t *font, void *font_data,
|
||||||
|
hb_codepoint_t glyph,
|
||||||
|
hb_draw_funcs_t *draw_funcs, void *draw_data,
|
||||||
|
void *user_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hb_font_paint_glyph_func_t:
|
* hb_font_paint_glyph_func_t:
|
||||||
* @font: #hb_font_t to work upon
|
* @font: #hb_font_t to work upon
|
||||||
|
@ -796,15 +816,34 @@ hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t *ffuncs,
|
||||||
* @user_data: Data to pass to @func
|
* @user_data: Data to pass to @func
|
||||||
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||||
*
|
*
|
||||||
* Sets the implementation function for #hb_font_get_glyph_shape_func_t.
|
* Sets the implementation function for #hb_font_get_glyph_shape_func_t,
|
||||||
|
* which is the same as #hb_font_draw_glyph_func_t.
|
||||||
*
|
*
|
||||||
* Since: 4.0.0
|
* Since: 4.0.0
|
||||||
|
*
|
||||||
|
* Deprecated: REPLACEME: Use hb_font_set_draw_glyph_func() instead
|
||||||
**/
|
**/
|
||||||
HB_EXTERN void
|
HB_EXTERN void
|
||||||
hb_font_funcs_set_glyph_shape_func (hb_font_funcs_t *ffuncs,
|
hb_font_funcs_set_glyph_shape_func (hb_font_funcs_t *ffuncs,
|
||||||
hb_font_get_glyph_shape_func_t func,
|
hb_font_get_glyph_shape_func_t func,
|
||||||
void *user_data, hb_destroy_func_t destroy);
|
void *user_data, hb_destroy_func_t destroy);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hb_font_funcs_set_draw_glyph_func:
|
||||||
|
* @ffuncs: A font-function structure
|
||||||
|
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
||||||
|
* @user_data: Data to pass to @func
|
||||||
|
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
||||||
|
*
|
||||||
|
* Sets the implementation function for #hb_font_draw_glyph_func_t.
|
||||||
|
*
|
||||||
|
* Since: REPLACEME
|
||||||
|
**/
|
||||||
|
HB_EXTERN void
|
||||||
|
hb_font_funcs_set_draw_glyph_func (hb_font_funcs_t *ffuncs,
|
||||||
|
hb_font_draw_glyph_func_t func,
|
||||||
|
void *user_data, hb_destroy_func_t destroy);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hb_font_funcs_set_paint_glyph_func:
|
* hb_font_funcs_set_paint_glyph_func:
|
||||||
* @ffuncs:
|
* @ffuncs:
|
||||||
|
@ -906,6 +945,11 @@ hb_font_get_glyph_shape (hb_font_t *font,
|
||||||
hb_codepoint_t glyph,
|
hb_codepoint_t glyph,
|
||||||
hb_draw_funcs_t *dfuncs, void *draw_data);
|
hb_draw_funcs_t *dfuncs, void *draw_data);
|
||||||
|
|
||||||
|
HB_EXTERN void
|
||||||
|
hb_font_draw_glyph (hb_font_t *font,
|
||||||
|
hb_codepoint_t glyph,
|
||||||
|
hb_draw_funcs_t *dfuncs, void *draw_data);
|
||||||
|
|
||||||
HB_EXTERN void
|
HB_EXTERN void
|
||||||
hb_font_paint_glyph (hb_font_t *font,
|
hb_font_paint_glyph (hb_font_t *font,
|
||||||
hb_codepoint_t glyph,
|
hb_codepoint_t glyph,
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
HB_FONT_FUNC_IMPLEMENT (get_,glyph_contour_point) \
|
HB_FONT_FUNC_IMPLEMENT (get_,glyph_contour_point) \
|
||||||
HB_FONT_FUNC_IMPLEMENT (get_,glyph_name) \
|
HB_FONT_FUNC_IMPLEMENT (get_,glyph_name) \
|
||||||
HB_FONT_FUNC_IMPLEMENT (get_,glyph_from_name) \
|
HB_FONT_FUNC_IMPLEMENT (get_,glyph_from_name) \
|
||||||
HB_FONT_FUNC_IMPLEMENT (get_,glyph_shape) \
|
HB_FONT_FUNC_IMPLEMENT (,draw_glyph) \
|
||||||
HB_FONT_FUNC_IMPLEMENT (,paint_glyph) \
|
HB_FONT_FUNC_IMPLEMENT (,paint_glyph) \
|
||||||
/* ^--- Add new callbacks here */
|
/* ^--- Add new callbacks here */
|
||||||
|
|
||||||
|
@ -393,13 +393,13 @@ struct hb_font_t
|
||||||
!klass->user_data ? nullptr : klass->user_data->glyph_from_name);
|
!klass->user_data ? nullptr : klass->user_data->glyph_from_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_glyph_shape (hb_codepoint_t glyph,
|
void draw_glyph (hb_codepoint_t glyph,
|
||||||
hb_draw_funcs_t *draw_funcs, void *draw_data)
|
hb_draw_funcs_t *draw_funcs, void *draw_data)
|
||||||
{
|
{
|
||||||
klass->get.f.glyph_shape (this, user_data,
|
klass->get.f.draw_glyph (this, user_data,
|
||||||
glyph,
|
glyph,
|
||||||
draw_funcs, draw_data,
|
draw_funcs, draw_data,
|
||||||
!klass->user_data ? nullptr : klass->user_data->glyph_shape);
|
!klass->user_data ? nullptr : klass->user_data->draw_glyph);
|
||||||
}
|
}
|
||||||
|
|
||||||
void paint_glyph (hb_codepoint_t glyph,
|
void paint_glyph (hb_codepoint_t glyph,
|
||||||
|
|
|
@ -425,7 +425,7 @@ hb_ot_get_font_v_extents (hb_font_t *font,
|
||||||
|
|
||||||
#ifndef HB_NO_DRAW
|
#ifndef HB_NO_DRAW
|
||||||
static void
|
static void
|
||||||
hb_ot_get_glyph_shape (hb_font_t *font,
|
hb_ot_draw_glyph (hb_font_t *font,
|
||||||
void *font_data HB_UNUSED,
|
void *font_data HB_UNUSED,
|
||||||
hb_codepoint_t glyph,
|
hb_codepoint_t glyph,
|
||||||
hb_draw_funcs_t *draw_funcs, void *draw_data,
|
hb_draw_funcs_t *draw_funcs, void *draw_data,
|
||||||
|
@ -487,7 +487,7 @@ static struct hb_ot_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t<hb_ot
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HB_NO_DRAW
|
#ifndef HB_NO_DRAW
|
||||||
hb_font_funcs_set_glyph_shape_func (funcs, hb_ot_get_glyph_shape, nullptr, nullptr);
|
hb_font_funcs_set_draw_glyph_func (funcs, hb_ot_draw_glyph, nullptr, nullptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HB_NO_PAINT
|
#ifndef HB_NO_PAINT
|
||||||
|
|
Loading…
Reference in New Issue