OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2007,2008,2009,2010 Red Hat, Inc. | 2 * Copyright © 2007,2008,2009,2010 Red Hat, Inc. |
3 * Copyright © 2010,2012,2013 Google, Inc. | 3 * Copyright © 2010,2012,2013 Google, Inc. |
4 * | 4 * |
5 * This is part of HarfBuzz, a text shaping library. | 5 * This is part of HarfBuzz, a text shaping library. |
6 * | 6 * |
7 * Permission is hereby granted, without written agreement and without | 7 * Permission is hereby granted, without written agreement and without |
8 * license or royalty fees, to use, copy, modify, and distribute this | 8 * license or royalty fees, to use, copy, modify, and distribute this |
9 * software and its documentation for any purpose, provided that the | 9 * software and its documentation for any purpose, provided that the |
10 * above copyright notice and the following two paragraphs appear in | 10 * above copyright notice and the following two paragraphs appear in |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 { | 102 { |
103 unsigned int x_ppem, y_ppem; | 103 unsigned int x_ppem, y_ppem; |
104 unsigned int format = *this; | 104 unsigned int format = *this; |
105 hb_bool_t horizontal = HB_DIRECTION_IS_HORIZONTAL (direction); | 105 hb_bool_t horizontal = HB_DIRECTION_IS_HORIZONTAL (direction); |
106 | 106 |
107 if (!format) return; | 107 if (!format) return; |
108 | 108 |
109 if (format & xPlacement) glyph_pos.x_offset += font->em_scale_x (get_short
(values++)); | 109 if (format & xPlacement) glyph_pos.x_offset += font->em_scale_x (get_short
(values++)); |
110 if (format & yPlacement) glyph_pos.y_offset += font->em_scale_y (get_short
(values++)); | 110 if (format & yPlacement) glyph_pos.y_offset += font->em_scale_y (get_short
(values++)); |
111 if (format & xAdvance) { | 111 if (format & xAdvance) { |
112 if (likely (horizontal)) glyph_pos.x_advance += font->em_scale_x (get_shor
t (values++)); else values++; | 112 if (likely (horizontal)) glyph_pos.x_advance += font->em_scale_x (get_shor
t (values)); |
| 113 values++; |
113 } | 114 } |
114 /* y_advance values grow downward but font-space grows upward, hence negatio
n */ | 115 /* y_advance values grow downward but font-space grows upward, hence negatio
n */ |
115 if (format & yAdvance) { | 116 if (format & yAdvance) { |
116 if (unlikely (!horizontal)) glyph_pos.y_advance -= font->em_scale_y (get_s
hort (values++)); else values++; | 117 if (unlikely (!horizontal)) glyph_pos.y_advance -= font->em_scale_y (get_s
hort (values)); |
| 118 values++; |
117 } | 119 } |
118 | 120 |
119 if (!has_device ()) return; | 121 if (!has_device ()) return; |
120 | 122 |
121 x_ppem = font->x_ppem; | 123 x_ppem = font->x_ppem; |
122 y_ppem = font->y_ppem; | 124 y_ppem = font->y_ppem; |
123 | 125 |
124 if (!x_ppem && !y_ppem) return; | 126 if (!x_ppem && !y_ppem) return; |
125 | 127 |
126 /* pixel -> fractional pixel */ | 128 /* pixel -> fractional pixel */ |
127 if (format & xPlaDevice) { | 129 if (format & xPlaDevice) { |
128 if (x_ppem) glyph_pos.x_offset += (base + get_device (values++)).get_x_de
lta (font); else values++; | 130 if (x_ppem) glyph_pos.x_offset += (base + get_device (values)).get_x_delt
a (font); |
| 131 values++; |
129 } | 132 } |
130 if (format & yPlaDevice) { | 133 if (format & yPlaDevice) { |
131 if (y_ppem) glyph_pos.y_offset += (base + get_device (values++)).get_y_de
lta (font); else values++; | 134 if (y_ppem) glyph_pos.y_offset += (base + get_device (values)).get_y_delt
a (font); |
| 135 values++; |
132 } | 136 } |
133 if (format & xAdvDevice) { | 137 if (format & xAdvDevice) { |
134 if (horizontal && x_ppem) glyph_pos.x_advance += (base + get_device (value
s++)).get_x_delta (font); else values++; | 138 if (horizontal && x_ppem) glyph_pos.x_advance += (base + get_device (value
s)).get_x_delta (font); |
| 139 values++; |
135 } | 140 } |
136 if (format & yAdvDevice) { | 141 if (format & yAdvDevice) { |
137 /* y_advance values grow downward but font-space grows upward, hence negat
ion */ | 142 /* y_advance values grow downward but font-space grows upward, hence negat
ion */ |
138 if (!horizontal && y_ppem) glyph_pos.y_advance -= (base + get_device (valu
es++)).get_y_delta (font); else values++; | 143 if (!horizontal && y_ppem) glyph_pos.y_advance -= (base + get_device (valu
es)).get_y_delta (font); |
| 144 values++; |
139 } | 145 } |
140 } | 146 } |
141 | 147 |
142 private: | 148 private: |
143 inline bool sanitize_value_devices (hb_sanitize_context_t *c, void *base, Valu
e *values) { | 149 inline bool sanitize_value_devices (hb_sanitize_context_t *c, void *base, Valu
e *values) { |
144 unsigned int format = *this; | 150 unsigned int format = *this; |
145 | 151 |
146 if (format & xPlacement) values++; | 152 if (format & xPlacement) values++; |
147 if (format & yPlacement) values++; | 153 if (format & yPlacement) values++; |
148 if (format & xAdvance) values++; | 154 if (format & xAdvance) values++; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 }; | 239 }; |
234 | 240 |
235 struct AnchorFormat2 | 241 struct AnchorFormat2 |
236 { | 242 { |
237 inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id, | 243 inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id, |
238 hb_position_t *x, hb_position_t *y) const | 244 hb_position_t *x, hb_position_t *y) const |
239 { | 245 { |
240 unsigned int x_ppem = font->x_ppem; | 246 unsigned int x_ppem = font->x_ppem; |
241 unsigned int y_ppem = font->y_ppem; | 247 unsigned int y_ppem = font->y_ppem; |
242 hb_position_t cx, cy; | 248 hb_position_t cx, cy; |
243 hb_bool_t ret = false; | 249 hb_bool_t ret; |
244 | 250 |
245 if (x_ppem || y_ppem) | 251 ret = (x_ppem || y_ppem) && |
246 » ret = font->get_glyph_contour_point_for_origin (glyph_id, anchorPoint, H
B_DIRECTION_LTR, &cx, &cy); | 252 font->get_glyph_contour_point_for_origin (glyph_id, anchorPoint, HB
_DIRECTION_LTR, &cx, &cy); |
247 *x = x_ppem && ret ? cx : font->em_scale_x (xCoordinate); | 253 *x = ret && x_ppem ? cx : font->em_scale_x (xCoordinate); |
248 *y = y_ppem && ret ? cy : font->em_scale_y (yCoordinate); | 254 *y = ret && y_ppem ? cy : font->em_scale_y (yCoordinate); |
249 } | 255 } |
250 | 256 |
251 inline bool sanitize (hb_sanitize_context_t *c) { | 257 inline bool sanitize (hb_sanitize_context_t *c) { |
252 TRACE_SANITIZE (this); | 258 TRACE_SANITIZE (this); |
253 return TRACE_RETURN (c->check_struct (this)); | 259 return TRACE_RETURN (c->check_struct (this)); |
254 } | 260 } |
255 | 261 |
256 protected: | 262 protected: |
257 USHORT format; /* Format identifier--format = 2 */ | 263 USHORT format; /* Format identifier--format = 2 */ |
258 SHORT xCoordinate; /* Horizontal value--in design units */ | 264 SHORT xCoordinate; /* Horizontal value--in design units */ |
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1622 | 1628 |
1623 | 1629 |
1624 #undef attach_lookback | 1630 #undef attach_lookback |
1625 #undef cursive_chain | 1631 #undef cursive_chain |
1626 | 1632 |
1627 | 1633 |
1628 } /* namespace OT */ | 1634 } /* namespace OT */ |
1629 | 1635 |
1630 | 1636 |
1631 #endif /* HB_OT_LAYOUT_GPOS_TABLE_HH */ | 1637 #endif /* HB_OT_LAYOUT_GPOS_TABLE_HH */ |
OLD | NEW |