Currently just announces lookup applications. Message-API *will* change.
hb-shape / hb-view are updated to print-out messages to stder if --debug
is specified.
hb_codepoint_t context[2][CONTEXT_LENGTH];
unsigned int context_len[2];
+ /* Debugging */
+ hb_buffer_message_func_t message_func;
+ void *message_data;
+ hb_destroy_func_t message_destroy;
+
/* Methods */
inline void clear_context (unsigned int side) { context_len[side] = 0; }
HB_INTERNAL void sort (unsigned int start, unsigned int end, int(*compar)(const hb_glyph_info_t *, const hb_glyph_info_t *));
+
+ inline bool messaging (void) { return unlikely (message_func); }
+ inline bool message (hb_font_t *font, const char *fmt, ...) HB_PRINTF_FUNC(3, 4)
+ {
+ if (!messaging ())
+ return true;
+ va_list ap;
+ va_start (ap, fmt);
+ bool ret = message_impl (font, fmt, ap);
+ va_end (ap);
+ return ret;
+ }
+ HB_INTERNAL bool message_impl (hb_font_t *font, const char *fmt, va_list ap) HB_PRINTF_FUNC(3, 0);
};
free (buffer->info);
free (buffer->pos);
+ if (buffer->message_destroy)
+ buffer->message_destroy (buffer->message_data);
free (buffer);
}
}
}
}
+
+/*
+ * Debugging.
+ */
+
+/**
+ * hb_buffer_set_message_func:
+ * @buffer: a buffer.
+ * @func: (closure user_data) (destroy destroy) (scope notified):
+ * @user_data:
+ * @destroy:
+ *
+ *
+ *
+ * Since: 1.1.3
+ **/
+void
+hb_buffer_set_message_func (hb_buffer_t *buffer,
+ hb_buffer_message_func_t func,
+ void *user_data, hb_destroy_func_t destroy)
+{
+ if (buffer->message_destroy)
+ buffer->message_destroy (buffer->message_data);
+
+ if (func) {
+ buffer->message_func = func;
+ buffer->message_data = user_data;
+ buffer->message_destroy = destroy;
+ } else {
+ buffer->message_func = NULL;
+ buffer->message_data = NULL;
+ buffer->message_destroy = NULL;
+ }
+}
+
+bool
+hb_buffer_t::message_impl (hb_font_t *font, const char *fmt, va_list ap)
+{
+ char buf[100];
+ vsnprintf (buf, sizeof (buf), fmt, ap);
+ return (bool) this->message_func (this, font, buf, this->message_data);
+}
hb_buffer_serialize_format_t format);
+/*
+ * Debugging.
+ */
+
+typedef hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer,
+ hb_font_t *font,
+ const char *message,
+ void *user_data);
+
+HB_EXTERN void
+hb_buffer_set_message_func (hb_buffer_t *buffer,
+ hb_buffer_message_func_t func,
+ void *user_data, hb_destroy_func_t destroy);
+
+
HB_END_DECLS
#endif /* HB_BUFFER_H */
const stage_map_t *stage = &stages[table_index][stage_index];
for (; i < stage->last_lookup; i++)
{
-#if 0
- char buf[4096];
- hb_buffer_serialize_glyphs (buffer, 0, buffer->len,
- buf, sizeof (buf), NULL,
- font,
- HB_BUFFER_SERIALIZE_FORMAT_TEXT,
- HB_BUFFER_SERIALIZE_FLAG_DEFAULT);
- printf ("buf: [%s]\n", buf);
-#endif
-
unsigned int lookup_index = lookups[table_index][i].index;
+ if (!buffer->message (font, "start lookup %d", lookup_index)) continue;
c.set_lookup_index (lookup_index);
c.set_lookup_mask (lookups[table_index][i].mask);
c.set_auto_zwj (lookups[table_index][i].auto_zwj);
apply_string<Proxy> (&c,
proxy.table.get_lookup (lookup_index),
proxy.accels[lookup_index]);
+ (void) buffer->message (font, "end lookup %d", lookup_index);
}
if (stage->pause_func)
return t;
}
+static hb_bool_t
+message_func (hb_buffer_t *buffer,
+ hb_font_t *font,
+ const char *message,
+ void *user_data)
+{
+ fprintf (stderr, "HB: %s\n", message);
+ char buf[4096];
+ hb_buffer_serialize_glyphs (buffer, 0, hb_buffer_get_length (buffer),
+ buf, sizeof (buf), NULL,
+ font,
+ HB_BUFFER_SERIALIZE_FORMAT_TEXT,
+ HB_BUFFER_SERIALIZE_FLAG_DEFAULT);
+ printf ("HB: buffer [%s]\n", buf);
+ return true;
+}
template <typename consumer_t, int default_font_size, int subpixel_bits>
struct main_font_text_t
consumer.init (&font_opts);
hb_buffer_t *buffer = hb_buffer_create ();
+ if (debug)
+ hb_buffer_set_message_func (buffer, message_func, NULL, NULL);
unsigned int text_len;
const char *text;
while ((text = input.get_line (&text_len)))