This commit is contained in:
Behdad Esfahbod 2011-05-17 23:27:22 -04:00
parent 2c3f51a11c
commit 190981851f
2 changed files with 74 additions and 76 deletions

View File

@ -60,19 +60,19 @@ static hb_bool_t
hb_font_get_glyph_h_advance_nil (hb_font_t *font HB_UNUSED, hb_font_get_glyph_h_advance_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_position_t *x_advance, hb_position_t *x,
hb_position_t *y_advance, hb_position_t *y,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
if (font->parent) { if (font->parent) {
hb_bool_t ret = hb_font_get_glyph_h_advance (font->parent, hb_bool_t ret = hb_font_get_glyph_h_advance (font->parent,
glyph, glyph,
x_advance, y_advance); x, y);
font->parent_scale_distance (x_advance, y_advance); font->parent_scale_distance (x, y);
return ret; return ret;
} }
*x_advance = *y_advance = 0; *x = *y = 0;
return FALSE; return FALSE;
} }
@ -80,19 +80,19 @@ static hb_bool_t
hb_font_get_glyph_v_advance_nil (hb_font_t *font HB_UNUSED, hb_font_get_glyph_v_advance_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_position_t *x_advance, hb_position_t *x,
hb_position_t *y_advance, hb_position_t *y,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
if (font->parent) { if (font->parent) {
hb_bool_t ret = hb_font_get_glyph_v_advance (font->parent, hb_bool_t ret = hb_font_get_glyph_v_advance (font->parent,
glyph, glyph,
x_advance, y_advance); x, y);
font->parent_scale_distance (x_advance, y_advance); font->parent_scale_distance (x, y);
return ret; return ret;
} }
*x_advance = *y_advance = 0; *x = *y = 0;
return FALSE; return FALSE;
} }
@ -100,19 +100,19 @@ 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,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x_origin, hb_position_t *x,
hb_position_t *y_origin, hb_position_t *y,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
if (font->parent) { if (font->parent) {
hb_bool_t ret = hb_font_get_glyph_h_origin (font->parent, hb_bool_t ret = hb_font_get_glyph_h_origin (font->parent,
glyph, glyph,
x_origin, y_origin); x, y);
font->parent_scale_distance (x_origin, y_origin); font->parent_scale_distance (x, y);
return ret; return ret;
} }
*x_origin = *y_origin = 0; *x = *y = 0;
return FALSE; return FALSE;
} }
@ -120,19 +120,19 @@ static hb_bool_t
hb_font_get_glyph_v_origin_nil (hb_font_t *font HB_UNUSED, hb_font_get_glyph_v_origin_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_position_t *x_origin, hb_position_t *x,
hb_position_t *y_origin, hb_position_t *y,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
if (font->parent) { if (font->parent) {
hb_bool_t ret = hb_font_get_glyph_v_origin (font->parent, hb_bool_t ret = hb_font_get_glyph_v_origin (font->parent,
glyph, glyph,
x_origin, y_origin); x, y);
font->parent_scale_distance (x_origin, y_origin); font->parent_scale_distance (x, y);
return ret; return ret;
} }
*x_origin = *y_origin = 0; *x = *y = 0;
return FALSE; return FALSE;
} }
@ -141,19 +141,19 @@ hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED,
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,
hb_position_t *x_kern, hb_position_t *x,
hb_position_t *y_kern, hb_position_t *y,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
if (font->parent) { if (font->parent) {
hb_bool_t ret = hb_font_get_glyph_h_kerning (font->parent, hb_bool_t ret = hb_font_get_glyph_h_kerning (font->parent,
left_glyph, right_glyph, left_glyph, right_glyph,
x_kern, y_kern); x, y);
font->parent_scale_distance (x_kern, y_kern); font->parent_scale_distance (x, y);
return ret; return ret;
} }
*x_kern = *y_kern = 0; *x = *y = 0;
return FALSE; return FALSE;
} }
@ -162,19 +162,19 @@ hb_font_get_glyph_v_kerning_nil (hb_font_t *font HB_UNUSED,
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,
hb_position_t *x_kern, hb_position_t *x,
hb_position_t *y_kern, hb_position_t *y,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
if (font->parent) { if (font->parent) {
hb_bool_t ret = hb_font_get_glyph_v_kerning (font->parent, hb_bool_t ret = hb_font_get_glyph_v_kerning (font->parent,
top_glyph, bottom_glyph, top_glyph, bottom_glyph,
x_kern, y_kern); x, y);
font->parent_scale_distance (x_kern, y_kern); font->parent_scale_distance (x, y);
return ret; return ret;
} }
*x_kern = *y_kern = 0; *x = *y = 0;
return FALSE; return FALSE;
} }
@ -347,68 +347,68 @@ hb_font_get_glyph (hb_font_t *font,
hb_bool_t hb_bool_t
hb_font_get_glyph_h_advance (hb_font_t *font, hb_font_get_glyph_h_advance (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x_advance, hb_position_t *y_advance) hb_position_t *x, hb_position_t *y)
{ {
*x_advance = *y_advance = 0; *x = *y = 0;
return font->klass->get.glyph_h_advance (font, font->user_data, return font->klass->get.glyph_h_advance (font, font->user_data,
glyph, x_advance, y_advance, glyph, x, y,
font->klass->user_data.glyph_h_advance); font->klass->user_data.glyph_h_advance);
} }
hb_bool_t hb_bool_t
hb_font_get_glyph_v_advance (hb_font_t *font, hb_font_get_glyph_v_advance (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x_advance, hb_position_t *y_advance) hb_position_t *x, hb_position_t *y)
{ {
*x_advance = *y_advance = 0; *x = *y = 0;
return font->klass->get.glyph_v_advance (font, font->user_data, return font->klass->get.glyph_v_advance (font, font->user_data,
glyph, x_advance, y_advance, glyph, x, y,
font->klass->user_data.glyph_v_advance); font->klass->user_data.glyph_v_advance);
} }
hb_bool_t hb_bool_t
hb_font_get_glyph_h_origin (hb_font_t *font, hb_font_get_glyph_h_origin (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x_origin, hb_position_t *y_origin) hb_position_t *x, hb_position_t *y)
{ {
*x_origin = *y_origin = 0; *x = *y = 0;
return font->klass->get.glyph_h_origin (font, font->user_data, return font->klass->get.glyph_h_origin (font, font->user_data,
glyph, x_origin, y_origin, glyph, x, y,
font->klass->user_data.glyph_h_origin); font->klass->user_data.glyph_h_origin);
} }
hb_bool_t hb_bool_t
hb_font_get_glyph_v_origin (hb_font_t *font, hb_font_get_glyph_v_origin (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x_origin, hb_position_t *y_origin) hb_position_t *x, hb_position_t *y)
{ {
*x_origin = *y_origin = 0; *x = *y = 0;
return font->klass->get.glyph_v_origin (font, font->user_data, return font->klass->get.glyph_v_origin (font, font->user_data,
glyph, x_origin, y_origin, glyph, x, y,
font->klass->user_data.glyph_v_origin); font->klass->user_data.glyph_v_origin);
} }
hb_bool_t hb_bool_t
hb_font_get_glyph_h_kerning (hb_font_t *font, hb_font_get_glyph_h_kerning (hb_font_t *font,
hb_codepoint_t left_glyph, hb_codepoint_t right_glyph, hb_codepoint_t left_glyph, hb_codepoint_t right_glyph,
hb_position_t *x_kern, hb_position_t *y_kern) hb_position_t *x, hb_position_t *y)
{ {
*x_kern = *y_kern = 0; *x = *y = 0;
return font->klass->get.glyph_h_kerning (font, font->user_data, return font->klass->get.glyph_h_kerning (font, font->user_data,
left_glyph, right_glyph, left_glyph, right_glyph,
x_kern, y_kern, x, y,
font->klass->user_data.glyph_h_kerning); font->klass->user_data.glyph_h_kerning);
} }
hb_bool_t hb_bool_t
hb_font_get_glyph_v_kerning (hb_font_t *font, hb_font_get_glyph_v_kerning (hb_font_t *font,
hb_codepoint_t left_glyph, hb_codepoint_t right_glyph, hb_codepoint_t left_glyph, hb_codepoint_t right_glyph,
hb_position_t *x_kern, hb_position_t *y_kern) hb_position_t *x, hb_position_t *y)
{ {
*x_kern = *y_kern = 0; *x = *y = 0;
return font->klass->get.glyph_v_kerning (font, font->user_data, return font->klass->get.glyph_v_kerning (font, font->user_data,
left_glyph, right_glyph, left_glyph, right_glyph,
x_kern, y_kern, x, y,
font->klass->user_data.glyph_v_kerning); font->klass->user_data.glyph_v_kerning);
} }
@ -443,15 +443,15 @@ void
hb_font_get_glyph_advance_for_direction (hb_font_t *font, hb_font_get_glyph_advance_for_direction (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_direction_t direction, hb_direction_t direction,
hb_position_t *x_advance, hb_position_t *y_advance) hb_position_t *x, hb_position_t *y)
{ {
if (HB_DIRECTION_IS_VERTICAL (direction)) { if (HB_DIRECTION_IS_VERTICAL (direction)) {
hb_bool_t ret = hb_font_get_glyph_v_advance (font, glyph, x_advance, y_advance); hb_bool_t ret = hb_font_get_glyph_v_advance (font, glyph, x, y);
if (!ret) { if (!ret) {
/* TODO return font_extents.ascent + font_extents.descent? */ /* TODO return font_extents.ascent + font_extents.descent? */
} }
} else { } else {
hb_font_get_glyph_h_advance (font, glyph, x_advance, y_advance); hb_font_get_glyph_h_advance (font, glyph, x, y);
} }
} }
@ -459,15 +459,15 @@ void
hb_font_get_glyph_origin_for_direction (hb_font_t *font, hb_font_get_glyph_origin_for_direction (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_direction_t direction, hb_direction_t direction,
hb_position_t *x_origin, hb_position_t *y_origin) hb_position_t *x, hb_position_t *y)
{ {
if (HB_DIRECTION_IS_VERTICAL (direction)) { if (HB_DIRECTION_IS_VERTICAL (direction)) {
hb_bool_t ret = hb_font_get_glyph_v_origin (font, glyph, x_origin, y_origin); hb_bool_t ret = hb_font_get_glyph_v_origin (font, glyph, x, y);
if (!ret) { if (!ret) {
/* TODO return h_origin/2. and font_extents.ascent */ /* TODO return h_origin/2. and font_extents.ascent */
} }
} else { } else {
hb_font_get_glyph_h_origin (font, glyph, x_origin, y_origin); hb_font_get_glyph_h_origin (font, glyph, x, y);
} }
} }
@ -475,17 +475,17 @@ void
hb_font_get_glyph_kerning_for_direction (hb_font_t *font, hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
hb_direction_t direction, hb_direction_t direction,
hb_position_t *x_kern, hb_position_t *y_kern) hb_position_t *x, hb_position_t *y)
{ {
switch (direction) { switch (direction) {
case HB_DIRECTION_LTR: case HB_DIRECTION_LTR:
case HB_DIRECTION_RTL: case HB_DIRECTION_RTL:
hb_font_get_glyph_h_kerning (font, first_glyph, second_glyph, x_kern, y_kern); hb_font_get_glyph_h_kerning (font, first_glyph, second_glyph, x, y);
break; break;
case HB_DIRECTION_TTB: case HB_DIRECTION_TTB:
case HB_DIRECTION_BTT: case HB_DIRECTION_BTT:
hb_font_get_glyph_v_kerning (font, first_glyph, second_glyph, x_kern, y_kern); hb_font_get_glyph_v_kerning (font, first_glyph, second_glyph, x, y);
break; break;
case HB_DIRECTION_INVALID: case HB_DIRECTION_INVALID:

View File

@ -82,8 +82,8 @@ static hb_bool_t
hb_ft_get_glyph_h_advance (hb_font_t *font HB_UNUSED, hb_ft_get_glyph_h_advance (hb_font_t *font HB_UNUSED,
void *font_data, void *font_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x_advance, hb_position_t *x,
hb_position_t *y_advance, hb_position_t *y,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
FT_Face ft_face = (FT_Face) font_data; FT_Face ft_face = (FT_Face) font_data;
@ -92,7 +92,7 @@ hb_ft_get_glyph_h_advance (hb_font_t *font HB_UNUSED,
if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags))) if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
return FALSE; return FALSE;
*x_advance = ft_face->glyph->metrics.horiAdvance; *x = ft_face->glyph->metrics.horiAdvance;
return TRUE; return TRUE;
} }
@ -100,8 +100,8 @@ static hb_bool_t
hb_ft_get_glyph_v_advance (hb_font_t *font HB_UNUSED, hb_ft_get_glyph_v_advance (hb_font_t *font HB_UNUSED,
void *font_data, void *font_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x_advance, hb_position_t *x,
hb_position_t *y_advance, hb_position_t *y,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
FT_Face ft_face = (FT_Face) font_data; FT_Face ft_face = (FT_Face) font_data;
@ -110,7 +110,7 @@ hb_ft_get_glyph_v_advance (hb_font_t *font HB_UNUSED,
if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags))) if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
return FALSE; return FALSE;
*y_advance = -ft_face->glyph->metrics.vertAdvance; *y = -ft_face->glyph->metrics.vertAdvance;
return TRUE; return TRUE;
} }
@ -118,8 +118,8 @@ static hb_bool_t
hb_ft_get_glyph_h_origin (hb_font_t *font HB_UNUSED, hb_ft_get_glyph_h_origin (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t glyph HB_UNUSED, hb_codepoint_t glyph HB_UNUSED,
hb_position_t *x_origin HB_UNUSED, hb_position_t *x HB_UNUSED,
hb_position_t *y_origin HB_UNUSED, hb_position_t *y HB_UNUSED,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
/* We always work in the horizontal coordinates. */ /* We always work in the horizontal coordinates. */
@ -130,8 +130,8 @@ static hb_bool_t
hb_ft_get_glyph_v_origin (hb_font_t *font HB_UNUSED, hb_ft_get_glyph_v_origin (hb_font_t *font HB_UNUSED,
void *font_data, void *font_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x_origin, hb_position_t *x,
hb_position_t *y_origin, hb_position_t *y,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
FT_Face ft_face = (FT_Face) font_data; FT_Face ft_face = (FT_Face) font_data;
@ -140,7 +140,7 @@ hb_ft_get_glyph_v_origin (hb_font_t *font HB_UNUSED,
if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags))) if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
return FALSE; return FALSE;
/* XXX */*y_origin = ft_face->glyph->metrics.vertAdvance; /* XXX */*y = ft_face->glyph->metrics.vertAdvance;
return TRUE; return TRUE;
} }
@ -149,8 +149,8 @@ hb_ft_get_glyph_h_kerning (hb_font_t *font HB_UNUSED,
void *font_data, void *font_data,
hb_codepoint_t left_glyph, hb_codepoint_t left_glyph,
hb_codepoint_t right_glyph, hb_codepoint_t right_glyph,
hb_position_t *x_kern, hb_position_t *x,
hb_position_t *y_kern, hb_position_t *y,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
FT_Face ft_face = (FT_Face) font_data; FT_Face ft_face = (FT_Face) font_data;
@ -159,8 +159,8 @@ hb_ft_get_glyph_h_kerning (hb_font_t *font HB_UNUSED,
if (FT_Get_Kerning (ft_face, left_glyph, right_glyph, FT_KERNING_DEFAULT, &kerning)) if (FT_Get_Kerning (ft_face, left_glyph, right_glyph, FT_KERNING_DEFAULT, &kerning))
return FALSE; return FALSE;
*x_kern = kerning.x; *x = kerning.x;
*y_kern = kerning.y; *y = kerning.y;
return TRUE; return TRUE;
} }
@ -169,8 +169,8 @@ hb_ft_get_glyph_v_kerning (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED, void *font_data HB_UNUSED,
hb_codepoint_t top_glyph HB_UNUSED, hb_codepoint_t top_glyph HB_UNUSED,
hb_codepoint_t bottom_glyph HB_UNUSED, hb_codepoint_t bottom_glyph HB_UNUSED,
hb_position_t *x_kern HB_UNUSED, hb_position_t *x HB_UNUSED,
hb_position_t *y_kern HB_UNUSED, hb_position_t *y HB_UNUSED,
void *user_data HB_UNUSED) void *user_data HB_UNUSED)
{ {
/* FreeType API doesn't support vertical kerning */ /* FreeType API doesn't support vertical kerning */
@ -187,8 +187,6 @@ hb_ft_get_glyph_extents (hb_font_t *font HB_UNUSED,
FT_Face ft_face = (FT_Face) font_data; FT_Face ft_face = (FT_Face) font_data;
int load_flags = FT_LOAD_DEFAULT; int load_flags = FT_LOAD_DEFAULT;
/* TODO: load_flags, embolden, etc, shape/transform */
if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags))) if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
return FALSE; return FALSE;