[Vertical] GPOS is always done with horizontal origin
diff --git a/src/hb-font.cc b/src/hb-font.cc
index e223a68..e358ae7 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -56,44 +56,40 @@
return FALSE;
}
-static hb_bool_t
+static void
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 *x,
- hb_position_t *y,
+ hb_position_t *advance,
void *user_data HB_UNUSED)
{
if (font->parent) {
- hb_bool_t ret = hb_font_get_glyph_h_advance (font->parent,
- glyph,
- x, y);
- font->parent_scale_distance (x, y);
- return ret;
+ hb_font_get_glyph_h_advance (font->parent,
+ glyph,
+ advance);
+ *advance = font->parent_scale_x_distance (*advance);
+ return;
}
- *x = *y = 0;
- return FALSE;
+ *advance = 0;
}
-static hb_bool_t
+static void
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 *x,
- hb_position_t *y,
+ hb_position_t *advance,
void *user_data HB_UNUSED)
{
if (font->parent) {
- hb_bool_t ret = hb_font_get_glyph_v_advance (font->parent,
- glyph,
- x, y);
- font->parent_scale_distance (x, y);
- return ret;
+ hb_font_get_glyph_v_advance (font->parent,
+ glyph,
+ advance);
+ *advance = font->parent_scale_y_distance (*advance);
+ return;
}
- *x = *y = 0;
- return FALSE;
+ *advance = 0;
}
static hb_bool_t
@@ -108,7 +104,8 @@
hb_bool_t ret = hb_font_get_glyph_h_origin (font->parent,
glyph,
x, y);
- font->parent_scale_distance (x, y);
+ if (ret)
+ font->parent_scale_position (x, y);
return ret;
}
@@ -128,7 +125,8 @@
hb_bool_t ret = hb_font_get_glyph_v_origin (font->parent,
glyph,
x, y);
- font->parent_scale_distance (x, y);
+ if (ret)
+ font->parent_scale_position (x, y);
return ret;
}
@@ -136,46 +134,42 @@
return FALSE;
}
-static hb_bool_t
+static void
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 *x,
- hb_position_t *y,
+ hb_position_t *kerning,
void *user_data HB_UNUSED)
{
if (font->parent) {
- hb_bool_t ret = hb_font_get_glyph_h_kerning (font->parent,
- left_glyph, right_glyph,
- x, y);
- font->parent_scale_distance (x, y);
- return ret;
+ hb_font_get_glyph_h_kerning (font->parent,
+ left_glyph, right_glyph,
+ kerning);
+ *kerning = font->parent_scale_x_distance (*kerning);
+ return;
}
- *x = *y = 0;
- return FALSE;
+ *kerning = 0;
}
-static hb_bool_t
+static void
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 *x,
- hb_position_t *y,
+ hb_position_t *kerning,
void *user_data HB_UNUSED)
{
if (font->parent) {
- hb_bool_t ret = hb_font_get_glyph_v_kerning (font->parent,
- top_glyph, bottom_glyph,
- x, y);
- font->parent_scale_distance (x, y);
- return ret;
+ hb_font_get_glyph_v_kerning (font->parent,
+ top_glyph, bottom_glyph,
+ kerning);
+ *kerning = font->parent_scale_y_distance (*kerning);
+ return;
}
- *x = *y = 0;
- return FALSE;
+ *kerning = 0;
}
static hb_bool_t
@@ -189,13 +183,14 @@
hb_bool_t ret = hb_font_get_glyph_extents (font->parent,
glyph,
extents);
- font->parent_scale_position (&extents->x_bearing, &extents->y_bearing);
- font->parent_scale_distance (&extents->width, &extents->height);
+ if (ret) {
+ font->parent_scale_position (&extents->x_bearing, &extents->y_bearing);
+ font->parent_scale_distance (&extents->width, &extents->height);
+ }
return ret;
}
- extents->x_bearing = extents->y_bearing = 0;
- extents->width = extents->height = 0;
+ memset (extents, 0, sizeof (*extents));
return FALSE;
}
@@ -212,7 +207,8 @@
hb_bool_t ret = hb_font_get_glyph_contour_point (font->parent,
glyph, point_index,
x, y);
- font->parent_scale_position (x, y);
+ if (ret)
+ font->parent_scale_position (x, y);
return ret;
}
@@ -344,26 +340,26 @@
font->klass->user_data.glyph);
}
-hb_bool_t
+void
hb_font_get_glyph_h_advance (hb_font_t *font,
hb_codepoint_t glyph,
- hb_position_t *x, hb_position_t *y)
+ hb_position_t *advance)
{
- *x = *y = 0;
- return font->klass->get.glyph_h_advance (font, font->user_data,
- glyph, x, y,
- font->klass->user_data.glyph_h_advance);
+ *advance = 0;
+ font->klass->get.glyph_h_advance (font, font->user_data,
+ glyph, advance,
+ font->klass->user_data.glyph_h_advance);
}
-hb_bool_t
+void
hb_font_get_glyph_v_advance (hb_font_t *font,
hb_codepoint_t glyph,
- hb_position_t *x, hb_position_t *y)
+ hb_position_t *advance)
{
- *x = *y = 0;
- return font->klass->get.glyph_v_advance (font, font->user_data,
- glyph, x, y,
- font->klass->user_data.glyph_v_advance);
+ *advance = 0;
+ font->klass->get.glyph_v_advance (font, font->user_data,
+ glyph, advance,
+ font->klass->user_data.glyph_v_advance);
}
hb_bool_t
@@ -388,27 +384,27 @@
font->klass->user_data.glyph_v_origin);
}
-hb_bool_t
+void
hb_font_get_glyph_h_kerning (hb_font_t *font,
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,
left_glyph, right_glyph,
- x, y,
+ kerning,
font->klass->user_data.glyph_h_kerning);
}
-hb_bool_t
+void
hb_font_get_glyph_v_kerning (hb_font_t *font,
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,
left_glyph, right_glyph,
- x, y,
+ kerning,
font->klass->user_data.glyph_v_kerning);
}
@@ -445,13 +441,12 @@
hb_direction_t direction,
hb_position_t *x, hb_position_t *y)
{
- if (HB_DIRECTION_IS_VERTICAL (direction)) {
- hb_bool_t ret = hb_font_get_glyph_v_advance (font, glyph, x, y);
- if (!ret) {
- /* TODO return font_extents.ascent + font_extents.descent? */
- }
+ if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
+ *y = 0;
+ hb_font_get_glyph_h_advance (font, glyph, x);
} 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_direction_t direction,
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);
if (!ret) {
/* 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_direction_t direction,
hb_position_t *x, hb_position_t *y)
{
- switch (direction) {
- case HB_DIRECTION_LTR:
- case HB_DIRECTION_RTL:
- hb_font_get_glyph_h_kerning (font, first_glyph, second_glyph, x, y);
- break;
-
- 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;
+ if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
+ *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);
}
}
-void
-hb_font_get_glyph_extents_for_direction (hb_font_t *font,
- hb_codepoint_t glyph,
- hb_direction_t direction,
- hb_glyph_extents_t *extents)
+hb_bool_t
+hb_font_get_glyph_extents_for_origin (hb_font_t *font,
+ hb_codepoint_t glyph,
+ hb_direction_t direction,
+ hb_glyph_extents_t *extents)
{
hb_bool_t ret = hb_font_get_glyph_extents (font, glyph, extents);
if (ret)
hb_font_subtract_glyph_origin_for_direction (font, glyph, direction, &extents->x_bearing, &extents->y_bearing);
+
+ return ret;
}
hb_bool_t
-hb_font_get_glyph_contour_point_for_direction (hb_font_t *font,
- hb_codepoint_t glyph, unsigned int point_index,
- hb_direction_t direction,
- hb_position_t *x, hb_position_t *y)
+hb_font_get_glyph_contour_point_for_origin (hb_font_t *font,
+ hb_codepoint_t glyph, unsigned int point_index,
+ hb_direction_t direction,
+ hb_position_t *x, hb_position_t *y)
{
hb_bool_t ret = hb_font_get_glyph_contour_point (font, glyph, point_index, x, y);