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

Side by Side Diff: third_party/harfbuzz-ng/src/hb-shape.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 © 2009 Red Hat, Inc. 2 * Copyright © 2009 Red Hat, Inc.
3 * Copyright © 2012 Google, Inc. 3 * Copyright © 2012 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 static hb_bool_t 146 static hb_bool_t
147 parse_one_feature (const char **pp, const char *end, hb_feature_t *feature) 147 parse_one_feature (const char **pp, const char *end, hb_feature_t *feature)
148 { 148 {
149 return parse_feature_value_prefix (pp, end, feature) && 149 return parse_feature_value_prefix (pp, end, feature) &&
150 parse_feature_tag (pp, end, feature) && 150 parse_feature_tag (pp, end, feature) &&
151 parse_feature_indices (pp, end, feature) && 151 parse_feature_indices (pp, end, feature) &&
152 parse_feature_value_postfix (pp, end, feature) && 152 parse_feature_value_postfix (pp, end, feature) &&
153 *pp == end; 153 *pp == end;
154 } 154 }
155 155
156 /**
157 * hb_feature_from_string:
158 * @str: (array length=len):
159 * @len:
160 * @feature: (out):
161 *
162 *
163 *
164 * Return value:
165 *
166 * Since: 1.0
167 **/
156 hb_bool_t 168 hb_bool_t
157 hb_feature_from_string (const char *str, int len, 169 hb_feature_from_string (const char *str, int len,
158 hb_feature_t *feature) 170 hb_feature_t *feature)
159 { 171 {
160 if (len < 0) 172 if (len < 0)
161 len = strlen (str); 173 len = strlen (str);
162 174
163 return parse_one_feature (&str, str + len, feature); 175 return parse_one_feature (&str, str + len, feature);
164 } 176 }
165 177
178 /**
179 * hb_feature_to_string:
180 * @feature:
181 * @buf: (array length=size):
182 * @size:
183 *
184 *
185 *
186 * Since: 1.0
187 **/
166 void 188 void
167 hb_feature_to_string (hb_feature_t *feature, 189 hb_feature_to_string (hb_feature_t *feature,
168 char *buf, unsigned int size) 190 char *buf, unsigned int size)
169 { 191 {
170 if (unlikely (!size)) return; 192 if (unlikely (!size)) return;
171 193
172 char s[128]; 194 char s[128];
173 unsigned int len = 0; 195 unsigned int len = 0;
174 if (feature->value == 0) 196 if (feature->value == 0)
175 s[len++] = '-'; 197 s[len++] = '-';
176 hb_tag_to_string (feature->tag, s + len); 198 hb_tag_to_string (feature->tag, s + len);
177 len += 4; 199 len += 4;
178 while (len && s[len - 1] == ' ') 200 while (len && s[len - 1] == ' ')
179 len--; 201 len--;
180 if (feature->start != 0 || feature->end != (unsigned int) -1) 202 if (feature->start != 0 || feature->end != (unsigned int) -1)
181 { 203 {
182 s[len++] = '['; 204 s[len++] = '[';
183 if (feature->start) 205 if (feature->start)
184 len += snprintf (s + len, ARRAY_LENGTH (s) - len, "%d", feature->start); 206 len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%d", feature->s tart));
185 if (feature->end != feature->start + 1) { 207 if (feature->end != feature->start + 1) {
186 s[len++] = ':'; 208 s[len++] = ':';
187 if (feature->end != (unsigned int) -1) 209 if (feature->end != (unsigned int) -1)
188 » len += snprintf (s + len, ARRAY_LENGTH (s) - len, "%d", feature->end); 210 » len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%d", feature- >end));
189 } 211 }
190 s[len++] = ']'; 212 s[len++] = ']';
191 } 213 }
192 if (feature->value > 1) 214 if (feature->value > 1)
193 { 215 {
194 s[len++] = '='; 216 s[len++] = '=';
195 len += snprintf (s + len, ARRAY_LENGTH (s) - len, "%d", feature->value); 217 len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%d", feature->val ue));
196 } 218 }
197 assert (len < ARRAY_LENGTH (s)); 219 assert (len < ARRAY_LENGTH (s));
198 len = MIN (len, size - 1); 220 len = MIN (len, size - 1);
199 memcpy (buf, s, len); 221 memcpy (buf, s, len);
200 s[len] = '\0'; 222 buf[len] = '\0';
201 } 223 }
202 224
203 225
204 static const char **static_shaper_list; 226 static const char **static_shaper_list;
205 227
206 static inline 228 static inline
207 void free_static_shaper_list (void) 229 void free_static_shaper_list (void)
208 { 230 {
209 free (static_shaper_list); 231 free (static_shaper_list);
210 } 232 }
211 233
234 /**
235 * hb_shape_list_shapers:
236 *
237 *
238 *
239 * Return value: (transfer none):
240 *
241 * Since: 1.0
242 **/
212 const char ** 243 const char **
213 hb_shape_list_shapers (void) 244 hb_shape_list_shapers (void)
214 { 245 {
215 retry: 246 retry:
216 const char **shaper_list = (const char **) hb_atomic_ptr_get (&static_shaper_l ist); 247 const char **shaper_list = (const char **) hb_atomic_ptr_get (&static_shaper_l ist);
217 248
218 if (unlikely (!shaper_list)) 249 if (unlikely (!shaper_list))
219 { 250 {
220 /* Not found; allocate one. */ 251 /* Not found; allocate one. */
221 shaper_list = (const char **) calloc (1 + HB_SHAPERS_COUNT, sizeof (const ch ar *)); 252 shaper_list = (const char **) calloc (1 + HB_SHAPERS_COUNT, sizeof (const ch ar *));
(...skipping 15 matching lines...) Expand all
237 268
238 #ifdef HAVE_ATEXIT 269 #ifdef HAVE_ATEXIT
239 atexit (free_static_shaper_list); /* First person registers atexit() callbac k. */ 270 atexit (free_static_shaper_list); /* First person registers atexit() callbac k. */
240 #endif 271 #endif
241 } 272 }
242 273
243 return shaper_list; 274 return shaper_list;
244 } 275 }
245 276
246 277
278 /**
279 * hb_shape_full:
280 * @font: a font.
281 * @buffer: a buffer.
282 * @features: (array length=num_features):
283 * @num_features:
284 * @shaper_list: (array zero-terminated=1):
285 *
286 *
287 *
288 * Return value:
289 *
290 * Since: 1.0
291 **/
247 hb_bool_t 292 hb_bool_t
248 hb_shape_full (hb_font_t *font, 293 hb_shape_full (hb_font_t *font,
249 hb_buffer_t *buffer, 294 hb_buffer_t *buffer,
250 const hb_feature_t *features, 295 const hb_feature_t *features,
251 unsigned int num_features, 296 unsigned int num_features,
252 const char * const *shaper_list) 297 const char * const *shaper_list)
253 { 298 {
254 if (unlikely (!buffer->len)) 299 if (unlikely (!buffer->len))
255 return true; 300 return true;
256 301
257 assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE); 302 assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE);
258 303
259 hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached (font->face, &buffer ->props, features, num_features, shaper_list); 304 hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached (font->face, &buffer ->props, features, num_features, shaper_list);
260 hb_bool_t res = hb_shape_plan_execute (shape_plan, font, buffer, features, num _features); 305 hb_bool_t res = hb_shape_plan_execute (shape_plan, font, buffer, features, num _features);
261 hb_shape_plan_destroy (shape_plan); 306 hb_shape_plan_destroy (shape_plan);
262 307
263 if (res) 308 if (res)
264 buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS; 309 buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS;
265 return res; 310 return res;
266 } 311 }
267 312
313 /**
314 * hb_shape:
315 * @font: a font.
316 * @buffer: a buffer.
317 * @features: (array length=num_features):
318 * @num_features:
319 *
320 *
321 *
322 * Since: 1.0
323 **/
268 void 324 void
269 hb_shape (hb_font_t *font, 325 hb_shape (hb_font_t *font,
270 hb_buffer_t *buffer, 326 hb_buffer_t *buffer,
271 const hb_feature_t *features, 327 const hb_feature_t *features,
272 unsigned int num_features) 328 unsigned int num_features)
273 { 329 {
274 hb_shape_full (font, buffer, features, num_features, NULL); 330 hb_shape_full (font, buffer, features, num_features, NULL);
275 } 331 }
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-set-private.hh ('k') | third_party/harfbuzz-ng/src/hb-shape-plan.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698