| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 2010,2012 Google, Inc. | 2 * Copyright © 2010,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. |
| 11 * | 11 * |
| 12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR | 12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
| 13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES | 13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
| 14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN | 14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
| 15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH | 15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
| 16 * DAMAGE. | 16 * DAMAGE. |
| 17 * | 17 * |
| 18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, | 18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
| 19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | 19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS | 20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
| 21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO | 21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
| 22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 23 * | 23 * |
| 24 * Google Author(s): Behdad Esfahbod | 24 * Google Author(s): Behdad Esfahbod |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "hb-ot-shape-complex-private.hh" | 27 #include "hb-ot-shape-complex-private.hh" |
| 28 | 28 |
| 29 | 29 |
| 30 /* TODO Add kana, and other small shapers here */ | |
| 31 | |
| 32 | |
| 33 /* The default shaper *only* adds additional per-script features.*/ | |
| 34 | |
| 35 static const hb_tag_t hangul_features[] = | |
| 36 { | |
| 37 HB_TAG('l','j','m','o'), | |
| 38 HB_TAG('v','j','m','o'), | |
| 39 HB_TAG('t','j','m','o'), | |
| 40 HB_TAG_NONE | |
| 41 }; | |
| 42 | |
| 43 static const hb_tag_t tibetan_features[] = | |
| 44 { | |
| 45 HB_TAG('a','b','v','s'), | |
| 46 HB_TAG('b','l','w','s'), | |
| 47 HB_TAG('a','b','v','m'), | |
| 48 HB_TAG('b','l','w','m'), | |
| 49 HB_TAG_NONE | |
| 50 }; | |
| 51 | |
| 52 static void | |
| 53 collect_features_default (hb_ot_shape_planner_t *plan) | |
| 54 { | |
| 55 const hb_tag_t *script_features = NULL; | |
| 56 | |
| 57 switch ((hb_tag_t) plan->props.script) | |
| 58 { | |
| 59 /* Unicode-1.1 additions */ | |
| 60 case HB_SCRIPT_HANGUL: | |
| 61 script_features = hangul_features; | |
| 62 break; | |
| 63 | |
| 64 /* Unicode-2.0 additions */ | |
| 65 case HB_SCRIPT_TIBETAN: | |
| 66 script_features = tibetan_features; | |
| 67 break; | |
| 68 } | |
| 69 | |
| 70 for (; script_features && *script_features; script_features++) | |
| 71 plan->map.add_global_bool_feature (*script_features); | |
| 72 } | |
| 73 | |
| 74 static hb_ot_shape_normalization_mode_t | |
| 75 normalization_preference_default (const hb_segment_properties_t *props) | |
| 76 { | |
| 77 return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS; | |
| 78 } | |
| 79 | |
| 80 static bool | 30 static bool |
| 81 compose_default (const hb_ot_shape_normalize_context_t *c, | 31 compose_hebrew (const hb_ot_shape_normalize_context_t *c, |
| 82 » » hb_codepoint_t a, | 32 » » hb_codepoint_t a, |
| 83 » » hb_codepoint_t b, | 33 » » hb_codepoint_t b, |
| 84 » » hb_codepoint_t *ab) | 34 » » hb_codepoint_t *ab) |
| 85 { | 35 { |
| 86 /* Hebrew presentation-form shaping. | 36 /* Hebrew presentation-form shaping. |
| 87 * https://bugzilla.mozilla.org/show_bug.cgi?id=728866 | 37 * https://bugzilla.mozilla.org/show_bug.cgi?id=728866 |
| 88 * Hebrew presentation forms with dagesh, for characters 0x05D0..0x05EA; | 38 * Hebrew presentation forms with dagesh, for characters 0x05D0..0x05EA; |
| 89 * Note that some letters do not have a dagesh presForm encoded. | 39 * Note that some letters do not have a dagesh presForm encoded. |
| 90 */ | 40 */ |
| 91 static const hb_codepoint_t sDageshForms[0x05EA - 0x05D0 + 1] = { | 41 static const hb_codepoint_t sDageshForms[0x05EA - 0x05D0 + 1] = { |
| 92 0xFB30, /* ALEF */ | 42 0xFB30, /* ALEF */ |
| 93 0xFB31, /* BET */ | 43 0xFB31, /* BET */ |
| 94 0xFB32, /* GIMEL */ | 44 0xFB32, /* GIMEL */ |
| (...skipping 18 matching lines...) Expand all Loading... |
| 113 0x0000, /* FINAL TSADI */ | 63 0x0000, /* FINAL TSADI */ |
| 114 0xFB46, /* TSADI */ | 64 0xFB46, /* TSADI */ |
| 115 0xFB47, /* QOF */ | 65 0xFB47, /* QOF */ |
| 116 0xFB48, /* RESH */ | 66 0xFB48, /* RESH */ |
| 117 0xFB49, /* SHIN */ | 67 0xFB49, /* SHIN */ |
| 118 0xFB4A /* TAV */ | 68 0xFB4A /* TAV */ |
| 119 }; | 69 }; |
| 120 | 70 |
| 121 bool found = c->unicode->compose (a, b, ab); | 71 bool found = c->unicode->compose (a, b, ab); |
| 122 | 72 |
| 123 if (!found && (b & ~0x7F) == 0x0580) { | 73 if (!found && !c->plan->has_mark) |
| 74 { |
| 124 /* Special-case Hebrew presentation forms that are excluded from | 75 /* Special-case Hebrew presentation forms that are excluded from |
| 125 * standard normalization, but wanted for old fonts. */ | 76 * standard normalization, but wanted for old fonts. */ |
| 126 switch (b) { | 77 switch (b) { |
| 127 case 0x05B4: /* HIRIQ */ | 78 case 0x05B4: /* HIRIQ */ |
| 128 if (a == 0x05D9) { /* YOD */ | 79 if (a == 0x05D9) { /* YOD */ |
| 129 *ab = 0xFB1D; | 80 *ab = 0xFB1D; |
| 130 found = true; | 81 found = true; |
| 131 } | 82 } |
| 132 break; | 83 break; |
| 133 case 0x05B7: /* patah */ | 84 case 0x05B7: /* patah */ |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 *ab = 0xFB2D; | 147 *ab = 0xFB2D; |
| 197 found = true; | 148 found = true; |
| 198 } | 149 } |
| 199 break; | 150 break; |
| 200 } | 151 } |
| 201 } | 152 } |
| 202 | 153 |
| 203 return found; | 154 return found; |
| 204 } | 155 } |
| 205 | 156 |
| 206 const hb_ot_complex_shaper_t _hb_ot_complex_shaper_default = | 157 |
| 158 const hb_ot_complex_shaper_t _hb_ot_complex_shaper_hebrew = |
| 207 { | 159 { |
| 208 "default", | 160 "hebrew", |
| 209 collect_features_default, | 161 NULL, /* collect_features */ |
| 210 NULL, /* override_features */ | 162 NULL, /* override_features */ |
| 211 NULL, /* data_create */ | 163 NULL, /* data_create */ |
| 212 NULL, /* data_destroy */ | 164 NULL, /* data_destroy */ |
| 213 NULL, /* preprocess_text */ | 165 NULL, /* preprocess_text */ |
| 214 normalization_preference_default, | 166 HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT, |
| 215 NULL, /* decompose */ | 167 NULL, /* decompose */ |
| 216 compose_default, | 168 compose_hebrew, |
| 217 NULL, /* setup_masks */ | 169 NULL, /* setup_masks */ |
| 218 HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_UNICODE_LATE, | 170 HB_OT_SHAPE_ZERO_WIDTH_MARKS_DEFAULT, |
| 219 true, /* fallback_position */ | 171 true, /* fallback_position */ |
| 220 }; | 172 }; |
| OLD | NEW |