Add batch advance width callback function

New API:
+hb_font_funcs_set_glyph_h_advances_func
+hb_font_funcs_set_glyph_v_advances_func
+hb_font_get_glyph_h_advances
+hb_font_get_glyph_h_advances_func_t
+hb_font_get_glyph_v_advances
+hb_font_get_glyph_v_advances_func_t
This commit is contained in:
Behdad Esfahbod 2018-08-06 09:45:17 -07:00
parent 9533364cc3
commit 79e21984b1
5 changed files with 256 additions and 148 deletions

View File

@ -208,10 +208,12 @@ hb_font_funcs_set_glyph_contour_point_func
hb_font_funcs_set_glyph_extents_func hb_font_funcs_set_glyph_extents_func
hb_font_funcs_set_glyph_from_name_func hb_font_funcs_set_glyph_from_name_func
hb_font_funcs_set_glyph_h_advance_func hb_font_funcs_set_glyph_h_advance_func
hb_font_funcs_set_glyph_h_advances_func
hb_font_funcs_set_glyph_h_kerning_func hb_font_funcs_set_glyph_h_kerning_func
hb_font_funcs_set_glyph_h_origin_func hb_font_funcs_set_glyph_h_origin_func
hb_font_funcs_set_glyph_name_func hb_font_funcs_set_glyph_name_func
hb_font_funcs_set_glyph_v_advance_func hb_font_funcs_set_glyph_v_advance_func
hb_font_funcs_set_glyph_v_advances_func
hb_font_funcs_set_glyph_v_kerning_func hb_font_funcs_set_glyph_v_kerning_func
hb_font_funcs_set_glyph_v_origin_func hb_font_funcs_set_glyph_v_origin_func
hb_font_funcs_set_nominal_glyph_func hb_font_funcs_set_nominal_glyph_func
@ -233,6 +235,8 @@ hb_font_get_glyph_from_name
hb_font_get_glyph_from_name_func_t hb_font_get_glyph_from_name_func_t
hb_font_get_glyph_h_advance hb_font_get_glyph_h_advance
hb_font_get_glyph_h_advance_func_t hb_font_get_glyph_h_advance_func_t
hb_font_get_glyph_h_advances
hb_font_get_glyph_h_advances_func_t
hb_font_get_glyph_h_kerning hb_font_get_glyph_h_kerning
hb_font_get_glyph_h_kerning_func_t hb_font_get_glyph_h_kerning_func_t
hb_font_get_glyph_h_origin hb_font_get_glyph_h_origin
@ -245,6 +249,8 @@ hb_font_get_glyph_origin_for_direction
hb_font_get_glyph_origin_func_t hb_font_get_glyph_origin_func_t
hb_font_get_glyph_v_advance hb_font_get_glyph_v_advance
hb_font_get_glyph_v_advance_func_t hb_font_get_glyph_v_advance_func_t
hb_font_get_glyph_v_advances
hb_font_get_glyph_v_advances_func_t
hb_font_get_glyph_v_kerning hb_font_get_glyph_v_kerning
hb_font_get_glyph_v_kerning_func_t hb_font_get_glyph_v_kerning_func_t
hb_font_get_glyph_v_origin hb_font_get_glyph_v_origin

View File

