| 1 | #ifndef OT_LAYOUT_GPOS_ANCHORFORMAT2_HH |
|---|---|
| 2 | #define OT_LAYOUT_GPOS_ANCHORFORMAT2_HH |
| 3 | |
| 4 | namespace OT { |
| 5 | namespace Layout { |
| 6 | namespace GPOS_impl { |
| 7 | |
| 8 | struct AnchorFormat2 |
| 9 | { |
| 10 | |
| 11 | protected: |
| 12 | HBUINT16 format; /* Format identifier--format = 2 */ |
| 13 | FWORD xCoordinate; /* Horizontal value--in design units */ |
| 14 | FWORD yCoordinate; /* Vertical value--in design units */ |
| 15 | HBUINT16 anchorPoint; /* Index to glyph contour point */ |
| 16 | public: |
| 17 | DEFINE_SIZE_STATIC (8); |
| 18 | |
| 19 | bool sanitize (hb_sanitize_context_t *c) const |
| 20 | { |
| 21 | TRACE_SANITIZE (this); |
| 22 | return_trace (c->check_struct (this)); |
| 23 | } |
| 24 | |
| 25 | void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id, |
| 26 | float *x, float *y) const |
| 27 | { |
| 28 | hb_font_t *font = c->font; |
| 29 | |
| 30 | #ifdef HB_NO_HINTING |
| 31 | *x = font->em_fscale_x (xCoordinate); |
| 32 | *y = font->em_fscale_y (yCoordinate); |
| 33 | return; |
| 34 | #endif |
| 35 | |
| 36 | unsigned int x_ppem = font->x_ppem; |
| 37 | unsigned int y_ppem = font->y_ppem; |
| 38 | hb_position_t cx = 0, cy = 0; |
| 39 | bool ret; |
| 40 | |
| 41 | ret = (x_ppem || y_ppem) && |
| 42 | font->get_glyph_contour_point_for_origin (glyph_id, anchorPoint, HB_DIRECTION_LTR, &cx, &cy); |
| 43 | *x = ret && x_ppem ? cx : font->em_fscale_x (xCoordinate); |
| 44 | *y = ret && y_ppem ? cy : font->em_fscale_y (yCoordinate); |
| 45 | } |
| 46 | |
| 47 | AnchorFormat2* copy (hb_serialize_context_t *c) const |
| 48 | { |
| 49 | TRACE_SERIALIZE (this); |
| 50 | return_trace (c->embed<AnchorFormat2> (this)); |
| 51 | } |
| 52 | }; |
| 53 | |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | #endif // OT_LAYOUT_GPOS_ANCHORFORMAT2_HH |
| 59 |