|
|
|
@ -32,38 +32,38 @@ |
|
|
|
|
const unsigned DEFAULT_FONT_SIZE = FONT_SIZE_UPEM; |
|
|
|
|
const unsigned SUBPIXEL_BITS = 0; |
|
|
|
|
|
|
|
|
|
struct output_buffer_t |
|
|
|
|
struct output_buffer_t : output_options_t |
|
|
|
|
{ |
|
|
|
|
void add_options (option_parser_t *parser) |
|
|
|
|
{ |
|
|
|
|
options.add_options (parser, hb_buffer_serialize_list_formats ()); |
|
|
|
|
output_options_t::add_options (parser, hb_buffer_serialize_list_formats ()); |
|
|
|
|
format.add_options (parser); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void init (hb_buffer_t *buffer, const font_options_t *font_opts) |
|
|
|
|
{ |
|
|
|
|
options.get_file_handle (); |
|
|
|
|
get_file_handle (); |
|
|
|
|
gs = g_string_new (nullptr); |
|
|
|
|
line_no = 0; |
|
|
|
|
font = hb_font_reference (font_opts->get_font ()); |
|
|
|
|
|
|
|
|
|
if (!options.output_format) |
|
|
|
|
output_format = HB_BUFFER_SERIALIZE_FORMAT_TEXT; |
|
|
|
|
if (!output_format) |
|
|
|
|
serialize_format = HB_BUFFER_SERIALIZE_FORMAT_TEXT; |
|
|
|
|
else |
|
|
|
|
output_format = hb_buffer_serialize_format_from_string (options.output_format, -1); |
|
|
|
|
serialize_format = hb_buffer_serialize_format_from_string (output_format, -1); |
|
|
|
|
/* An empty "output_format" parameter basically skips output generating.
|
|
|
|
|
* Useful for benchmarking. */ |
|
|
|
|
if ((!options.output_format || *options.output_format) && |
|
|
|
|
!hb_buffer_serialize_format_to_string (output_format)) |
|
|
|
|
if ((!output_format || *output_format) && |
|
|
|
|
!hb_buffer_serialize_format_to_string (serialize_format)) |
|
|
|
|
{ |
|
|
|
|
if (options.explicit_output_format) |
|
|
|
|
if (explicit_output_format) |
|
|
|
|
fail (false, "Unknown output format `%s'; supported formats are: %s", |
|
|
|
|
options.output_format, |
|
|
|
|
output_format, |
|
|
|
|
g_strjoinv ("/", const_cast<char**> (hb_buffer_serialize_list_formats ()))); |
|
|
|
|
else |
|
|
|
|
/* Just default to TEXT if not explicitly requested and the
|
|
|
|
|
* file extension is not recognized. */ |
|
|
|
|
output_format = HB_BUFFER_SERIALIZE_FORMAT_TEXT; |
|
|
|
|
serialize_format = HB_BUFFER_SERIALIZE_FORMAT_TEXT; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
unsigned int flags = HB_BUFFER_SERIALIZE_FLAG_DEFAULT; |
|
|
|
@ -79,7 +79,7 @@ struct output_buffer_t |
|
|
|
|
flags |= HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS; |
|
|
|
|
if (format.show_flags) |
|
|
|
|
flags |= HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS; |
|
|
|
|
format_flags = (hb_buffer_serialize_flags_t) flags; |
|
|
|
|
serialize_flags = (hb_buffer_serialize_flags_t) flags; |
|
|
|
|
|
|
|
|
|
if (format.trace) |
|
|
|
|
hb_buffer_set_message_func (buffer, message_func, this, nullptr); |
|
|
|
@ -92,13 +92,13 @@ struct output_buffer_t |
|
|
|
|
{ |
|
|
|
|
g_string_set_size (gs, 0); |
|
|
|
|
format.serialize_buffer_of_text (buffer, line_no, text, text_len, font, gs); |
|
|
|
|
fprintf (options.fp, "%s", gs->str); |
|
|
|
|
fprintf (fp, "%s", gs->str); |
|
|
|
|
} |
|
|
|
|
void error (const char *message) |
|
|
|
|
{ |
|
|
|
|
g_string_set_size (gs, 0); |
|
|
|
|
format.serialize_message (line_no, "error", message, gs); |
|
|
|
|
fprintf (options.fp, "%s", gs->str); |
|
|
|
|
fprintf (fp, "%s", gs->str); |
|
|
|
|
} |
|
|
|
|
void consume_glyphs (hb_buffer_t *buffer, |
|
|
|
|
const char *text, |
|
|
|
@ -107,8 +107,8 @@ struct output_buffer_t |
|
|
|
|
{ |
|
|
|
|
g_string_set_size (gs, 0); |
|
|
|
|
format.serialize_buffer_of_glyphs (buffer, line_no, text, text_len, font, |
|
|
|
|
output_format, format_flags, gs); |
|
|
|
|
fprintf (options.fp, "%s", gs->str); |
|
|
|
|
serialize_format, serialize_flags, gs); |
|
|
|
|
fprintf (fp, "%s", gs->str); |
|
|
|
|
} |
|
|
|
|
void finish (hb_buffer_t *buffer, const font_options_t *font_opts) |
|
|
|
|
{ |
|
|
|
@ -138,22 +138,21 @@ struct output_buffer_t |
|
|
|
|
g_string_set_size (gs, 0); |
|
|
|
|
format.serialize_line_no (line_no, gs); |
|
|
|
|
g_string_append_printf (gs, "trace: %s buffer: ", message); |
|
|
|
|
format.serialize (buffer, font, output_format, format_flags, gs); |
|
|
|
|
format.serialize (buffer, font, serialize_format, serialize_flags, gs); |
|
|
|
|
g_string_append_c (gs, '\n'); |
|
|
|
|
fprintf (options.fp, "%s", gs->str); |
|
|
|
|
fprintf (fp, "%s", gs->str); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
|
|
|
|
|
output_options_t options; |
|
|
|
|
shape_format_options_t format; |
|
|
|
|
|
|
|
|
|
GString *gs = nullptr; |
|
|
|
|
unsigned int line_no = 0; |
|
|
|
|
hb_font_t *font = nullptr; |
|
|
|
|
hb_buffer_serialize_format_t output_format = HB_BUFFER_SERIALIZE_FORMAT_INVALID; |
|
|
|
|
hb_buffer_serialize_flags_t format_flags = HB_BUFFER_SERIALIZE_FLAG_DEFAULT; |
|
|
|
|
hb_buffer_serialize_format_t serialize_format = HB_BUFFER_SERIALIZE_FORMAT_INVALID; |
|
|
|
|
hb_buffer_serialize_flags_t serialize_flags = HB_BUFFER_SERIALIZE_FLAG_DEFAULT; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
int |
|
|
|
|