diff --git a/src/hb-font.cc b/src/hb-font.cc index 3b1b6ca17..d0d58f1fb 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -196,6 +196,7 @@ hb_font_get_contour_point (hb_font_t *font, hb_face_t *face, unsigned int point_index, hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y) { + *x = 0; *y = 0; return font->klass->get_contour_point (font, face, font->user_data, point_index, glyph, x, y); diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh index cc037a4d4..e85b57819 100644 --- a/src/hb-ot-layout-gdef-private.hh +++ b/src/hb-ot-layout-gdef-private.hh @@ -116,9 +116,11 @@ struct CaretValueFormat2 inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const { /* TODO vertical */ - hb_position_t x = 0, y = 0; - hb_font_get_contour_point (context->font, context->face, caretValuePoint, glyph_id, &x, &y); - return x; + hb_position_t x, y; + if (hb_font_get_contour_point (context->font, context->face, caretValuePoint, glyph_id, &x, &y)) + return x; + else + return 0; } inline bool sanitize (SANITIZE_ARG_DEF) { diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh index f3fb26596..07c411751 100644 --- a/src/hb-ot-layout-gpos-private.hh +++ b/src/hb-ot-layout-gpos-private.hh @@ -221,10 +221,15 @@ struct AnchorFormat2 inline void get_anchor (hb_ot_layout_context_t *layout_context, hb_codepoint_t glyph_id, hb_position_t *x, hb_position_t *y) const { - /* TODO Contour - * NOTE only adjust directions with nonzero ppem */ - *x = _hb_16dot16_mul_round (layout_context->font->x_scale, xCoordinate); - *y = _hb_16dot16_mul_round (layout_context->font->y_scale, yCoordinate); + unsigned int x_ppem = layout_context->font->x_ppem; + unsigned int y_ppem = layout_context->font->y_ppem; + hb_position_t cx, cy; + hb_bool_t ret; + + if (x_ppem || y_ppem) + ret = hb_font_get_contour_point (layout_context->font, layout_context->face, anchorPoint, glyph_id, &cx, &cy); + *x = x_ppem && ret ? cx : _hb_16dot16_mul_round (layout_context->font->x_scale, xCoordinate); + *y = y_ppem && ret ? cy : _hb_16dot16_mul_round (layout_context->font->y_scale, yCoordinate); } inline bool sanitize (SANITIZE_ARG_DEF) {