return FALSE;
}
-static void
+static hb_position_t
hb_font_get_glyph_h_advance_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
hb_codepoint_t glyph,
- hb_position_t *advance,
void *user_data HB_UNUSED)
{
- if (font->parent) {
- hb_font_get_glyph_h_advance (font->parent,
- glyph,
- advance);
- *advance = font->parent_scale_x_distance (*advance);
- return;
- }
+ if (font->parent)
+ return font->parent_scale_x_distance (hb_font_get_glyph_h_advance (font->parent, glyph));
- *advance = font->x_scale;
+ return font->x_scale;
}
-static void
+static hb_position_t
hb_font_get_glyph_v_advance_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
hb_codepoint_t glyph,
- hb_position_t *advance,
void *user_data HB_UNUSED)
{
- if (font->parent) {
- hb_font_get_glyph_v_advance (font->parent,
- glyph,
- advance);
- *advance = font->parent_scale_y_distance (*advance);
- return;
- }
+ if (font->parent)
+ return font->parent_scale_y_distance (hb_font_get_glyph_v_advance (font->parent, glyph));
- *advance = font->y_scale;
+ return font->y_scale;
}
static hb_bool_t
return FALSE;
}
-static void
+static hb_position_t
hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
hb_codepoint_t left_glyph,
hb_codepoint_t right_glyph,
- hb_position_t *kerning,
void *user_data HB_UNUSED)
{
- if (font->parent) {
- hb_font_get_glyph_h_kerning (font->parent,
- left_glyph, right_glyph,
- kerning);
- *kerning = font->parent_scale_x_distance (*kerning);
- return;
- }
+ if (font->parent)
+ return font->parent_scale_x_distance (hb_font_get_glyph_h_kerning (font->parent, left_glyph, right_glyph));
- *kerning = 0;
+ return 0;
}
-static void
+static hb_position_t
hb_font_get_glyph_v_kerning_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
hb_codepoint_t top_glyph,
hb_codepoint_t bottom_glyph,
- hb_position_t *kerning,
void *user_data HB_UNUSED)
{
- if (font->parent) {
- hb_font_get_glyph_v_kerning (font->parent,
- top_glyph, bottom_glyph,
- kerning);
- *kerning = font->parent_scale_y_distance (*kerning);
- return;
- }
+ if (font->parent)
+ return font->parent_scale_y_distance (hb_font_get_glyph_v_kerning (font->parent, top_glyph, bottom_glyph));
- *kerning = 0;
+ return 0;
}
static hb_bool_t
font->klass->user_data.glyph);
}
-void
+hb_position_t
hb_font_get_glyph_h_advance (hb_font_t *font,
- hb_codepoint_t glyph,
- hb_position_t *advance)
+ hb_codepoint_t glyph)
{
- *advance = 0;
- font->klass->get.glyph_h_advance (font, font->user_data,
- glyph, advance,
- font->klass->user_data.glyph_h_advance);
+ return font->klass->get.glyph_h_advance (font, font->user_data,
+ glyph,
+ font->klass->user_data.glyph_h_advance);
}
-void
+hb_position_t
hb_font_get_glyph_v_advance (hb_font_t *font,
- hb_codepoint_t glyph,
- hb_position_t *advance)
+ hb_codepoint_t glyph)
{
- *advance = 0;
- font->klass->get.glyph_v_advance (font, font->user_data,
- glyph, advance,
- font->klass->user_data.glyph_v_advance);
+ return font->klass->get.glyph_v_advance (font, font->user_data,
+ glyph,
+ font->klass->user_data.glyph_v_advance);
}
hb_bool_t
font->klass->user_data.glyph_v_origin);
}
-void
+hb_position_t
hb_font_get_glyph_h_kerning (hb_font_t *font,
- hb_codepoint_t left_glyph, hb_codepoint_t right_glyph,
- hb_position_t *kerning)
+ hb_codepoint_t left_glyph, hb_codepoint_t right_glyph)
{
- *kerning = 0;
return font->klass->get.glyph_h_kerning (font, font->user_data,
left_glyph, right_glyph,
- kerning,
font->klass->user_data.glyph_h_kerning);
}
-void
+hb_position_t
hb_font_get_glyph_v_kerning (hb_font_t *font,
- hb_codepoint_t left_glyph, hb_codepoint_t right_glyph,
- hb_position_t *kerning)
+ hb_codepoint_t left_glyph, hb_codepoint_t right_glyph)
{
- *kerning = 0;
return font->klass->get.glyph_v_kerning (font, font->user_data,
left_glyph, right_glyph,
- kerning,
font->klass->user_data.glyph_v_kerning);
}
hb_position_t *x, hb_position_t *y)
{
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
+ *x = hb_font_get_glyph_h_advance (font, glyph);
*y = 0;
- hb_font_get_glyph_h_advance (font, glyph, x);
} else {
*x = 0;
- hb_font_get_glyph_v_advance (font, glyph, y);
+ *y = hb_font_get_glyph_v_advance (font, glyph);
}
}
hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y)
{
- *x = *y = 0;
-
- hb_font_get_glyph_h_advance (font, glyph, x);
- *x /= 2;
+ *x = hb_font_get_glyph_h_advance (font, glyph) / 2;
/* TODO use font_metics.ascent */
*y = font->y_scale;
hb_position_t *x, hb_position_t *y)
{
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
+ *x = hb_font_get_glyph_h_kerning (font, first_glyph, second_glyph);
*y = 0;
- hb_font_get_glyph_h_kerning (font, first_glyph, second_glyph, x);
} else {
*x = 0;
- hb_font_get_glyph_v_kerning (font, first_glyph, second_glyph, y);
+ *y = hb_font_get_glyph_v_kerning (font, first_glyph, second_glyph);
}
}
void *user_data);
-typedef void (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data,
- hb_codepoint_t glyph,
- hb_position_t *advance,
- void *user_data);
+typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data,
+ hb_codepoint_t glyph,
+ void *user_data);
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_origin_func_t hb_font_get_glyph_h_origin_func_t;
typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t;
-typedef void (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data,
- hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
- hb_position_t *kerning,
- void *user_data);
+typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data,
+ hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
+ void *user_data);
typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t;
typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t;
void
hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs,
- hb_font_get_glyph_h_advance_func_t glyph_advance_func,
+ hb_font_get_glyph_h_advance_func_t func,
void *user_data, hb_destroy_func_t destroy);
void
hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs,
- hb_font_get_glyph_v_advance_func_t glyph_advance_func,
+ hb_font_get_glyph_v_advance_func_t func,
void *user_data, hb_destroy_func_t destroy);
void
hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs,
- hb_font_get_glyph_h_origin_func_t glyph_advance_func,
+ hb_font_get_glyph_h_origin_func_t func,
void *user_data, hb_destroy_func_t destroy);
void
hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs,
- hb_font_get_glyph_v_origin_func_t glyph_advance_func,
+ hb_font_get_glyph_v_origin_func_t func,
void *user_data, hb_destroy_func_t destroy);
void
hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs,
- hb_font_get_glyph_h_kerning_func_t kerning_func,
+ hb_font_get_glyph_h_kerning_func_t func,
void *user_data, hb_destroy_func_t destroy);
void
hb_font_funcs_set_glyph_v_kerning_func (hb_font_funcs_t *ffuncs,
- hb_font_get_glyph_v_kerning_func_t kerning_func,
+ hb_font_get_glyph_v_kerning_func_t func,
void *user_data, hb_destroy_func_t destroy);
void
hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
- hb_font_get_glyph_extents_func_t glyph_extents_func,
+ hb_font_get_glyph_extents_func_t func,
void *user_data, hb_destroy_func_t destroy);
void
hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs,
- hb_font_get_glyph_contour_point_func_t glyph_contour_point_func,
+ hb_font_get_glyph_contour_point_func_t func,
void *user_data, hb_destroy_func_t destroy);
hb_codepoint_t unicode, hb_codepoint_t variation_selector,
hb_codepoint_t *glyph);
-void
+hb_position_t
hb_font_get_glyph_h_advance (hb_font_t *font,
- hb_codepoint_t glyph,
- hb_position_t *advance);
-void
+ hb_codepoint_t glyph);
+hb_position_t
hb_font_get_glyph_v_advance (hb_font_t *font,
- hb_codepoint_t glyph,
- hb_position_t *advance);
+ hb_codepoint_t glyph);
hb_bool_t
hb_font_get_glyph_h_origin (hb_font_t *font,
hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y);
-void
+hb_position_t
hb_font_get_glyph_h_kerning (hb_font_t *font,
- hb_codepoint_t left_glyph, hb_codepoint_t right_glyph,
- hb_position_t *kerning);
-void
+ hb_codepoint_t left_glyph, hb_codepoint_t right_glyph);
+hb_position_t
hb_font_get_glyph_v_kerning (hb_font_t *font,
- hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph,
- hb_position_t *kerning);
+ hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph);
hb_bool_t
hb_font_get_glyph_extents (hb_font_t *font,
return *glyph != 0;
}
-static void
+static hb_position_t
hb_ft_get_glyph_h_advance (hb_font_t *font HB_UNUSED,
void *font_data,
hb_codepoint_t glyph,
- hb_position_t *advance,
void *user_data HB_UNUSED)
{
FT_Face ft_face = (FT_Face) font_data;
int load_flags = FT_LOAD_DEFAULT;
if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
- return;
+ return 0;
- *advance = ft_face->glyph->metrics.horiAdvance;
+ return ft_face->glyph->metrics.horiAdvance;
}
-static void
+static hb_position_t
hb_ft_get_glyph_v_advance (hb_font_t *font HB_UNUSED,
void *font_data,
hb_codepoint_t glyph,
- hb_position_t *advance,
void *user_data HB_UNUSED)
{
FT_Face ft_face = (FT_Face) font_data;
int load_flags = FT_LOAD_DEFAULT;
if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
- return;
+ return 0;
/* Note: FreeType's vertical metrics grows downward while other FreeType coordinates
* have a Y growing upward. Hence the extra negation. */
- *advance = -ft_face->glyph->metrics.vertAdvance;
+ return -ft_face->glyph->metrics.vertAdvance;
}
static hb_bool_t
return TRUE;
}
-static void
+static hb_position_t
hb_ft_get_glyph_h_kerning (hb_font_t *font HB_UNUSED,
void *font_data,
hb_codepoint_t left_glyph,
hb_codepoint_t right_glyph,
- hb_position_t *kerning,
void *user_data HB_UNUSED)
{
FT_Face ft_face = (FT_Face) font_data;
FT_Vector kerningv;
if (FT_Get_Kerning (ft_face, left_glyph, right_glyph, FT_KERNING_DEFAULT, &kerningv))
- return;
+ return 0;
- *kerning = kerningv.x;
+ return kerningv.x;
}
-static void
+static hb_position_t
hb_ft_get_glyph_v_kerning (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
hb_codepoint_t top_glyph HB_UNUSED,
hb_codepoint_t bottom_glyph HB_UNUSED,
- hb_position_t *kerning HB_UNUSED,
void *user_data HB_UNUSED)
{
/* FreeType API doesn't support vertical kerning */
- return;
+ return 0;
}
static hb_bool_t
g_assert_cmpint (x, ==, 0);
g_assert_cmpint (y, ==, 0);
- x = 13;
- hb_font_get_glyph_h_advance (font, 17, &x);
+ x = hb_font_get_glyph_h_advance (font, 17);
g_assert_cmpint (x, ==, 0);
extents.x_bearing = extents.y_bearing = 13;
g_assert_cmpint (glyph, ==, 0);
x = 13;
- hb_font_get_glyph_h_kerning (font, 17, 19, &x);
+ x = hb_font_get_glyph_h_kerning (font, 17, 19);
g_assert_cmpint (x, ==, 0);
}
glyph, point_index, x, y);
}
-static void
+static hb_position_t
glyph_h_advance_func1 (hb_font_t *font, void *font_data,
hb_codepoint_t glyph,
- hb_position_t *advance,
void *user_data)
{
- if (glyph == 1) {
- *advance = 8;
- }
+ if (glyph == 1)
+ return 8;
+
+ return 0;
}
static void
g_assert (!hb_font_get_glyph_contour_point_for_origin (font1, 3, 7, HB_DIRECTION_RTL, &x, &y));
g_assert_cmpint (x, ==, 0);
g_assert_cmpint (y, ==, 0);
- hb_font_get_glyph_h_advance (font1, 1, &x);
+ x = hb_font_get_glyph_h_advance (font1, 1);
g_assert_cmpint (x, ==, 8);
- hb_font_get_glyph_h_advance (font1, 2, &x);
+ x = hb_font_get_glyph_h_advance (font1, 2);
g_assert_cmpint (x, ==, 0);
g_assert (!hb_font_get_glyph_contour_point_for_origin (font2, 3, 7, HB_DIRECTION_LTR, &x, &y));
g_assert_cmpint (x, ==, 0);
g_assert_cmpint (y, ==, 0);
- hb_font_get_glyph_h_advance (font2, 1, &x);
+ x = hb_font_get_glyph_h_advance (font2, 1);
g_assert_cmpint (x, ==, 8);
- hb_font_get_glyph_h_advance (font2, 2, &x);
+ x = hb_font_get_glyph_h_advance (font2, 2);
g_assert_cmpint (x, ==, 0);
g_assert (!hb_font_get_glyph_contour_point_for_origin (font3, 3, 7, HB_DIRECTION_LTR, &x, &y));
g_assert_cmpint (x, ==, 0*2);
g_assert_cmpint (y, ==, 0*3);
- hb_font_get_glyph_h_advance (font3, 1, &x);
+ x = hb_font_get_glyph_h_advance (font3, 1);
g_assert_cmpint (x, ==, 8*2);
- hb_font_get_glyph_h_advance (font3, 2, &x);
+ x = hb_font_get_glyph_h_advance (font3, 2);
g_assert_cmpint (x, ==, 0*2);
static const char test_data[] = "test\0data";
-static void
+static hb_position_t
glyph_h_advance_func (hb_font_t *font, void *font_data,
hb_codepoint_t glyph,
- hb_position_t *advance,
void *user_data)
{
switch (glyph) {
- case 1: *advance = 10; return;
- case 2: *advance = 6; return;
- case 3: *advance = 5; return;
+ case 1: return 10;
+ case 2: return 6;
+ case 3: return 5;
}
+ return 0;
}
static hb_bool_t
case 'e': *glyph = 2; return TRUE;
case 's': *glyph = 3; return TRUE;
}
-
return FALSE;
}
-static void
+static hb_position_t
glyph_h_kerning_func (hb_font_t *font, void *font_data,
hb_codepoint_t left, hb_codepoint_t right,
- hb_position_t *kerning,
void *user_data)
{
- if (left == 1 && right == 2) {
- *kerning = -2;
- }
+ if (left == 1 && right == 2)
+ return -2;
+
+ return 0;
}
static const char TesT[] = "TesT";