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_HH
28 #define HB_BUFFER_DESERIALIZE_TEXT_HH
30 #include "hb-private.hh"
34 machine deserialize_text;
35 alphtype unsigned char;
39 memset (&info, 0, sizeof (info));
40 memset (&pos , 0, sizeof (pos ));
44 buffer->add_info (info);
47 buffer->pos[buffer->len - 1] = pos;
56 if (!hb_font_glyph_from_string (font,
62 action parse_cluster { if (!parse_uint (tok, p, &info.cluster )) return false; }
63 action parse_x_offset { if (!parse_int (tok, p, &pos.x_offset )) return false; }
64 action parse_y_offset { if (!parse_int (tok, p, &pos.y_offset )) return false; }
65 action parse_x_advance { if (!parse_int (tok, p, &pos.x_advance)) return false; }
66 action parse_y_advance { if (!parse_int (tok, p, &pos.y_advance)) return false; }
68 unum = '0' | [1-9] digit*;
72 glyph_name = alpha (alnum|'_'|'.'|'-')*;
74 glyph = (glyph_id | glyph_name) >tok %parse_glyph;
75 cluster = '=' (unum >tok %parse_cluster);
76 offsets = '@' (num >tok %parse_x_offset) ',' (num >tok %parse_y_offset );
77 advances= '+' (num >tok %parse_x_advance) (',' (num >tok %parse_y_advance))?;
89 main := space* item (space* '|' space* item)* space* ('|'|']')?;
94 _hb_buffer_deserialize_glyphs_text (hb_buffer_t *buffer,
100 const char *p = buf, *pe = buf + buf_len;
102 /* Ensure we have positions. */
103 (void) hb_buffer_get_glyph_positions (buffer, NULL);
105 while (p < pe && ISSPACE (*p))
107 if (p < pe && *p == (buffer->len ? '|' : '['))
112 const char *eof = pe, *tok = NULL;
114 hb_glyph_info_t info = {0};
115 hb_glyph_position_t pos = {0};
123 return p == pe && *(p-1) != ']';
126 #endif /* HB_BUFFER_DESERIALIZE_TEXT_HH */