@ -46,6 +46,8 @@
HB_FONT_FUNC_IMPLEMENT (variation_glyph) \ HB_FONT_FUNC_IMPLEMENT (variation_glyph) \
HB_FONT_FUNC_IMPLEMENT (glyph_h_advance) \ HB_FONT_FUNC_IMPLEMENT (glyph_h_advance) \
HB_FONT_FUNC_IMPLEMENT (glyph_v_advance) \ HB_FONT_FUNC_IMPLEMENT (glyph_v_advance) \
HB_FONT_FUNC_IMPLEMENT (glyph_h_advances) \
HB_FONT_FUNC_IMPLEMENT (glyph_v_advances) \
HB_FONT_FUNC_IMPLEMENT (glyph_h_origin) \ HB_FONT_FUNC_IMPLEMENT (glyph_h_origin) \
HB_FONT_FUNC_IMPLEMENT (glyph_v_origin) \ HB_FONT_FUNC_IMPLEMENT (glyph_v_origin) \
HB_FONT_FUNC_IMPLEMENT (glyph_h_kerning) \ HB_FONT_FUNC_IMPLEMENT (glyph_h_kerning) \
@ -54,7 +56,6 @@
HB_FONT_FUNC_IMPLEMENT (glyph_contour_point) \ HB_FONT_FUNC_IMPLEMENT (glyph_contour_point) \
HB_FONT_FUNC_IMPLEMENT (glyph_name) \ HB_FONT_FUNC_IMPLEMENT (glyph_name) \
HB_FONT_FUNC_IMPLEMENT (glyph_from_name) \ HB_FONT_FUNC_IMPLEMENT (glyph_from_name) \
HB_FONT_FUNC_IMPLEMENT (glyph_h_advances) \
/* ^--- Add new callbacks here */ /* ^--- Add new callbacks here */
struct hb_font_funcs_t struct hb_font_funcs_t
@ -228,18 +229,6 @@ struct hb_font_t
klass->user_data.glyph_h_advance); 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) inline hb_position_t get_glyph_v_advance (hb_codepoint_t glyph)
{ {
return klass->get.f.glyph_v_advance (this, user_data, return klass->get.f.glyph_v_advance (this, user_data,
@ -247,6 +236,32 @@ struct hb_font_t
klass->user_data.glyph_v_advance); klass->user_data.glyph_v_advance);
} }
inline void get_glyph_h_advances (unsigned int count,
hb_codepoint_t *first_glyph,
unsigned int glyph_stride,
hb_position_t *first_advance,
unsigned int advance_stride)
{
return klass->get.f.glyph_h_advances (this, user_data,
count,
first_glyph, glyph_stride,
first_advance, advance_stride,
klass->user_data.glyph_h_advances);
}
inline void get_glyph_v_advances (unsigned int count,
hb_codepoint_t *first_glyph,
unsigned int glyph_stride,
hb_position_t *first_advance,
unsigned int advance_stride)
{
return klass->get.f.glyph_v_advances (this, user_data,
count,
first_glyph, glyph_stride,
first_advance, advance_stride,
klass->user_data.glyph_v_advances);
}
inline hb_bool_t get_glyph_h_origin (hb_codepoint_t glyph, inline hb_bool_t get_glyph_h_origin (hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y) hb_position_t *x, hb_position_t *y)
{ {

View File

@ -29,6 +29,7 @@
#include "hb-private.hh" #include "hb-private.hh"
#include "hb-font-private.hh" #include "hb-font-private.hh"
#include "hb-machinery-private.hh"
/* /*
@ -45,10 +46,10 @@ hb_font_get_font_h_extents_nil (hb_font_t *font HB_UNUSED,
return false; return false;
} }
static hb_bool_t static hb_bool_t
hb_font_get_font_h_extents_parent (hb_font_t *font, hb_font_get_font_h_extents_default (hb_font_t *font,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_font_extents_t *metrics, hb_font_extents_t *metrics,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
hb_bool_t ret = font->parent->get_font_h_extents (metrics); hb_bool_t ret = font->parent->get_font_h_extents (metrics);
if (ret) { if (ret) {
@ -69,10 +70,10 @@ hb_font_get_font_v_extents_nil (hb_font_t *font HB_UNUSED,
return false; return false;
} }
static hb_bool_t static hb_bool_t
hb_font_get_font_v_extents_parent (hb_font_t *font, hb_font_get_font_v_extents_default (hb_font_t *font,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_font_extents_t *metrics, hb_font_extents_t *metrics,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
hb_bool_t ret = font->parent->get_font_v_extents (metrics); hb_bool_t ret = font->parent->get_font_v_extents (metrics);
if (ret) { if (ret) {
@ -94,11 +95,11 @@ hb_font_get_nominal_glyph_nil (hb_font_t *font HB_UNUSED,
return false; return false;
} }
static hb_bool_t static hb_bool_t
hb_font_get_nominal_glyph_parent (hb_font_t *font, hb_font_get_nominal_glyph_default (hb_font_t *font,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t unicode, hb_codepoint_t unicode,
hb_codepoint_t *glyph, hb_codepoint_t *glyph,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
return font->parent->get_nominal_glyph (unicode, glyph); return font->parent->get_nominal_glyph (unicode, glyph);
} }
@ -115,12 +116,12 @@ hb_font_get_variation_glyph_nil (hb_font_t *font HB_UNUSED,
return false; return false;
} }
static hb_bool_t static hb_bool_t
hb_font_get_variation_glyph_parent (hb_font_t *font, hb_font_get_variation_glyph_default (hb_font_t *font,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t unicode, hb_codepoint_t unicode,
hb_codepoint_t variation_selector, hb_codepoint_t variation_selector,
hb_codepoint_t *glyph, hb_codepoint_t *glyph,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
return font->parent->get_variation_glyph (unicode, variation_selector, glyph); return font->parent->get_variation_glyph (unicode, variation_selector, glyph);
} }
@ -129,75 +130,134 @@ hb_font_get_variation_glyph_parent (hb_font_t *font,
static hb_position_t static hb_position_t
hb_font_get_glyph_h_advance_nil (hb_font_t *font, hb_font_get_glyph_h_advance_nil (hb_font_t *font,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t glyph, hb_codepoint_t glyph HB_UNUSED,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
return font->x_scale; return font->x_scale;
} }
static hb_position_t static hb_position_t
hb_font_get_glyph_h_advance_parent (hb_font_t *font, hb_font_get_glyph_h_advance_default (hb_font_t *font,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t glyph, hb_codepoint_t glyph,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
return font->parent_scale_x_distance (font->parent->get_glyph_h_advance (glyph)); 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 static hb_position_t
hb_font_get_glyph_v_advance_nil (hb_font_t *font, hb_font_get_glyph_v_advance_nil (hb_font_t *font,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t glyph, hb_codepoint_t glyph HB_UNUSED,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
/* TODO use font_extents.ascender+descender */ /* TODO use font_extents.ascender+descender */
return font->y_scale; return font->y_scale;
} }
static hb_position_t static hb_position_t
hb_font_get_glyph_v_advance_parent (hb_font_t *font, hb_font_get_glyph_v_advance_default (hb_font_t *font,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t glyph, hb_codepoint_t glyph,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
return font->parent_scale_y_distance (font->parent->get_glyph_v_advance (glyph)); return font->parent_scale_y_distance (font->parent->get_glyph_v_advance (glyph));
} }
static void
hb_font_get_glyph_h_advances_nil (hb_font_t* font,
void* font_data HB_UNUSED,
unsigned int count,
hb_codepoint_t *first_glyph HB_UNUSED,
unsigned int glyph_stride HB_UNUSED,
hb_position_t *first_advance,
unsigned int advance_stride,
void *user_data HB_UNUSED)
{
for (unsigned int i = 0; i < count; i++)
{
*first_advance = font->get_glyph_h_advance (*first_glyph);
first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride);
first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride);
}
}
static void
hb_font_get_glyph_h_advances_default (hb_font_t* font,
void* font_data HB_UNUSED,
unsigned int count,
hb_codepoint_t *first_glyph,
unsigned int glyph_stride,
hb_position_t *first_advance,
unsigned int advance_stride,
void *user_data HB_UNUSED)
{
if (font->has_glyph_h_advance_func ())
{
for (unsigned int i = 0; i < count; i++)
{
*first_advance = font->get_glyph_h_advance (*first_glyph);
first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride);
first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride);
}
return;
}
font->parent->get_glyph_h_advances (count,
first_glyph, glyph_stride,
first_advance, advance_stride);
for (unsigned int i = 0; i < count; i++)
{
*first_advance = font->parent_scale_x_distance (*first_advance);
first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride);
}
}
static void
hb_font_get_glyph_v_advances_nil (hb_font_t* font,
void* font_data HB_UNUSED,
unsigned int count,
hb_codepoint_t *first_glyph HB_UNUSED,
unsigned int glyph_stride HB_UNUSED,
hb_position_t *first_advance,
unsigned int advance_stride,
void *user_data HB_UNUSED)
{
for (unsigned int i = 0; i < count; i++)
{
*first_advance = font->get_glyph_v_advance (*first_glyph);
first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride);
first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride);
}
}
static void
hb_font_get_glyph_v_advances_default (hb_font_t* font,
void* font_data HB_UNUSED,
unsigned int count,
hb_codepoint_t *first_glyph,
unsigned int glyph_stride,
hb_position_t *first_advance,
unsigned int advance_stride,
void *user_data HB_UNUSED)
{
if (font->has_glyph_v_advance_func ())
{
for (unsigned int i = 0; i < count; i++)
{
*first_advance = font->get_glyph_v_advance (*first_glyph);
first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride);
first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride);
}
return;
}
font->parent->get_glyph_v_advances (count,
first_glyph, glyph_stride,
first_advance, advance_stride);
for (unsigned int i = 0; i < count; i++)
{
*first_advance = font->parent_scale_y_distance (*first_advance);
first_advance = &StructAtOffset<hb_position_t> (first_advance, advance_stride);
}
}
static hb_bool_t static hb_bool_t
hb_font_get_glyph_h_origin_nil (hb_font_t *font HB_UNUSED, hb_font_get_glyph_h_origin_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
@ -210,12 +270,12 @@ hb_font_get_glyph_h_origin_nil (hb_font_t *font HB_UNUSED,
return true; return true;
} }
static hb_bool_t static hb_bool_t
hb_font_get_glyph_h_origin_parent (hb_font_t *font, hb_font_get_glyph_h_origin_default (hb_font_t *font,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *x,
hb_position_t *y, hb_position_t *y,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
hb_bool_t ret = font->parent->get_glyph_h_origin (glyph, x, y); hb_bool_t ret = font->parent->get_glyph_h_origin (glyph, x, y);
if (ret) if (ret)
@ -235,12 +295,12 @@ hb_font_get_glyph_v_origin_nil (hb_font_t *font HB_UNUSED,
return false; return false;
} }
static hb_bool_t static hb_bool_t
hb_font_get_glyph_v_origin_parent (hb_font_t *font, hb_font_get_glyph_v_origin_default (hb_font_t *font,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *x,
hb_position_t *y, hb_position_t *y,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
hb_bool_t ret = font->parent->get_glyph_v_origin (glyph, x, y); hb_bool_t ret = font->parent->get_glyph_v_origin (glyph, x, y);
if (ret) if (ret)
@ -258,11 +318,11 @@ hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED,
return 0; return 0;
} }
static hb_position_t static hb_position_t
hb_font_get_glyph_h_kerning_parent (hb_font_t *font, hb_font_get_glyph_h_kerning_default (hb_font_t *font,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t left_glyph, hb_codepoint_t left_glyph,
hb_codepoint_t right_glyph, hb_codepoint_t right_glyph,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
return font->parent_scale_x_distance (font->parent->get_glyph_h_kerning (left_glyph, right_glyph)); return font->parent_scale_x_distance (font->parent->get_glyph_h_kerning (left_glyph, right_glyph));
} }
@ -277,11 +337,11 @@ hb_font_get_glyph_v_kerning_nil (hb_font_t *font HB_UNUSED,
return 0; return 0;
} }
static hb_position_t static hb_position_t
hb_font_get_glyph_v_kerning_parent (hb_font_t *font, hb_font_get_glyph_v_kerning_default (hb_font_t *font,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t top_glyph, hb_codepoint_t top_glyph,
hb_codepoint_t bottom_glyph, hb_codepoint_t bottom_glyph,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
return font->parent_scale_y_distance (font->parent->get_glyph_v_kerning (top_glyph, bottom_glyph)); return font->parent_scale_y_distance (font->parent->get_glyph_v_kerning (top_glyph, bottom_glyph));
} }
@ -297,11 +357,11 @@ hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED,
return false; return false;
} }
static hb_bool_t static hb_bool_t
hb_font_get_glyph_extents_parent (hb_font_t *font, hb_font_get_glyph_extents_default (hb_font_t *font,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_glyph_extents_t *extents, hb_glyph_extents_t *extents,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
hb_bool_t ret = font->parent->get_glyph_extents (glyph, extents); hb_bool_t ret = font->parent->get_glyph_extents (glyph, extents);
if (ret) { if (ret) {
@ -324,13 +384,13 @@ hb_font_get_glyph_contour_point_nil (hb_font_t *font HB_UNUSED,
return false; return false;
} }
static hb_bool_t static hb_bool_t
hb_font_get_glyph_contour_point_parent (hb_font_t *font, hb_font_get_glyph_contour_point_default (hb_font_t *font,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t glyph, hb_codepoint_t glyph,
unsigned int point_index, unsigned int point_index,
hb_position_t *x, hb_position_t *x,
hb_position_t *y, hb_position_t *y,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
hb_bool_t ret = font->parent->get_glyph_contour_point (glyph, point_index, x, y); hb_bool_t ret = font->parent->get_glyph_contour_point (glyph, point_index, x, y);
if (ret) if (ret)
@ -349,11 +409,11 @@ hb_font_get_glyph_name_nil (hb_font_t *font HB_UNUSED,
return false; return false;
} }
static hb_bool_t static hb_bool_t
hb_font_get_glyph_name_parent (hb_font_t *font, hb_font_get_glyph_name_default (hb_font_t *font,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t glyph, hb_codepoint_t glyph,
char *name, unsigned int size, char *name, unsigned int size,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
return font->parent->get_glyph_name (glyph, name, size); return font->parent->get_glyph_name (glyph, name, size);
} }
@ -369,11 +429,11 @@ hb_font_get_glyph_from_name_nil (hb_font_t *font HB_UNUSED,
return false; return false;
} }
static hb_bool_t static hb_bool_t
hb_font_get_glyph_from_name_parent (hb_font_t *font, hb_font_get_glyph_from_name_default (hb_font_t *font,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
const char *name, int len, /* -1 means nul-terminated */ const char *name, int len, /* -1 means nul-terminated */
hb_codepoint_t *glyph, hb_codepoint_t *glyph,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
return font->parent->get_glyph_from_name (name, len, glyph); return font->parent->get_glyph_from_name (name, len, glyph);
} }
@ -403,7 +463,7 @@ DEFINE_NULL_INSTANCE (hb_font_funcs_t) =
} }
}; };
static const hb_font_funcs_t _hb_font_funcs_parent = { static const hb_font_funcs_t _hb_font_funcs_default = {
HB_OBJECT_HEADER_STATIC, HB_OBJECT_HEADER_STATIC,
true, /* immutable */ true, /* immutable */
@ -420,7 +480,7 @@ static const hb_font_funcs_t _hb_font_funcs_parent = {
}, },
{ {
{ {
#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_parent, #define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_default,
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_FONT_FUNC_IMPLEMENT #undef HB_FONT_FUNC_IMPLEMENT
} }
@ -445,7 +505,7 @@ hb_font_funcs_create (void)
if (!(ffuncs = hb_object_create<hb_font_funcs_t> ())) if (!(ffuncs = hb_object_create<hb_font_funcs_t> ()))
return hb_font_funcs_get_empty (); return hb_font_funcs_get_empty ();
ffuncs->get = _hb_font_funcs_parent.get; ffuncs->get = _hb_font_funcs_default.get;
return ffuncs; return ffuncs;
} }
@ -462,7 +522,7 @@ hb_font_funcs_create (void)
hb_font_funcs_t * hb_font_funcs_t *
hb_font_funcs_get_empty (void) hb_font_funcs_get_empty (void)
{ {
return const_cast<hb_font_funcs_t *> (&_hb_font_funcs_parent); return const_cast<hb_font_funcs_t *> (&_hb_font_funcs_default);
} }
/** /**
@ -601,9 +661,9 @@ hb_font_funcs_set_##name##_func (hb_font_funcs_t *ffuncs, \
ffuncs->user_data.name = user_data; \ ffuncs->user_data.name = user_data; \
ffuncs->destroy.name = destroy; \ ffuncs->destroy.name = destroy; \
} else { \ } else { \
ffuncs->get.f.name = hb_font_get_##name##_parent; \ ffuncs->get.f.name = hb_font_get_##name##_default; \
ffuncs->user_data.name = nullptr; \ ffuncs->user_data.name = nullptr; \
ffuncs->destroy.name = nullptr; \ ffuncs->destroy.name = nullptr; \
} \ } \
} }
@ -613,9 +673,8 @@ HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
bool bool
hb_font_t::has_func (unsigned int i) hb_font_t::has_func (unsigned int i)
{ {
if (parent && parent != hb_font_get_empty () && parent->has_func (i)) return (this->klass->get.array[i] != _hb_font_funcs_default.get.array[i]) ||
return true; (parent && parent != &_hb_Null_hb_font_t && parent->has_func (i));
return this->klass->get.array[i] != _hb_font_funcs_parent.get.array[i];
} }
/* Public getters */ /* Public getters */

View File

@ -132,15 +132,15 @@ 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_h_advance_func_t;
typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_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)( typedef void (*hb_font_get_glyph_advances_func_t) (hb_font_t* font, void* font_data,
hb_font_t* font, unsigned count,
void* font_data, hb_codepoint_t *first_glyph,
unsigned count, unsigned glyph_stride,
hb_codepoint_t* glyphs, hb_position_t *first_advance,
unsigned glyph_struct_size, unsigned advance_stride,
hb_position_t* advances, void *user_data);
unsigned advance_struct_size, typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_h_advances_func_t;
void* user_data); typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_v_advances_func_t;
typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data, typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
@ -258,11 +258,6 @@ hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_h_advance_func_t func, hb_font_get_glyph_h_advance_func_t func,
void *user_data, hb_destroy_func_t destroy); 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: * hb_font_funcs_set_glyph_v_advance_func:
* @ffuncs: font functions. * @ffuncs: font functions.
@ -279,6 +274,38 @@ hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_v_advance_func_t func, hb_font_get_glyph_v_advance_func_t func,
void *user_data, hb_destroy_func_t destroy); void *user_data, hb_destroy_func_t destroy);
/**
* hb_font_funcs_set_glyph_h_advances_func:
* @ffuncs: font functions.
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: REPLACEME
**/
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_advances_func:
* @ffuncs: font functions.
* @func: (closure user_data) (destroy destroy) (scope notified):
* @user_data:
* @destroy:
*
*
*
* Since: REPLACEME
**/
HB_EXTERN void
hb_font_funcs_set_glyph_v_advances_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_v_advances_func_t func,
void *user_data, hb_destroy_func_t destroy);
/** /**
* hb_font_funcs_set_glyph_h_origin_func: * hb_font_funcs_set_glyph_h_origin_func:
* @ffuncs: font functions. * @ffuncs: font functions.

View File

@ -691,9 +691,10 @@ hb_ot_position_default (hb_ot_shape_context_t *c)
} }
else else
{ {
c->font->get_glyph_v_advances (count, &info[0].codepoint, sizeof(info[0]),
&pos[0].y_advance, sizeof(pos[0]));
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
pos[i].y_advance = c->font->get_glyph_v_advance (info[i].codepoint);
c->font->subtract_glyph_v_origin (info[i].codepoint, c->font->subtract_glyph_v_origin (info[i].codepoint,
&pos[i].x_offset, &pos[i].x_offset,
&pos[i].y_offset); &pos[i].y_offset);