2 * Copyright © 2013 Google, Inc.
4 * This is part of HarfBuzz, a text shaping library.
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
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
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
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
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 * Google Author(s): Behdad Esfahbod
27 #ifndef HB_BUFFER_DESERIALIZE_TEXT_UNICODE_HH
28 #define HB_BUFFER_DESERIALIZE_TEXT_UNICODE_HH
34 machine deserialize_text_unicode;
35 alphtype unsigned char;
39 hb_memset (&info, 0, sizeof (info));
43 buffer->add_info (info);
44 if (unlikely (!buffer->successful))
46 if (buffer->have_positions)
47 buffer->pos[buffer->len - 1] = pos;
55 action parse_hexdigits {if (!parse_hex (tok, p, &info.codepoint )) return false; }
57 action parse_cluster { if (!parse_uint (tok, p, &info.cluster )) return false; }
59 unum = '0' | [1-9] digit*;
62 cluster = '=' (unum >tok %parse_cluster);
64 unicode = [Uu] '+'? xdigit+ >tok %parse_hexdigits;
75 unicodes = unicode_item (space* '|' space* unicode_item)* space*;
77 main := space* unicodes;
82 _hb_buffer_deserialize_text_unicode (hb_buffer_t *buffer,
88 const char *p = buf, *pe = buf + buf_len, *eof = pe, *orig_pe = pe;
90 while (p < pe && ISSPACE (*p))
92 if (p < pe && *p == (buffer->len ? '|' : '<'))
95 const char *end = strchr ((char *) p, '>');
100 end = strrchr ((char *) p, '|');
108 const char *tok = nullptr;
110 hb_glyph_info_t info = {0};
111 const hb_glyph_position_t pos = {0};
117 if (pe < orig_pe && *pe == '>')
129 #endif /* HB_BUFFER_DESERIALIZE_TEXT_UNICODE_HH */