hb-buffer-deserialize-text-unicode.hh (6504B)
1 #line 1 "hb-buffer-deserialize-text-unicode.rl" 2 /* 3 * Copyright © 2013 Google, Inc. 4 * 5 * This is part of HarfBuzz, a text shaping library. 6 * 7 * Permission is hereby granted, without written agreement and without 8 * license or royalty fees, to use, copy, modify, and distribute this 9 * software and its documentation for any purpose, provided that the 10 * above copyright notice and the following two paragraphs appear in 11 * all copies of this software. 12 * 13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 17 * DAMAGE. 18 * 19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 24 * 25 * Google Author(s): Behdad Esfahbod 26 */ 27 28 #ifndef HB_BUFFER_DESERIALIZE_TEXT_UNICODE_HH 29 #define HB_BUFFER_DESERIALIZE_TEXT_UNICODE_HH 30 31 #include "hb.hh" 32 33 34 #line 33 "hb-buffer-deserialize-text-unicode.hh" 35 static const unsigned char _deserialize_text_unicode_trans_keys[] = { 36 0u, 0u, 43u, 102u, 48u, 102u, 48u, 124u, 48u, 57u, 62u, 124u, 48u, 124u, 60u, 117u, 37 85u, 117u, 85u, 117u, 0 38 }; 39 40 static const char _deserialize_text_unicode_key_spans[] = { 41 0, 60, 55, 77, 10, 63, 77, 58, 42 33, 33 43 }; 44 45 static const short _deserialize_text_unicode_index_offsets[] = { 46 0, 0, 61, 117, 195, 206, 270, 348, 47 407, 441 48 }; 49 50 static const char _deserialize_text_unicode_indicies[] = { 51 0, 1, 1, 1, 1, 2, 2, 52 2, 2, 2, 2, 2, 2, 2, 2, 53 1, 1, 1, 1, 1, 1, 1, 2, 54 2, 2, 2, 2, 2, 1, 1, 1, 55 1, 1, 1, 1, 1, 1, 1, 1, 56 1, 1, 1, 1, 1, 1, 1, 1, 57 1, 1, 1, 1, 1, 1, 1, 2, 58 2, 2, 2, 2, 2, 1, 2, 2, 59 2, 2, 2, 2, 2, 2, 2, 2, 60 1, 1, 1, 1, 1, 1, 1, 2, 61 2, 2, 2, 2, 2, 1, 1, 1, 62 1, 1, 1, 1, 1, 1, 1, 1, 63 1, 1, 1, 1, 1, 1, 1, 1, 64 1, 1, 1, 1, 1, 1, 1, 2, 65 2, 2, 2, 2, 2, 1, 3, 3, 66 3, 3, 3, 3, 3, 3, 3, 3, 67 1, 1, 1, 4, 5, 1, 1, 3, 68 3, 3, 3, 3, 3, 1, 1, 1, 69 1, 1, 1, 1, 1, 1, 1, 1, 70 1, 1, 1, 1, 1, 1, 1, 1, 71 1, 1, 1, 1, 1, 1, 1, 3, 72 3, 3, 3, 3, 3, 1, 1, 1, 73 1, 1, 1, 1, 1, 1, 1, 1, 74 1, 1, 1, 1, 1, 1, 1, 1, 75 1, 1, 5, 1, 6, 7, 7, 7, 76 7, 7, 7, 7, 7, 7, 1, 8, 77 1, 1, 1, 1, 1, 1, 1, 1, 78 1, 1, 1, 1, 1, 1, 1, 1, 79 1, 1, 1, 1, 1, 1, 1, 1, 80 1, 1, 1, 1, 1, 1, 1, 1, 81 1, 1, 1, 1, 1, 1, 1, 1, 82 1, 1, 1, 1, 1, 1, 1, 1, 83 1, 1, 1, 1, 1, 1, 1, 1, 84 1, 1, 1, 1, 1, 8, 1, 9, 85 9, 9, 9, 9, 9, 9, 9, 9, 86 9, 1, 1, 1, 1, 8, 1, 1, 87 1, 1, 1, 1, 1, 1, 1, 1, 88 1, 1, 1, 1, 1, 1, 1, 1, 89 1, 1, 1, 1, 1, 1, 1, 1, 90 1, 1, 1, 1, 1, 1, 1, 1, 91 1, 1, 1, 1, 1, 1, 1, 1, 92 1, 1, 1, 1, 1, 1, 1, 1, 93 1, 1, 1, 1, 1, 1, 1, 1, 94 1, 1, 1, 8, 1, 10, 1, 1, 95 1, 1, 1, 1, 1, 1, 1, 1, 96 1, 1, 1, 1, 1, 1, 1, 1, 97 1, 1, 1, 1, 1, 1, 11, 1, 98 1, 1, 1, 1, 1, 1, 1, 1, 99 1, 1, 1, 1, 1, 1, 1, 1, 100 1, 1, 1, 1, 1, 1, 1, 1, 101 1, 1, 1, 1, 1, 1, 11, 1, 102 11, 1, 1, 1, 1, 1, 1, 1, 103 1, 1, 1, 1, 1, 1, 1, 1, 104 1, 1, 1, 1, 1, 1, 1, 1, 105 1, 1, 1, 1, 1, 1, 1, 1, 106 11, 1, 12, 1, 1, 1, 1, 1, 107 1, 1, 1, 1, 1, 1, 1, 1, 108 1, 1, 1, 1, 1, 1, 1, 1, 109 1, 1, 1, 1, 1, 1, 1, 1, 110 1, 1, 12, 1, 0 111 }; 112 113 static const char _deserialize_text_unicode_trans_targs[] = { 114 2, 0, 3, 3, 4, 9, 5, 6, 115 9, 6, 8, 1, 1 116 }; 117 118 static const char _deserialize_text_unicode_trans_actions[] = { 119 0, 0, 1, 0, 2, 2, 1, 1, 120 3, 0, 0, 4, 6 121 }; 122 123 static const char _deserialize_text_unicode_eof_actions[] = { 124 0, 0, 0, 0, 0, 0, 0, 0, 125 0, 5 126 }; 127 128 static const int deserialize_text_unicode_start = 7; 129 static const int deserialize_text_unicode_first_final = 7; 130 static const int deserialize_text_unicode_error = 0; 131 132 static const int deserialize_text_unicode_en_main = 7; 133 134 135 #line 80 "hb-buffer-deserialize-text-unicode.rl" 136 137 138 static hb_bool_t 139 _hb_buffer_deserialize_text_unicode (hb_buffer_t *buffer, 140 const char *buf, 141 unsigned int buf_len, 142 const char **end_ptr, 143 hb_font_t *font) 144 { 145 const char *p = buf, *pe = buf + buf_len, *eof = pe; 146 147 const char *tok = nullptr; 148 int cs; 149 hb_glyph_info_t info = {0}; 150 const hb_glyph_position_t pos = {0}; 151 152 #line 147 "hb-buffer-deserialize-text-unicode.hh" 153 { 154 cs = deserialize_text_unicode_start; 155 } 156 157 #line 150 "hb-buffer-deserialize-text-unicode.hh" 158 { 159 int _slen; 160 int _trans; 161 const unsigned char *_keys; 162 const char *_inds; 163 if ( p == pe ) 164 goto _test_eof; 165 if ( cs == 0 ) 166 goto _out; 167 _resume: 168 _keys = _deserialize_text_unicode_trans_keys + (cs<<1); 169 _inds = _deserialize_text_unicode_indicies + _deserialize_text_unicode_index_offsets[cs]; 170 171 _slen = _deserialize_text_unicode_key_spans[cs]; 172 _trans = _inds[ _slen > 0 && _keys[0] <=(*p) && 173 (*p) <= _keys[1] ? 174 (*p) - _keys[0] : _slen ]; 175 176 cs = _deserialize_text_unicode_trans_targs[_trans]; 177 178 if ( _deserialize_text_unicode_trans_actions[_trans] == 0 ) 179 goto _again; 180 181 switch ( _deserialize_text_unicode_trans_actions[_trans] ) { 182 case 4: 183 #line 38 "hb-buffer-deserialize-text-unicode.rl" 184 { 185 hb_memset (&info, 0, sizeof (info)); 186 } 187 break; 188 case 1: 189 #line 51 "hb-buffer-deserialize-text-unicode.rl" 190 { 191 tok = p; 192 } 193 break; 194 case 2: 195 #line 55 "hb-buffer-deserialize-text-unicode.rl" 196 {if (!parse_hex (tok, p, &info.codepoint )) return false; } 197 break; 198 case 3: 199 #line 57 "hb-buffer-deserialize-text-unicode.rl" 200 { if (!parse_uint (tok, p, &info.cluster )) return false; } 201 break; 202 case 6: 203 #line 42 "hb-buffer-deserialize-text-unicode.rl" 204 { 205 buffer->add_info (info); 206 if (unlikely (!buffer->successful)) 207 return false; 208 if (buffer->have_positions) 209 buffer->pos[buffer->len - 1] = pos; 210 *end_ptr = p; 211 } 212 #line 38 "hb-buffer-deserialize-text-unicode.rl" 213 { 214 hb_memset (&info, 0, sizeof (info)); 215 } 216 break; 217 #line 203 "hb-buffer-deserialize-text-unicode.hh" 218 } 219 220 _again: 221 if ( cs == 0 ) 222 goto _out; 223 if ( ++p != pe ) 224 goto _resume; 225 _test_eof: {} 226 if ( p == eof ) 227 { 228 switch ( _deserialize_text_unicode_eof_actions[cs] ) { 229 case 5: 230 #line 42 "hb-buffer-deserialize-text-unicode.rl" 231 { 232 buffer->add_info (info); 233 if (unlikely (!buffer->successful)) 234 return false; 235 if (buffer->have_positions) 236 buffer->pos[buffer->len - 1] = pos; 237 *end_ptr = p; 238 } 239 break; 240 #line 224 "hb-buffer-deserialize-text-unicode.hh" 241 } 242 } 243 244 _out: {} 245 } 246 247 #line 98 "hb-buffer-deserialize-text-unicode.rl" 248 249 250 *end_ptr = p; 251 252 return p == pe; 253 } 254 255 #endif /* HB_BUFFER_DESERIALIZE_TEXT_UNICODE_HH */