1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/harfbuzz/src/hb-ot-shape-complex-hebrew.cc Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,172 @@ 1.4 +/* 1.5 + * Copyright © 2010,2012 Google, Inc. 1.6 + * 1.7 + * This is part of HarfBuzz, a text shaping library. 1.8 + * 1.9 + * Permission is hereby granted, without written agreement and without 1.10 + * license or royalty fees, to use, copy, modify, and distribute this 1.11 + * software and its documentation for any purpose, provided that the 1.12 + * above copyright notice and the following two paragraphs appear in 1.13 + * all copies of this software. 1.14 + * 1.15 + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 1.16 + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 1.17 + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 1.18 + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 1.19 + * DAMAGE. 1.20 + * 1.21 + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 1.22 + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 1.23 + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 1.24 + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 1.25 + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 1.26 + * 1.27 + * Google Author(s): Behdad Esfahbod 1.28 + */ 1.29 + 1.30 +#include "hb-ot-shape-complex-private.hh" 1.31 + 1.32 + 1.33 +static bool 1.34 +compose_hebrew (const hb_ot_shape_normalize_context_t *c, 1.35 + hb_codepoint_t a, 1.36 + hb_codepoint_t b, 1.37 + hb_codepoint_t *ab) 1.38 +{ 1.39 + /* Hebrew presentation-form shaping. 1.40 + * https://bugzilla.mozilla.org/show_bug.cgi?id=728866 1.41 + * Hebrew presentation forms with dagesh, for characters 0x05D0..0x05EA; 1.42 + * Note that some letters do not have a dagesh presForm encoded. 1.43 + */ 1.44 + static const hb_codepoint_t sDageshForms[0x05EA - 0x05D0 + 1] = { 1.45 + 0xFB30, /* ALEF */ 1.46 + 0xFB31, /* BET */ 1.47 + 0xFB32, /* GIMEL */ 1.48 + 0xFB33, /* DALET */ 1.49 + 0xFB34, /* HE */ 1.50 + 0xFB35, /* VAV */ 1.51 + 0xFB36, /* ZAYIN */ 1.52 + 0x0000, /* HET */ 1.53 + 0xFB38, /* TET */ 1.54 + 0xFB39, /* YOD */ 1.55 + 0xFB3A, /* FINAL KAF */ 1.56 + 0xFB3B, /* KAF */ 1.57 + 0xFB3C, /* LAMED */ 1.58 + 0x0000, /* FINAL MEM */ 1.59 + 0xFB3E, /* MEM */ 1.60 + 0x0000, /* FINAL NUN */ 1.61 + 0xFB40, /* NUN */ 1.62 + 0xFB41, /* SAMEKH */ 1.63 + 0x0000, /* AYIN */ 1.64 + 0xFB43, /* FINAL PE */ 1.65 + 0xFB44, /* PE */ 1.66 + 0x0000, /* FINAL TSADI */ 1.67 + 0xFB46, /* TSADI */ 1.68 + 0xFB47, /* QOF */ 1.69 + 0xFB48, /* RESH */ 1.70 + 0xFB49, /* SHIN */ 1.71 + 0xFB4A /* TAV */ 1.72 + }; 1.73 + 1.74 + bool found = c->unicode->compose (a, b, ab); 1.75 + 1.76 + if (!found) 1.77 + { 1.78 + /* Special-case Hebrew presentation forms that are excluded from 1.79 + * standard normalization, but wanted for old fonts. */ 1.80 + switch (b) { 1.81 + case 0x05B4: /* HIRIQ */ 1.82 + if (a == 0x05D9) { /* YOD */ 1.83 + *ab = 0xFB1D; 1.84 + found = true; 1.85 + } 1.86 + break; 1.87 + case 0x05B7: /* patah */ 1.88 + if (a == 0x05F2) { /* YIDDISH YOD YOD */ 1.89 + *ab = 0xFB1F; 1.90 + found = true; 1.91 + } else if (a == 0x05D0) { /* ALEF */ 1.92 + *ab = 0xFB2E; 1.93 + found = true; 1.94 + } 1.95 + break; 1.96 + case 0x05B8: /* QAMATS */ 1.97 + if (a == 0x05D0) { /* ALEF */ 1.98 + *ab = 0xFB2F; 1.99 + found = true; 1.100 + } 1.101 + break; 1.102 + case 0x05B9: /* HOLAM */ 1.103 + if (a == 0x05D5) { /* VAV */ 1.104 + *ab = 0xFB4B; 1.105 + found = true; 1.106 + } 1.107 + break; 1.108 + case 0x05BC: /* DAGESH */ 1.109 + if (a >= 0x05D0 && a <= 0x05EA) { 1.110 + *ab = sDageshForms[a - 0x05D0]; 1.111 + found = (*ab != 0); 1.112 + } else if (a == 0xFB2A) { /* SHIN WITH SHIN DOT */ 1.113 + *ab = 0xFB2C; 1.114 + found = true; 1.115 + } else if (a == 0xFB2B) { /* SHIN WITH SIN DOT */ 1.116 + *ab = 0xFB2D; 1.117 + found = true; 1.118 + } 1.119 + break; 1.120 + case 0x05BF: /* RAFE */ 1.121 + switch (a) { 1.122 + case 0x05D1: /* BET */ 1.123 + *ab = 0xFB4C; 1.124 + found = true; 1.125 + break; 1.126 + case 0x05DB: /* KAF */ 1.127 + *ab = 0xFB4D; 1.128 + found = true; 1.129 + break; 1.130 + case 0x05E4: /* PE */ 1.131 + *ab = 0xFB4E; 1.132 + found = true; 1.133 + break; 1.134 + } 1.135 + break; 1.136 + case 0x05C1: /* SHIN DOT */ 1.137 + if (a == 0x05E9) { /* SHIN */ 1.138 + *ab = 0xFB2A; 1.139 + found = true; 1.140 + } else if (a == 0xFB49) { /* SHIN WITH DAGESH */ 1.141 + *ab = 0xFB2C; 1.142 + found = true; 1.143 + } 1.144 + break; 1.145 + case 0x05C2: /* SIN DOT */ 1.146 + if (a == 0x05E9) { /* SHIN */ 1.147 + *ab = 0xFB2B; 1.148 + found = true; 1.149 + } else if (a == 0xFB49) { /* SHIN WITH DAGESH */ 1.150 + *ab = 0xFB2D; 1.151 + found = true; 1.152 + } 1.153 + break; 1.154 + } 1.155 + } 1.156 + 1.157 + return found; 1.158 +} 1.159 + 1.160 + 1.161 +const hb_ot_complex_shaper_t _hb_ot_complex_shaper_hebrew = 1.162 +{ 1.163 + "hebrew", 1.164 + NULL, /* collect_features */ 1.165 + NULL, /* override_features */ 1.166 + NULL, /* data_create */ 1.167 + NULL, /* data_destroy */ 1.168 + NULL, /* preprocess_text */ 1.169 + HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT, 1.170 + NULL, /* decompose */ 1.171 + compose_hebrew, 1.172 + NULL, /* setup_masks */ 1.173 + HB_OT_SHAPE_ZERO_WIDTH_MARKS_DEFAULT, 1.174 + true, /* fallback_position */ 1.175 +};