2 * Copyright © 2011 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
30 #include "hb-private.hh"
32 #include "helper-cairo.hh"
37 view_cairo_t (option_parser_t *parser)
38 : output_options (parser, helper_cairo_supported_formats),
39 view_options (parser),
40 direction (HB_DIRECTION_INVALID),
41 lines (0), scale_bits (0) {}
42 ~view_cairo_t (void) {
43 cairo_debug_reset_static_data ();
46 void init (hb_buffer_t *buffer, const font_options_t *font_opts)
48 lines = g_array_new (false, false, sizeof (helper_cairo_line_t));
49 scale_bits = -font_opts->subpixel_bits;
54 void consume_text (hb_buffer_t *buffer,
56 unsigned int text_len,
57 hb_bool_t utf8_clusters)
60 void error (const char *message)
62 g_printerr ("%s: %s\n", g_get_prgname (), message);
64 void consume_glyphs (hb_buffer_t *buffer,
66 unsigned int text_len,
67 hb_bool_t utf8_clusters)
69 direction = hb_buffer_get_direction (buffer);
70 helper_cairo_line_t l;
71 helper_cairo_line_from_buffer (&l, buffer, text, text_len, scale_bits, utf8_clusters);
72 g_array_append_val (lines, l);
74 void finish (hb_buffer_t *buffer, const font_options_t *font_opts)
78 for (unsigned int i = 0; i < lines->len; i++) {
79 helper_cairo_line_t &line = g_array_index (lines, helper_cairo_line_t, i);
82 #if GLIB_CHECK_VERSION (2, 22, 0)
83 g_array_unref (lines);
85 g_array_free (lines, TRUE);
91 output_options_t output_options;
92 view_options_t view_options;
94 void render (const font_options_t *font_opts);
96 hb_direction_t direction; // Remove this, make segment_properties accessible