Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: third_party/harfbuzz-ng/src/hb-ot-shape-normalize.cc

Issue 70193010: Update harfbuzz-ng to 0.9.24 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright © 2011,2012 Google, Inc. 2 * Copyright © 2011,2012 Google, Inc.
3 * 3 *
4 * This is part of HarfBuzz, a text shaping library. 4 * This is part of HarfBuzz, a text shaping library.
5 * 5 *
6 * Permission is hereby granted, without written agreement and without 6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this 7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the 8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in 9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software. 10 * all copies of this software.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 skip_char (hb_buffer_t *buffer) 125 skip_char (hb_buffer_t *buffer)
126 { 126 {
127 buffer->skip_glyph (); 127 buffer->skip_glyph ();
128 } 128 }
129 129
130 /* Returns 0 if didn't decompose, number of resulting characters otherwise. */ 130 /* Returns 0 if didn't decompose, number of resulting characters otherwise. */
131 static inline unsigned int 131 static inline unsigned int
132 decompose (const hb_ot_shape_normalize_context_t *c, bool shortest, hb_codepoint _t ab) 132 decompose (const hb_ot_shape_normalize_context_t *c, bool shortest, hb_codepoint _t ab)
133 { 133 {
134 hb_codepoint_t a, b, a_glyph, b_glyph; 134 hb_codepoint_t a, b, a_glyph, b_glyph;
135 hb_buffer_t * const buffer = c->buffer;
136 hb_font_t * const font = c->font;
135 137
136 if (!c->decompose (c, ab, &a, &b) || 138 if (!c->decompose (c, ab, &a, &b) ||
137 (b && !c->font->get_glyph (b, 0, &b_glyph))) 139 (b && !font->get_glyph (b, 0, &b_glyph)))
138 return 0; 140 return 0;
139 141
140 bool has_a = c->font->get_glyph (a, 0, &a_glyph); 142 bool has_a = font->get_glyph (a, 0, &a_glyph);
141 if (shortest && has_a) { 143 if (shortest && has_a) {
142 /* Output a and b */ 144 /* Output a and b */
143 output_char (c->buffer, a, a_glyph); 145 output_char (buffer, a, a_glyph);
144 if (likely (b)) { 146 if (likely (b)) {
145 output_char (c->buffer, b, b_glyph); 147 output_char (buffer, b, b_glyph);
146 return 2; 148 return 2;
147 } 149 }
148 return 1; 150 return 1;
149 } 151 }
150 152
151 unsigned int ret; 153 unsigned int ret;
152 if ((ret = decompose (c, shortest, a))) { 154 if ((ret = decompose (c, shortest, a))) {
153 if (b) { 155 if (b) {
154 output_char (c->buffer, b, b_glyph); 156 output_char (buffer, b, b_glyph);
155 return ret + 1; 157 return ret + 1;
156 } 158 }
157 return ret; 159 return ret;
158 } 160 }
159 161
160 if (has_a) { 162 if (has_a) {
161 output_char (c->buffer, a, a_glyph); 163 output_char (buffer, a, a_glyph);
162 if (likely (b)) { 164 if (likely (b)) {
163 output_char (c->buffer, b, b_glyph); 165 output_char (buffer, b, b_glyph);
164 return 2; 166 return 2;
165 } 167 }
166 return 1; 168 return 1;
167 } 169 }
168 170
169 return 0; 171 return 0;
170 } 172 }
171 173
172 /* Returns 0 if didn't decompose, number of resulting characters otherwise. */ 174 /* Returns 0 if didn't decompose, number of resulting characters otherwise. */
173 static inline unsigned int 175 static inline unsigned int
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 else if (decompose_compatibility (c, buffer->cur().codepoint)) 209 else if (decompose_compatibility (c, buffer->cur().codepoint))
208 skip_char (buffer); 210 skip_char (buffer);
209 else 211 else
210 next_char (buffer, glyph); /* glyph is initialized in earlier branches. */ 212 next_char (buffer, glyph); /* glyph is initialized in earlier branches. */
211 } 213 }
212 214
213 static inline void 215 static inline void
214 handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, uns igned int end) 216 handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, uns igned int end)
215 { 217 {
216 hb_buffer_t * const buffer = c->buffer; 218 hb_buffer_t * const buffer = c->buffer;
219 hb_font_t * const font = c->font;
217 for (; buffer->idx < end - 1;) { 220 for (; buffer->idx < end - 1;) {
218 if (unlikely (buffer->unicode->is_variation_selector (buffer->cur(+1).codepo int))) { 221 if (unlikely (buffer->unicode->is_variation_selector (buffer->cur(+1).codepo int))) {
219 /* The next two lines are some ugly lines... But work. */ 222 /* The next two lines are some ugly lines... But work. */
220 c->font->get_glyph (buffer->cur().codepoint, buffer->cur(+1).codepoint, &b uffer->cur().glyph_index()); 223 if (font->get_glyph (buffer->cur().codepoint, buffer->cur(+1).codepoint, & buffer->cur().glyph_index()))
221 buffer->replace_glyphs (2, 1, &buffer->cur().codepoint); 224 {
225 » buffer->replace_glyphs (2, 1, &buffer->cur().codepoint);
226 }
227 else
228 {
229 /* Just pass on the two characters separately, let GSUB do its magic. */
230 » set_glyph (buffer->cur(), font);
231 » buffer->next_glyph ();
232 » set_glyph (buffer->cur(), font);
233 » buffer->next_glyph ();
234 }
235 /* Skip any further variation selectors. */
236 while (buffer->idx < end && unlikely (buffer->unicode->is_variation_select or (buffer->cur().codepoint)))
237 {
238 » set_glyph (buffer->cur(), font);
239 » buffer->next_glyph ();
240 }
222 } else { 241 } else {
223 set_glyph (buffer->cur(), c->font); 242 set_glyph (buffer->cur(), font);
224 buffer->next_glyph (); 243 buffer->next_glyph ();
225 } 244 }
226 } 245 }
227 if (likely (buffer->idx < end)) { 246 if (likely (buffer->idx < end)) {
228 set_glyph (buffer->cur(), c->font); 247 set_glyph (buffer->cur(), font);
229 buffer->next_glyph (); 248 buffer->next_glyph ();
230 } 249 }
231 } 250 }
232 251
233 static inline void 252 static inline void
234 decompose_multi_char_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end) 253 decompose_multi_char_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end)
235 { 254 {
236 hb_buffer_t * const buffer = c->buffer; 255 hb_buffer_t * const buffer = c->buffer;
237 /* TODO Currently if there's a variation-selector we give-up, it's just too ha rd. */ 256 /* TODO Currently if there's a variation-selector we give-up, it's just too ha rd. */
238 for (unsigned int i = buffer->idx; i < end; i++) 257 for (unsigned int i = buffer->idx; i < end; i++)
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 402
384 /* Blocked, or doesn't compose. */ 403 /* Blocked, or doesn't compose. */
385 buffer->next_glyph (); 404 buffer->next_glyph ();
386 405
387 if (_hb_glyph_info_get_modified_combining_class (&buffer->prev()) == 0) 406 if (_hb_glyph_info_get_modified_combining_class (&buffer->prev()) == 0)
388 starter = buffer->out_len - 1; 407 starter = buffer->out_len - 1;
389 } 408 }
390 buffer->swap_buffers (); 409 buffer->swap_buffers ();
391 410
392 } 411 }
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-ot-shape-fallback.cc ('k') | third_party/harfbuzz-ng/src/hb-private.hh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698