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

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

Issue 1416013004: Cherry pick disabled unicode compatibility decomposition into HarfBuzz (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « third_party/harfbuzz-ng/README.chromium ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 if (likely (b)) { 164 if (likely (b)) {
165 output_char (buffer, b, b_glyph); 165 output_char (buffer, b, b_glyph);
166 return 2; 166 return 2;
167 } 167 }
168 return 1; 168 return 1;
169 } 169 }
170 170
171 return 0; 171 return 0;
172 } 172 }
173 173
174 /* Returns 0 if didn't decompose, number of resulting characters otherwise. */
175 static inline unsigned int
176 decompose_compatibility (const hb_ot_shape_normalize_context_t *c, hb_codepoint_ t u)
177 {
178 unsigned int len, i;
179 hb_codepoint_t decomposed[HB_UNICODE_MAX_DECOMPOSITION_LEN];
180 hb_codepoint_t glyphs[HB_UNICODE_MAX_DECOMPOSITION_LEN];
181
182 len = c->buffer->unicode->decompose_compatibility (u, decomposed);
183 if (!len)
184 return 0;
185
186 for (i = 0; i < len; i++)
187 if (!c->font->get_glyph (decomposed[i], 0, &glyphs[i]))
188 return 0;
189
190 for (i = 0; i < len; i++)
191 output_char (c->buffer, decomposed[i], glyphs[i]);
192
193 return len;
194 }
195
196 static inline void 174 static inline void
197 decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shor test) 175 decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shor test)
198 { 176 {
199 hb_buffer_t * const buffer = c->buffer; 177 hb_buffer_t * const buffer = c->buffer;
200 hb_codepoint_t u = buffer->cur().codepoint; 178 hb_codepoint_t u = buffer->cur().codepoint;
201 hb_codepoint_t glyph; 179 hb_codepoint_t glyph;
202 180
203 /* Kind of a cute waterfall here... */ 181 /* Kind of a cute waterfall here... */
204 if (shortest && c->font->get_glyph (u, 0, &glyph)) 182 if (shortest && c->font->get_glyph (u, 0, &glyph))
205 next_char (buffer, glyph); 183 next_char (buffer, glyph);
206 else if (decompose (c, shortest, u)) 184 else if (decompose (c, shortest, u))
207 skip_char (buffer); 185 skip_char (buffer);
208 else if (!shortest && c->font->get_glyph (u, 0, &glyph)) 186 else if (!shortest && c->font->get_glyph (u, 0, &glyph))
209 next_char (buffer, glyph); 187 next_char (buffer, glyph);
210 else if (decompose_compatibility (c, u))
211 skip_char (buffer);
212 else 188 else
213 next_char (buffer, glyph); /* glyph is initialized in earlier branches. */ 189 next_char (buffer, glyph); /* glyph is initialized in earlier branches. */
214 } 190 }
215 191
216 static inline void 192 static inline void
217 handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, uns igned int end, bool short_circuit) 193 handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, uns igned int end, bool short_circuit)
218 { 194 {
219 /* TODO Currently if there's a variation-selector we give-up, it's just too ha rd. */ 195 /* TODO Currently if there's a variation-selector we give-up, it's just too ha rd. */
220 hb_buffer_t * const buffer = c->buffer; 196 hb_buffer_t * const buffer = c->buffer;
221 hb_font_t * const font = c->font; 197 hb_font_t * const font = c->font;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 383
408 /* Blocked, or doesn't compose. */ 384 /* Blocked, or doesn't compose. */
409 buffer->next_glyph (); 385 buffer->next_glyph ();
410 386
411 if (_hb_glyph_info_get_modified_combining_class (&buffer->prev()) == 0) 387 if (_hb_glyph_info_get_modified_combining_class (&buffer->prev()) == 0)
412 starter = buffer->out_len - 1; 388 starter = buffer->out_len - 1;
413 } 389 }
414 buffer->swap_buffers (); 390 buffer->swap_buffers ();
415 391
416 } 392 }
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698