[Vertical] GPOS is always done with horizontal origin

This commit is contained in:
Behdad Esfahbod 2011-05-19 18:46:15 -04:00
parent 8b38faeede
commit 60fbb36096
8 changed files with 166 additions and 183 deletions

View File

@ -138,10 +138,10 @@ struct _hb_font_t {
return v; return v;
} }
inline hb_position_t parent_scale_x_position (hb_position_t v) { inline hb_position_t parent_scale_x_position (hb_position_t v) {
return parent_scale_x_distance (v); /* We don't have translation right now */ return parent_scale_x_distance (v);
} }
inline hb_position_t parent_scale_y_position (hb_position_t v) { inline hb_position_t parent_scale_y_position (hb_position_t v) {
return parent_scale_y_distance (v); /* We don't have translation right now */ return parent_scale_y_distance (v);
} }
inline void parent_scale_distance (hb_position_t *x, hb_position_t *y) { inline void parent_scale_distance (hb_position_t *x, hb_position_t *y) {

View File

@ -56,44 +56,40 @@ hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED,
return FALSE; return FALSE;
} }
static hb_bool_t static void
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, hb_position_t *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_font_get_glyph_h_advance (font->parent,
glyph, glyph,
x, y); advance);
font->parent_scale_distance (x, y); *advance = font->parent_scale_x_distance (*advance);
return ret; return;
} }
*x = *y = 0; *advance = 0;
return FALSE;
} }
static hb_bool_t static void
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, hb_position_t *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_font_get_glyph_v_advance (font->parent,
glyph, glyph,
x, y); advance);
font->parent_scale_distance (x, y); *advance = font->parent_scale_y_distance (*advance);
return ret; return;
} }
*x = *y = 0; *advance = 0;
return FALSE;
} }
static hb_bool_t static hb_bool_t
@ -108,7 +104,8 @@ hb_font_get_glyph_h_origin_nil (hb_font_t *font HB_UNUSED,
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, y); x, y);
font->parent_scale_distance (x, y); if (ret)
font->parent_scale_position (x, y);
return ret; return ret;
} }
@ -128,7 +125,8 @@ hb_font_get_glyph_v_origin_nil (hb_font_t *font HB_UNUSED,
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, y); x, y);
font->parent_scale_distance (x, y); if (ret)
font->parent_scale_position (x, y);
return ret; return ret;
} }
@ -136,46 +134,42 @@ hb_font_get_glyph_v_origin_nil (hb_font_t *font HB_UNUSED,
return FALSE; return FALSE;
} }
static hb_bool_t static void
hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED, 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, hb_position_t *kerning,
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_font_get_glyph_h_kerning (font->parent,
left_glyph, right_glyph, left_glyph, right_glyph,
x, y); kerning);
font->parent_scale_distance (x, y); *kerning = font->parent_scale_x_distance (*kerning);
return ret; return;
} }
*x = *y = 0; *kerning = 0;
return FALSE;
} }
static hb_bool_t static void
hb_font_get_glyph_v_kerning_nil (hb_font_t *font HB_UNUSED, 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, hb_position_t *kerning,
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_font_get_glyph_v_kerning (font->parent,
top_glyph, bottom_glyph, top_glyph, bottom_glyph,
x, y); kerning);
font->parent_scale_distance (x, y); *kerning = font->parent_scale_y_distance (*kerning);
return ret; return;
} }
*x = *y = 0; *kerning = 0;
return FALSE;
} }
static hb_bool_t static hb_bool_t
@ -189,13 +183,14 @@ hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED,
hb_bool_t ret = hb_font_get_glyph_extents (font->parent, hb_bool_t ret = hb_font_get_glyph_extents (font->parent,
glyph, glyph,
extents); extents);
font->parent_scale_position (&extents->x_bearing, &extents->y_bearing); if (ret) {
font->parent_scale_distance (&extents->width, &extents->height); font->parent_scale_position (&extents->x_bearing, &extents->y_bearing);
font->parent_scale_distance (&extents->width, &extents->height);
}
return ret; return ret;
} }
extents->x_bearing = extents->y_bearing = 0; memset (extents, 0, sizeof (*extents));
extents->width = extents->height = 0;
return FALSE; return FALSE;
} }
@ -212,7 +207,8 @@ hb_font_get_glyph_contour_point_nil (hb_font_t *font HB_UNUSED,
hb_bool_t ret = hb_font_get_glyph_contour_point (font->parent, hb_bool_t ret = hb_font_get_glyph_contour_point (font->parent,
glyph, point_index, glyph, point_index,
x, y); x, y);
font->parent_scale_position (x, y); if (ret)
font->parent_scale_position (x, y);
return ret; return ret;
} }
@ -344,26 +340,26 @@ hb_font_get_glyph (hb_font_t *font,
font->klass->user_data.glyph); font->klass->user_data.glyph);
} }
hb_bool_t void
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, hb_position_t *y) hb_position_t *advance)
{ {
*x = *y = 0; *advance = 0;
return font->klass->get.glyph_h_advance (font, font->user_data, font->klass->get.glyph_h_advance (font, font->user_data,
glyph, x, y, glyph, advance,
font->klass->user_data.glyph_h_advance); font->klass->user_data.glyph_h_advance);
} }
hb_bool_t void
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, hb_position_t *y) hb_position_t *advance)
{ {
*x = *y = 0; *advance = 0;
return font->klass->get.glyph_v_advance (font, font->user_data, font->klass->get.glyph_v_advance (font, font->user_data,
glyph, x, y, glyph, advance,
font->klass->user_data.glyph_v_advance); font->klass->user_data.glyph_v_advance);
} }
hb_bool_t hb_bool_t
@ -388,27 +384,27 @@ hb_font_get_glyph_v_origin (hb_font_t *font,
font->klass->user_data.glyph_v_origin); font->klass->user_data.glyph_v_origin);
} }
hb_bool_t void
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, hb_position_t *y) hb_position_t *kerning)
{ {
*x = *y = 0; *kerning = 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, y, kerning,
font->klass->user_data.glyph_h_kerning); font->klass->user_data.glyph_h_kerning);
} }
hb_bool_t void
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, hb_position_t *y) hb_position_t *kerning)
{ {
*x = *y = 0; *kerning = 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, y, kerning,
font->klass->user_data.glyph_v_kerning); font->klass->user_data.glyph_v_kerning);
} }
@ -445,13 +441,12 @@ hb_font_get_glyph_advance_for_direction (hb_font_t *font,
hb_direction_t direction, hb_direction_t direction,
hb_position_t *x, hb_position_t *y) hb_position_t *x, hb_position_t *y)
{ {
if (HB_DIRECTION_IS_VERTICAL (direction)) { if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
hb_bool_t ret = hb_font_get_glyph_v_advance (font, glyph, x, y); *y = 0;
if (!ret) { hb_font_get_glyph_h_advance (font, glyph, x);
/* TODO return font_extents.ascent + font_extents.descent? */
}
} else { } else {
hb_font_get_glyph_h_advance (font, glyph, x, y); *x = 0;
hb_font_get_glyph_v_advance (font, glyph, y);
} }
} }
@ -461,13 +456,13 @@ hb_font_get_glyph_origin_for_direction (hb_font_t *font,
hb_direction_t direction, hb_direction_t direction,
hb_position_t *x, hb_position_t *y) hb_position_t *x, hb_position_t *y)
{ {
if (HB_DIRECTION_IS_VERTICAL (direction)) { if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
hb_font_get_glyph_h_origin (font, glyph, x, y);
} else {
hb_bool_t ret = hb_font_get_glyph_v_origin (font, glyph, x, y); 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 {
hb_font_get_glyph_h_origin (font, glyph, x, y);
} }
} }
@ -505,40 +500,34 @@ hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
hb_direction_t direction, hb_direction_t direction,
hb_position_t *x, hb_position_t *y) hb_position_t *x, hb_position_t *y)
{ {
switch (direction) { if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
case HB_DIRECTION_LTR: *y = 0;
case HB_DIRECTION_RTL: hb_font_get_glyph_h_kerning (font, first_glyph, second_glyph, x);
hb_font_get_glyph_h_kerning (font, first_glyph, second_glyph, x, y); } else {
break; *x = 0;
hb_font_get_glyph_v_kerning (font, first_glyph, second_glyph, y);
case HB_DIRECTION_TTB:
case HB_DIRECTION_BTT:
hb_font_get_glyph_v_kerning (font, first_glyph, second_glyph, x, y);
break;
case HB_DIRECTION_INVALID:
default:
break;
} }
} }
void hb_bool_t
hb_font_get_glyph_extents_for_direction (hb_font_t *font, hb_font_get_glyph_extents_for_origin (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_direction_t direction, hb_direction_t direction,
hb_glyph_extents_t *extents) hb_glyph_extents_t *extents)
{ {
hb_bool_t ret = hb_font_get_glyph_extents (font, glyph, extents); hb_bool_t ret = hb_font_get_glyph_extents (font, glyph, extents);
if (ret) if (ret)
hb_font_subtract_glyph_origin_for_direction (font, glyph, direction, &extents->x_bearing, &extents->y_bearing); hb_font_subtract_glyph_origin_for_direction (font, glyph, direction, &extents->x_bearing, &extents->y_bearing);
return ret;
} }
hb_bool_t hb_bool_t
hb_font_get_glyph_contour_point_for_direction (hb_font_t *font, hb_font_get_glyph_contour_point_for_origin (hb_font_t *font,
hb_codepoint_t glyph, unsigned int point_index, hb_codepoint_t glyph, unsigned int point_index,
hb_direction_t direction, hb_direction_t direction,
hb_position_t *x, hb_position_t *y) hb_position_t *x, hb_position_t *y)
{ {
hb_bool_t ret = hb_font_get_glyph_contour_point (font, glyph, point_index, x, y); hb_bool_t ret = hb_font_get_glyph_contour_point (font, glyph, point_index, x, y);

View File

@ -142,10 +142,10 @@ typedef hb_bool_t (*hb_font_get_glyph_func_t) (hb_font_t *font, void *font_data,
void *user_data); void *user_data);
typedef hb_bool_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data, typedef void (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y, hb_position_t *advance,
void *user_data); 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_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;
@ -156,10 +156,10 @@ typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *fon
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_h_origin_func_t;
typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t; typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t;
typedef hb_bool_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data, 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_codepoint_t first_glyph, hb_codepoint_t second_glyph,
hb_position_t *x, hb_position_t *y, hb_position_t *kerning,
void *user_data); 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_h_kerning_func_t;
typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t; typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t;
@ -225,14 +225,14 @@ hb_font_get_glyph (hb_font_t *font,
hb_codepoint_t unicode, hb_codepoint_t variation_selector, hb_codepoint_t unicode, hb_codepoint_t variation_selector,
hb_codepoint_t *glyph); hb_codepoint_t *glyph);
hb_bool_t void
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, hb_position_t *y); hb_position_t *advance);
hb_bool_t void
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, hb_position_t *y); hb_position_t *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,
@ -243,14 +243,14 @@ hb_font_get_glyph_v_origin (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y); hb_position_t *x, hb_position_t *y);
hb_bool_t void
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, hb_position_t *y); hb_position_t *kerning);
hb_bool_t void
hb_font_get_glyph_v_kerning (hb_font_t *font, hb_font_get_glyph_v_kerning (hb_font_t *font,
hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph, hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph,
hb_position_t *x, hb_position_t *y); hb_position_t *kerning);
hb_bool_t hb_bool_t
hb_font_get_glyph_extents (hb_font_t *font, hb_font_get_glyph_extents (hb_font_t *font,
@ -292,17 +292,17 @@ hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
hb_direction_t direction, hb_direction_t direction,
hb_position_t *x, hb_position_t *y); hb_position_t *x, hb_position_t *y);
void hb_bool_t
hb_font_get_glyph_extents_for_direction (hb_font_t *font, hb_font_get_glyph_extents_for_origin (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_direction_t direction, hb_direction_t direction,
hb_glyph_extents_t *extents); hb_glyph_extents_t *extents);
hb_bool_t hb_bool_t
hb_font_get_glyph_contour_point_for_direction (hb_font_t *font, hb_font_get_glyph_contour_point_for_origin (hb_font_t *font,
hb_codepoint_t glyph, unsigned int point_index, hb_codepoint_t glyph, unsigned int point_index,
hb_direction_t direction, hb_direction_t direction,
hb_position_t *x, hb_position_t *y); hb_position_t *x, hb_position_t *y);
/* /*
@ -357,9 +357,6 @@ hb_font_set_funcs (hb_font_t *font,
hb_destroy_func_t destroy); hb_destroy_func_t destroy);
/*
* We should add support for full matrices.
*/
void void
hb_font_set_scale (hb_font_t *font, hb_font_set_scale (hb_font_t *font,
int x_scale, int x_scale,

View File

@ -78,42 +78,38 @@ hb_ft_get_glyph (hb_font_t *font HB_UNUSED,
return *glyph != 0; return *glyph != 0;
} }
static hb_bool_t static void
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, hb_position_t *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;
int load_flags = FT_LOAD_DEFAULT; int load_flags = FT_LOAD_DEFAULT;
if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags))) if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
return FALSE; return;
*x = ft_face->glyph->metrics.horiAdvance; *advance = ft_face->glyph->metrics.horiAdvance;
return TRUE;
} }
static hb_bool_t static void
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, hb_position_t *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;
int load_flags = FT_LOAD_DEFAULT; int load_flags = FT_LOAD_DEFAULT;
if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags))) if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
return FALSE; return;
/* Note: FreeType's vertical metrics grows downward while other FreeType coordinates /* Note: FreeType's vertical metrics grows downward while other FreeType coordinates
* have a Y growing upward. Hence the extra negation. */ * have a Y growing upward. Hence the extra negation. */
*y = -ft_face->glyph->metrics.vertAdvance; *advance = -ft_face->glyph->metrics.vertAdvance;
return TRUE;
} }
static hb_bool_t static hb_bool_t
@ -147,45 +143,36 @@ hb_ft_get_glyph_v_origin (hb_font_t *font HB_UNUSED,
*x = ft_face->glyph->metrics.horiBearingX - ft_face->glyph->metrics.vertBearingX; *x = ft_face->glyph->metrics.horiBearingX - ft_face->glyph->metrics.vertBearingX;
*y = ft_face->glyph->metrics.horiBearingY - (-ft_face->glyph->metrics.vertBearingY); *y = ft_face->glyph->metrics.horiBearingY - (-ft_face->glyph->metrics.vertBearingY);
/* TODO ??
if (glyph->format == FT_GLYPH_FORMAT_OUTLINE)
FT_Vector_Transform (&vector, &scaled_font->unscaled->Current_Shape);
*/
return TRUE; return TRUE;
} }
static hb_bool_t static void
hb_ft_get_glyph_h_kerning (hb_font_t *font HB_UNUSED, 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, hb_position_t *kerning,
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;
FT_Vector kerning; FT_Vector kerningv;
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, &kerningv))
return FALSE; return;
*x = kerning.x; *kerning = kerningv.x;
*y = kerning.y;
return TRUE;
} }
static hb_bool_t static void
hb_ft_get_glyph_v_kerning (hb_font_t *font HB_UNUSED, 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 HB_UNUSED, hb_position_t *kerning 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 */
return FALSE; return;
} }
static hb_bool_t static hb_bool_t

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2007,2008,2009 Red Hat, Inc. * Copyright © 2007,2008,2009 Red Hat, Inc.
* Copyright © 2010 Google, Inc. * Copyright © 2010,2011 Google, Inc.
* *
* This is part of HarfBuzz, a text shaping library. * This is part of HarfBuzz, a text shaping library.
* *
@ -96,7 +96,7 @@ struct CaretValueFormat1
friend struct CaretValue; friend struct CaretValue;
private: private:
inline int get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id HB_UNUSED) const inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id HB_UNUSED) const
{ {
return HB_DIRECTION_IS_HORIZONTAL (direction) ? font->em_scale_x (coordinate) : font->em_scale_y (coordinate); return HB_DIRECTION_IS_HORIZONTAL (direction) ? font->em_scale_x (coordinate) : font->em_scale_y (coordinate);
} }
@ -118,10 +118,10 @@ struct CaretValueFormat2
friend struct CaretValue; friend struct CaretValue;
private: private:
inline int get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const
{ {
hb_position_t x, y; hb_position_t x, y;
if (hb_font_get_glyph_contour_point_for_direction (font, glyph_id, caretValuePoint, direction, &x, &y)) if (hb_font_get_glyph_contour_point_for_origin (font, glyph_id, caretValuePoint, direction, &x, &y))
return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y; return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y;
else else
return 0; return 0;
@ -143,7 +143,7 @@ struct CaretValueFormat3
{ {
friend struct CaretValue; friend struct CaretValue;
inline int get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const
{ {
return HB_DIRECTION_IS_HORIZONTAL (direction) ? return HB_DIRECTION_IS_HORIZONTAL (direction) ?
font->em_scale_x (coordinate) + (this+deviceTable).get_x_delta (font) : font->em_scale_x (coordinate) + (this+deviceTable).get_x_delta (font) :
@ -169,7 +169,7 @@ struct CaretValueFormat3
struct CaretValue struct CaretValue
{ {
inline int get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const
{ {
switch (u.format) { switch (u.format) {
case 1: return u.format1.get_caret_value (font, direction, glyph_id); case 1: return u.format1.get_caret_value (font, direction, glyph_id);
@ -208,7 +208,7 @@ struct LigGlyph
hb_codepoint_t glyph_id, hb_codepoint_t glyph_id,
unsigned int start_offset, unsigned int start_offset,
unsigned int *caret_count /* IN/OUT */, unsigned int *caret_count /* IN/OUT */,
int *caret_array /* OUT */) const hb_position_t *caret_array /* OUT */) const
{ {
if (caret_count) { if (caret_count) {
const OffsetTo<CaretValue> *array = carets.sub_array (start_offset, caret_count); const OffsetTo<CaretValue> *array = carets.sub_array (start_offset, caret_count);
@ -241,7 +241,7 @@ struct LigCaretList
hb_codepoint_t glyph_id, hb_codepoint_t glyph_id,
unsigned int start_offset, unsigned int start_offset,
unsigned int *caret_count /* IN/OUT */, unsigned int *caret_count /* IN/OUT */,
int *caret_array /* OUT */) const hb_position_t *caret_array /* OUT */) const
{ {
unsigned int index = (this+coverage) (glyph_id); unsigned int index = (this+coverage) (glyph_id);
if (index == NOT_COVERED) if (index == NOT_COVERED)
@ -357,7 +357,7 @@ struct GDEF
hb_codepoint_t glyph_id, hb_codepoint_t glyph_id,
unsigned int start_offset, unsigned int start_offset,
unsigned int *caret_count /* IN/OUT */, unsigned int *caret_count /* IN/OUT */,
int *caret_array /* OUT */) const hb_position_t *caret_array /* OUT */) const
{ return (this+ligCaretList).get_lig_carets (font, direction, glyph_id, start_offset, caret_count, caret_array); } { return (this+ligCaretList).get_lig_carets (font, direction, glyph_id, start_offset, caret_count, caret_array); }
inline bool has_mark_sets (void) const { return version >= 0x00010002 && markGlyphSetsDef[0] != 0; } inline bool has_mark_sets (void) const { return version >= 0x00010002 && markGlyphSetsDef[0] != 0; }

View File

@ -210,7 +210,6 @@ struct AnchorFormat1
private: private:
inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id HB_UNUSED, inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id HB_UNUSED,
hb_direction_t direction HB_UNUSED,
hb_position_t *x, hb_position_t *y) const hb_position_t *x, hb_position_t *y) const
{ {
*x = font->em_scale_x (xCoordinate); *x = font->em_scale_x (xCoordinate);
@ -236,7 +235,6 @@ struct AnchorFormat2
private: private:
inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id, inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y) const hb_position_t *x, hb_position_t *y) const
{ {
unsigned int x_ppem = font->x_ppem; unsigned int x_ppem = font->x_ppem;
@ -245,7 +243,7 @@ struct AnchorFormat2
hb_bool_t ret = false; hb_bool_t ret = false;
if (x_ppem || y_ppem) if (x_ppem || y_ppem)
ret = hb_font_get_glyph_contour_point_for_direction (font, glyph_id, anchorPoint, direction, &cx, &cy); ret = hb_font_get_glyph_contour_point_for_origin (font, glyph_id, anchorPoint, HB_DIRECTION_LTR, &cx, &cy);
*x = x_ppem && ret ? cx : font->em_scale_x (xCoordinate); *x = x_ppem && ret ? cx : font->em_scale_x (xCoordinate);
*y = y_ppem && ret ? cy : font->em_scale_y (yCoordinate); *y = y_ppem && ret ? cy : font->em_scale_y (yCoordinate);
} }
@ -270,13 +268,11 @@ struct AnchorFormat3
private: private:
inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id HB_UNUSED, inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id HB_UNUSED,
hb_direction_t direction HB_UNUSED,
hb_position_t *x, hb_position_t *y) const hb_position_t *x, hb_position_t *y) const
{ {
*x = font->em_scale_x (xCoordinate); *x = font->em_scale_x (xCoordinate);
*y = font->em_scale_y (yCoordinate); *y = font->em_scale_y (yCoordinate);
/* pixel -> fractional pixel */
if (font->x_ppem) if (font->x_ppem)
*x += (this+xDeviceTable).get_x_delta (font); *x += (this+xDeviceTable).get_x_delta (font);
if (font->y_ppem) if (font->y_ppem)
@ -309,15 +305,14 @@ struct AnchorFormat3
struct Anchor struct Anchor
{ {
inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id, inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id,
hb_direction_t direction,
hb_position_t *x, hb_position_t *y) const hb_position_t *x, hb_position_t *y) const
{ {
*x = *y = 0; *x = *y = 0;
switch (u.format) { switch (u.format) {
case 1: u.format1.get_anchor (font, glyph_id, direction, x, y); return; case 1: u.format1.get_anchor (font, glyph_id, x, y); return;
case 2: u.format2.get_anchor (font, glyph_id, direction, x, y); return; case 2: u.format2.get_anchor (font, glyph_id, x, y); return;
case 3: u.format3.get_anchor (font, glyph_id, direction, x, y); return; case 3: u.format3.get_anchor (font, glyph_id, x, y); return;
default: return; default: return;
} }
} }
@ -407,8 +402,8 @@ struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage orde
hb_position_t mark_x, mark_y, base_x, base_y; hb_position_t mark_x, mark_y, base_x, base_y;
mark_anchor.get_anchor (c->font, c->buffer->info[c->buffer->i].codepoint, c->direction, &mark_x, &mark_y); mark_anchor.get_anchor (c->font, c->buffer->info[c->buffer->i].codepoint, &mark_x, &mark_y);
glyph_anchor.get_anchor (c->font, c->buffer->info[glyph_pos].codepoint, c->direction, &base_x, &base_y); glyph_anchor.get_anchor (c->font, c->buffer->info[glyph_pos].codepoint, &base_x, &base_y);
hb_glyph_position_t &o = c->buffer->pos[c->buffer->i]; hb_glyph_position_t &o = c->buffer->pos[c->buffer->i];
o.x_offset = base_x - mark_x; o.x_offset = base_x - mark_x;
@ -863,8 +858,8 @@ struct CursivePosFormat1
unsigned int i = c->buffer->i; unsigned int i = c->buffer->i;
hb_position_t entry_x, entry_y, exit_x, exit_y; hb_position_t entry_x, entry_y, exit_x, exit_y;
(this+this_record.exitAnchor).get_anchor (c->font, c->buffer->info[i].codepoint, c->direction, &exit_x, &exit_y); (this+this_record.exitAnchor).get_anchor (c->font, c->buffer->info[i].codepoint, &exit_x, &exit_y);
(this+next_record.entryAnchor).get_anchor (c->font, c->buffer->info[j].codepoint, c->direction, &entry_x, &entry_y); (this+next_record.entryAnchor).get_anchor (c->font, c->buffer->info[j].codepoint, &entry_x, &entry_y);
/* Align the exit anchor of the left/top glyph with the entry anchor of the right/bottom glyph /* Align the exit anchor of the left/top glyph with the entry anchor of the right/bottom glyph
* by adjusting advance of the left/top glyph. */ * by adjusting advance of the left/top glyph. */

View File

@ -63,7 +63,7 @@ hb_ot_layout_get_ligature_carets (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
unsigned int start_offset, unsigned int start_offset,
unsigned int *caret_count /* IN/OUT */, unsigned int *caret_count /* IN/OUT */,
int *caret_array /* OUT */); hb_position_t *caret_array /* OUT */);
/* /*

View File

@ -121,8 +121,23 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
if (!hb_ot_layout_has_positioning (c->face)) if (!hb_ot_layout_has_positioning (c->face))
return; return;
unsigned int count = c->buffer->len;
for (unsigned int i = 0; i < count; i++) {
hb_font_add_glyph_origin_for_direction (c->font, c->buffer->info[i].codepoint,
HB_DIRECTION_LTR,
&c->buffer->pos[i].x_offset,
&c->buffer->pos[i].y_offset);
}
c->plan->map.position (c->font, c->face, c->buffer); c->plan->map.position (c->font, c->face, c->buffer);
for (unsigned int i = 0; i < count; i++) {
hb_font_subtract_glyph_origin_for_direction (c->font, c->buffer->info[i].codepoint,
HB_DIRECTION_LTR,
&c->buffer->pos[i].x_offset,
&c->buffer->pos[i].y_offset);
}
hb_ot_layout_position_finish (c->buffer); hb_ot_layout_position_finish (c->buffer);
c->applied_position_complex = TRUE; c->applied_position_complex = TRUE;