OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2009,2010 Red Hat, Inc. | 2 * Copyright © 2009,2010 Red Hat, Inc. |
3 * Copyright © 2011 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 |
11 * all copies of this software. | 11 * all copies of this software. |
12 * | 12 * |
13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR | 13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 { | 73 { |
74 if (unlikely (!str || !len || !*str)) | 74 if (unlikely (!str || !len || !*str)) |
75 return HB_DIRECTION_INVALID; | 75 return HB_DIRECTION_INVALID; |
76 | 76 |
77 /* Lets match loosely: just match the first letter, such that | 77 /* Lets match loosely: just match the first letter, such that |
78 * all of "ltr", "left-to-right", etc work! | 78 * all of "ltr", "left-to-right", etc work! |
79 */ | 79 */ |
80 char c = TOLOWER (str[0]); | 80 char c = TOLOWER (str[0]); |
81 for (unsigned int i = 0; i < ARRAY_LENGTH (direction_strings); i++) | 81 for (unsigned int i = 0; i < ARRAY_LENGTH (direction_strings); i++) |
82 if (c == direction_strings[i][0]) | 82 if (c == direction_strings[i][0]) |
83 return (hb_direction_t) i; | 83 return (hb_direction_t) (HB_DIRECTION_LTR + i); |
84 | 84 |
85 return HB_DIRECTION_INVALID; | 85 return HB_DIRECTION_INVALID; |
86 } | 86 } |
87 | 87 |
88 const char * | 88 const char * |
89 hb_direction_to_string (hb_direction_t direction) | 89 hb_direction_to_string (hb_direction_t direction) |
90 { | 90 { |
91 if (likely ((unsigned int) direction < ARRAY_LENGTH (direction_strings))) | 91 if (likely ((unsigned int) (direction - HB_DIRECTION_LTR) |
92 return direction_strings[direction]; | 92 » < ARRAY_LENGTH (direction_strings))) |
| 93 return direction_strings[direction - HB_DIRECTION_LTR]; |
93 | 94 |
94 return "invalid"; | 95 return "invalid"; |
95 } | 96 } |
96 | 97 |
97 | 98 |
98 /* hb_language_t */ | 99 /* hb_language_t */ |
99 | 100 |
100 struct _hb_language_t { | 101 struct _hb_language_t { |
101 const char s[1]; | 102 const char s[1]; |
102 }; | 103 }; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 | 258 |
258 hb_tag_t | 259 hb_tag_t |
259 hb_script_to_iso15924_tag (hb_script_t script) | 260 hb_script_to_iso15924_tag (hb_script_t script) |
260 { | 261 { |
261 return (hb_tag_t) script; | 262 return (hb_tag_t) script; |
262 } | 263 } |
263 | 264 |
264 hb_direction_t | 265 hb_direction_t |
265 hb_script_get_horizontal_direction (hb_script_t script) | 266 hb_script_get_horizontal_direction (hb_script_t script) |
266 { | 267 { |
| 268 /* http://goo.gl/x9ilM */ |
267 switch ((hb_tag_t) script) | 269 switch ((hb_tag_t) script) |
268 { | 270 { |
| 271 /* Unicode-1.1 additions */ |
269 case HB_SCRIPT_ARABIC: | 272 case HB_SCRIPT_ARABIC: |
270 case HB_SCRIPT_HEBREW: | 273 case HB_SCRIPT_HEBREW: |
| 274 |
| 275 /* Unicode-3.0 additions */ |
271 case HB_SCRIPT_SYRIAC: | 276 case HB_SCRIPT_SYRIAC: |
272 case HB_SCRIPT_THAANA: | 277 case HB_SCRIPT_THAANA: |
273 | 278 |
274 /* Unicode-4.0 additions */ | 279 /* Unicode-4.0 additions */ |
275 case HB_SCRIPT_CYPRIOT: | 280 case HB_SCRIPT_CYPRIOT: |
276 | 281 |
| 282 /* Unicode-4.1 additions */ |
| 283 case HB_SCRIPT_KHAROSHTHI: |
| 284 |
277 /* Unicode-5.0 additions */ | 285 /* Unicode-5.0 additions */ |
278 case HB_SCRIPT_PHOENICIAN: | 286 case HB_SCRIPT_PHOENICIAN: |
279 case HB_SCRIPT_NKO: | 287 case HB_SCRIPT_NKO: |
280 | 288 |
| 289 /* Unicode-5.1 additions */ |
| 290 case HB_SCRIPT_LYDIAN: |
| 291 |
281 /* Unicode-5.2 additions */ | 292 /* Unicode-5.2 additions */ |
282 case HB_SCRIPT_AVESTAN: | 293 case HB_SCRIPT_AVESTAN: |
283 case HB_SCRIPT_IMPERIAL_ARAMAIC: | 294 case HB_SCRIPT_IMPERIAL_ARAMAIC: |
284 case HB_SCRIPT_INSCRIPTIONAL_PAHLAVI: | 295 case HB_SCRIPT_INSCRIPTIONAL_PAHLAVI: |
285 case HB_SCRIPT_INSCRIPTIONAL_PARTHIAN: | 296 case HB_SCRIPT_INSCRIPTIONAL_PARTHIAN: |
286 case HB_SCRIPT_OLD_SOUTH_ARABIAN: | 297 case HB_SCRIPT_OLD_SOUTH_ARABIAN: |
287 case HB_SCRIPT_OLD_TURKIC: | 298 case HB_SCRIPT_OLD_TURKIC: |
288 case HB_SCRIPT_SAMARITAN: | 299 case HB_SCRIPT_SAMARITAN: |
289 | 300 |
290 /* Unicode-6.0 additions */ | 301 /* Unicode-6.0 additions */ |
291 case HB_SCRIPT_MANDAIC: | 302 case HB_SCRIPT_MANDAIC: |
292 | 303 |
| 304 /* Unicode-6.1 additions */ |
| 305 case HB_SCRIPT_MEROITIC_CURSIVE: |
| 306 case HB_SCRIPT_MEROITIC_HIEROGLYPHS: |
| 307 |
293 return HB_DIRECTION_RTL; | 308 return HB_DIRECTION_RTL; |
294 } | 309 } |
295 | 310 |
296 return HB_DIRECTION_LTR; | 311 return HB_DIRECTION_LTR; |
297 } | 312 } |
298 | 313 |
299 | 314 |
300 /* hb_user_data_array_t */ | 315 /* hb_user_data_array_t */ |
301 | 316 |
302 | 317 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 378 |
364 hb_bool_t | 379 hb_bool_t |
365 hb_version_check (unsigned int major, | 380 hb_version_check (unsigned int major, |
366 unsigned int minor, | 381 unsigned int minor, |
367 unsigned int micro) | 382 unsigned int micro) |
368 { | 383 { |
369 return HB_VERSION_CHECK (major, minor, micro); | 384 return HB_VERSION_CHECK (major, minor, micro); |
370 } | 385 } |
371 | 386 |
372 | 387 |
OLD | NEW |