5 otl_string_ensure( OTL_String string,
9 count += string->length;
11 if ( count > string->capacity )
13 OTL_UInt old_count = string->capacity;
14 OTL_UInt new_count = old_count;
15 OTL_Memory memory = parser->memory;
17 while ( new_count < count )
18 new_count += (new_count >> 1) + 16;
20 if ( OTL_MEM_RENEW_ARRAY( string->glyphs, old_count, new_count ) )
21 otl_parser_error( parser, OTL_Parse_Err_Memory );
23 string->capacity = new_count;
27 #define OTL_STRING_ENSURE(str,count,parser) \
29 if ( (str)->length + (count) > (str)>capacity ) \
30 otl_string_ensure( str, count, parser ); \
34 OTL_LOCALDEF( OTL_UInt )
35 otl_parser_get_gindex( OTL_Parser parser )
37 OTL_String in = parser->str_in;
39 if ( in->cursor >= in->num_glyphs )
40 otl_parser_error( parser, OTL_Err_Parser_Internal );
42 return in->str[ in->cursor ].gindex;
47 otl_parser_error( OTL_Parser parser,
48 OTL_ParseError error; )
50 parser->error = error;
51 otl_longjmp( parser->jump_buffer, 1 );
54 #define OTL_PARSER_UNCOVERED(x) otl_parser_error( x, OTL_Parse_Err_UncoveredGlyph );
57 otl_parser_check_property( OTL_Parser parser,
60 OTL_UInt *aproperty );
63 otl_parser_replace_1( OTL_Parser parser,
66 OTL_String in = parser->str_in;
67 OTL_String out = parser->str_out;
68 OTL_StringGlyph glyph, in_glyph;
74 in->cursor >= in->length )
76 /* report as internal error, since these should */
78 otl_parser_error( parser, OTL_Err_Parse_Internal );
81 OTL_STRING_ENSURE( out, 1, parser );
82 glyph = out->glyphs + out->length;
83 in_glyph = in->glyphs + in->cursor;
85 glyph->gindex = gindex;
86 glyph->property = in_glyph->property;
87 glyph->lig_component = in_glyph->lig_component;
88 glyph->lig_id = in_glyph->lig_id;
91 out->cursor = out->length;
96 otl_parser_replace_n( OTL_Parser parser,
100 OTL_UInt lig_component, lig_id, property;
101 OTL_String in = parser->str_in;
102 OTL_String out = parser->str_out;
103 OTL_StringGlyph glyph, in_glyph;
104 OTL_Bytes p = indices;
110 in->cursor >= in->length )
112 /* report as internal error, since these should */
113 /* never happen !! */
114 otl_parser_error( parser, OTL_Err_Parse_Internal );
117 OTL_STRING_ENSURE( out, count, parser );
118 glyph = out->glyphs + out->length;
119 in_glyph = in->glyphs + in->cursor;
121 glyph->gindex = gindex;
123 lig_component = in_glyph->lig_component;
124 lig_id = in_glyph->lid_id;
125 property = in_glyph->property;
127 for ( ; count > 0; count-- )
129 glyph->gindex = OTL_NEXT_USHORT(p);
130 glyph->property = property;
131 glyph->lig_component = lig_component;
132 glyph->lig_id = lig_id;
137 out->cursor = out->length;