batchwidth

This commit is contained in:
Koji Ishii 2018-08-01 13:01:08 +09:00 committed by Behdad Esfahbod
parent b912fbea17
commit 9533364cc3
4 changed files with 67 additions and 2 deletions

View File

@ -54,6 +54,7 @@
HB_FONT_FUNC_IMPLEMENT (glyph_contour_point) \
HB_FONT_FUNC_IMPLEMENT (glyph_name) \
HB_FONT_FUNC_IMPLEMENT (glyph_from_name) \
HB_FONT_FUNC_IMPLEMENT (glyph_h_advances) \
/* ^--- Add new callbacks here */
struct hb_font_funcs_t
@ -227,6 +228,18 @@ struct hb_font_t
klass->user_data.glyph_h_advance);
}
inline void get_glyph_h_advances(unsigned count,
hb_codepoint_t* glyphs,
unsigned glyph_struct_size,
hb_position_t* advances,
unsigned advance_struct_size) {
return klass->get.f.glyph_h_advances (this, user_data,
count,
glyphs, glyph_struct_size,
advances, advance_struct_size,
klass->user_data.glyph_h_advances);
}
inline hb_position_t get_glyph_v_advance (hb_codepoint_t glyph)
{
return klass->get.f.glyph_v_advance (this, user_data,

View File

@ -143,6 +143,43 @@ hb_font_get_glyph_h_advance_parent (hb_font_t *font,
return font->parent_scale_x_distance (font->parent->get_glyph_h_advance (glyph));
}
template <class T>
T* advance_by_byte_size(T* p, unsigned byte_size) {
return reinterpret_cast<T*>(reinterpret_cast<uint8_t*>(p) + byte_size);
}
static void
hb_font_get_glyph_h_advances_nil(hb_font_t *font,
void *font_data HB_UNUSED,
unsigned count,
hb_codepoint_t* glyphs,
unsigned glyph_struct_size,
hb_position_t* advances,
unsigned advance_struct_size,
void *user_data HB_UNUSED) {
for (; count--;
glyphs = advance_by_byte_size(glyphs, glyph_struct_size),
advances = advance_by_byte_size(advances, advance_struct_size)) {
*advances = hb_font_get_glyph_h_advance_nil(font, font_data, *glyphs, user_data);
}
}
static void
hb_font_get_glyph_h_advances_parent(hb_font_t* font,
void* font_data HB_UNUSED,
unsigned count,
hb_codepoint_t* glyphs,
unsigned glyph_struct_size,
hb_position_t* advances,
unsigned advance_struct_size,
void* user_data HB_UNUSED) {
for (; count--;
glyphs = advance_by_byte_size(glyphs, glyph_struct_size),
advances = advance_by_byte_size(advances, advance_struct_size)) {
*advances = hb_font_get_glyph_h_advance_parent(font, font_data, *glyphs, user_data);
}
}
static hb_position_t
hb_font_get_glyph_v_advance_nil (hb_font_t *font,
void *font_data HB_UNUSED,

View File

@ -132,6 +132,16 @@ typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void
typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t;
typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t;
typedef void (*hb_font_get_glyph_h_advances_func_t)(
hb_font_t* font,
void* font_data,
unsigned count,
hb_codepoint_t* glyphs,
unsigned glyph_struct_size,
hb_position_t* advances,
unsigned advance_struct_size,
void* user_data);
typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data,
hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y,
@ -248,6 +258,11 @@ hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_h_advance_func_t func,
void *user_data, hb_destroy_func_t destroy);
HB_EXTERN void
hb_font_funcs_set_glyph_h_advances_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_h_advances_func_t func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_font_funcs_set_glyph_v_advance_func:
* @ffuncs: font functions.

View File

@ -680,8 +680,8 @@ hb_ot_position_default (hb_ot_shape_context_t *c)
if (HB_DIRECTION_IS_HORIZONTAL (direction))
{
for (unsigned int i = 0; i < count; i++)
pos[i].x_advance = c->font->get_glyph_h_advance (info[i].codepoint);
c->font->get_glyph_h_advances (count, &info[0].codepoint, sizeof(info[0]),
&pos[0].x_advance, sizeof(pos[0]));
/* The nil glyph_h_origin() func returns 0, so no need to apply it. */
if (c->font->has_glyph_h_origin_func ())
for (unsigned int i = 0; i < count; i++)