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

Side by Side Diff: third_party/harfbuzz-ng/src/hb-common.cc

Issue 10915172: harfbuzz-ng roll (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months 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
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-common.h ('k') | third_party/harfbuzz-ng/src/hb-coretext.h » ('j') | 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 © 2009,2010 Red Hat, Inc. 2 * Copyright © 2009,2010 Red Hat, Inc.
3 * Copyright © 2011,2012 Google, Inc. 3 * Copyright © 2011,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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 if (len < 0 || len > 4) 51 if (len < 0 || len > 4)
52 len = 4; 52 len = 4;
53 for (i = 0; i < (unsigned) len && s[i]; i++) 53 for (i = 0; i < (unsigned) len && s[i]; i++)
54 tag[i] = s[i]; 54 tag[i] = s[i];
55 for (; i < 4; i++) 55 for (; i < 4; i++)
56 tag[i] = ' '; 56 tag[i] = ' ';
57 57
58 return HB_TAG_CHAR4 (tag); 58 return HB_TAG_CHAR4 (tag);
59 } 59 }
60 60
61 void
62 hb_tag_to_string (hb_tag_t tag, char *buf)
63 {
64 buf[0] = (char) (uint8_t) (tag >> 24);
65 buf[1] = (char) (uint8_t) (tag >> 16);
66 buf[2] = (char) (uint8_t) (tag >> 8);
67 buf[3] = (char) (uint8_t) (tag >> 0);
68 }
69
61 70
62 /* hb_direction_t */ 71 /* hb_direction_t */
63 72
64 const char direction_strings[][4] = { 73 const char direction_strings[][4] = {
65 "ltr", 74 "ltr",
66 "rtl", 75 "rtl",
67 "ttb", 76 "ttb",
68 "btt" 77 "btt"
69 }; 78 };
70 79
(...skipping 20 matching lines...) Expand all
91 if (likely ((unsigned int) (direction - HB_DIRECTION_LTR) 100 if (likely ((unsigned int) (direction - HB_DIRECTION_LTR)
92 < ARRAY_LENGTH (direction_strings))) 101 < ARRAY_LENGTH (direction_strings)))
93 return direction_strings[direction - HB_DIRECTION_LTR]; 102 return direction_strings[direction - HB_DIRECTION_LTR];
94 103
95 return "invalid"; 104 return "invalid";
96 } 105 }
97 106
98 107
99 /* hb_language_t */ 108 /* hb_language_t */
100 109
101 struct _hb_language_t { 110 struct hb_language_impl_t {
102 const char s[1]; 111 const char s[1];
103 }; 112 };
104 113
105 static const char canon_map[256] = { 114 static const char canon_map[256] = {
106 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,
107 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,
108 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0 , 117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0 ,
109 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0, 0, 0, 0, 0, 0 , 118 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0, 0, 0, 0, 0, 0 ,
110 '-', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o ', 119 '-', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o ',
111 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0, 0, 0, 0, '- ', 120 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0, 0, 0, 0, '- ',
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 const char * 240 const char *
232 hb_language_to_string (hb_language_t language) 241 hb_language_to_string (hb_language_t language)
233 { 242 {
234 /* This is actually NULL-safe! */ 243 /* This is actually NULL-safe! */
235 return language->s; 244 return language->s;
236 } 245 }
237 246
238 hb_language_t 247 hb_language_t
239 hb_language_get_default (void) 248 hb_language_get_default (void)
240 { 249 {
241 static hb_language_t default_language; 250 static hb_language_t default_language = HB_LANGUAGE_INVALID;
242 251
243 if (!default_language) { 252 hb_language_t language = (hb_language_t) hb_atomic_ptr_get (&default_language) ;
244 /* This block is not quite threadsafe, but is not as bad as 253 if (unlikely (language == HB_LANGUAGE_INVALID)) {
245 * it looks since it's idempotent. As long as pointer ops 254 language = hb_language_from_string (setlocale (LC_CTYPE, NULL), -1);
246 * are atomic, we are safe. */ 255 hb_atomic_ptr_cmpexch (&default_language, HB_LANGUAGE_INVALID, language);
247
248 /* I hear that setlocale() doesn't honor env vars on Windows,
249 * but for now we ignore that. */
250
251 default_language = hb_language_from_string (setlocale (LC_CTYPE, NULL), -1);
252 } 256 }
253 257
254 return default_language; 258 return default_language;
255 } 259 }
256 260
257 261
258 /* hb_script_t */ 262 /* hb_script_t */
259 263
260 hb_script_t 264 hb_script_t
261 hb_script_from_iso15924_tag (hb_tag_t tag) 265 hb_script_from_iso15924_tag (hb_tag_t tag)
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 417
414 hb_bool_t 418 hb_bool_t
415 hb_version_check (unsigned int major, 419 hb_version_check (unsigned int major,
416 unsigned int minor, 420 unsigned int minor,
417 unsigned int micro) 421 unsigned int micro)
418 { 422 {
419 return HB_VERSION_CHECK (major, minor, micro); 423 return HB_VERSION_CHECK (major, minor, micro);
420 } 424 }
421 425
422 426
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-common.h ('k') | third_party/harfbuzz-ng/src/hb-coretext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698