|
Packit |
874993 |
/*
|
|
Packit |
874993 |
* Copyright © 2011 Google, Inc.
|
|
Packit |
874993 |
*
|
|
Packit |
874993 |
* This is part of HarfBuzz, a text shaping library.
|
|
Packit |
874993 |
*
|
|
Packit |
874993 |
* Permission is hereby granted, without written agreement and without
|
|
Packit |
874993 |
* license or royalty fees, to use, copy, modify, and distribute this
|
|
Packit |
874993 |
* software and its documentation for any purpose, provided that the
|
|
Packit |
874993 |
* above copyright notice and the following two paragraphs appear in
|
|
Packit |
874993 |
* all copies of this software.
|
|
Packit |
874993 |
*
|
|
Packit |
874993 |
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
|
Packit |
874993 |
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
Packit |
874993 |
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
|
Packit |
874993 |
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
Packit |
874993 |
* DAMAGE.
|
|
Packit |
874993 |
*
|
|
Packit |
874993 |
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
|
Packit |
874993 |
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
Packit |
874993 |
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
Packit |
874993 |
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
|
Packit |
874993 |
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
Packit |
874993 |
*
|
|
Packit |
874993 |
* Google Author(s): Behdad Esfahbod
|
|
Packit |
874993 |
*/
|
|
Packit |
874993 |
|
|
Packit |
874993 |
#include "options.hh"
|
|
Packit |
874993 |
#include "helper-cairo.hh"
|
|
Packit |
874993 |
|
|
Packit |
874993 |
#ifndef VIEW_CAIRO_HH
|
|
Packit |
874993 |
#define VIEW_CAIRO_HH
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
struct view_cairo_t
|
|
Packit |
874993 |
{
|
|
Packit |
874993 |
view_cairo_t (option_parser_t *parser)
|
|
Packit |
874993 |
: output_options (parser, helper_cairo_supported_formats),
|
|
Packit |
874993 |
view_options (parser),
|
|
Packit |
874993 |
direction (HB_DIRECTION_INVALID),
|
|
Packit |
874993 |
lines (0), scale_bits (0) {}
|
|
Packit |
874993 |
~view_cairo_t (void) {
|
|
Packit |
874993 |
if (debug)
|
|
Packit |
874993 |
cairo_debug_reset_static_data ();
|
|
Packit |
874993 |
}
|
|
Packit |
874993 |
|
|
Packit |
874993 |
void init (hb_buffer_t *buffer, const font_options_t *font_opts)
|
|
Packit |
874993 |
{
|
|
Packit |
874993 |
lines = g_array_new (false, false, sizeof (helper_cairo_line_t));
|
|
Packit |
874993 |
scale_bits = -font_opts->subpixel_bits;
|
|
Packit |
874993 |
}
|
|
Packit |
874993 |
void new_line (void)
|
|
Packit |
874993 |
{
|
|
Packit |
874993 |
}
|
|
Packit |
874993 |
void consume_text (hb_buffer_t *buffer,
|
|
Packit |
874993 |
const char *text,
|
|
Packit |
874993 |
unsigned int text_len,
|
|
Packit |
874993 |
hb_bool_t utf8_clusters)
|
|
Packit |
874993 |
{
|
|
Packit |
874993 |
}
|
|
Packit |
874993 |
void shape_failed (hb_buffer_t *buffer,
|
|
Packit |
874993 |
const char *text,
|
|
Packit |
874993 |
unsigned int text_len,
|
|
Packit |
874993 |
hb_bool_t utf8_clusters)
|
|
Packit |
874993 |
{
|
|
Packit |
874993 |
fail (false, "all shapers failed");
|
|
Packit |
874993 |
}
|
|
Packit |
874993 |
void consume_glyphs (hb_buffer_t *buffer,
|
|
Packit |
874993 |
const char *text,
|
|
Packit |
874993 |
unsigned int text_len,
|
|
Packit |
874993 |
hb_bool_t utf8_clusters)
|
|
Packit |
874993 |
{
|
|
Packit |
874993 |
direction = hb_buffer_get_direction (buffer);
|
|
Packit |
874993 |
helper_cairo_line_t l;
|
|
Packit |
874993 |
helper_cairo_line_from_buffer (&l, buffer, text, text_len, scale_bits, utf8_clusters);
|
|
Packit |
874993 |
g_array_append_val (lines, l);
|
|
Packit |
874993 |
}
|
|
Packit |
874993 |
void finish (hb_buffer_t *buffer, const font_options_t *font_opts)
|
|
Packit |
874993 |
{
|
|
Packit |
874993 |
render (font_opts);
|
|
Packit |
874993 |
|
|
Packit |
874993 |
for (unsigned int i = 0; i < lines->len; i++) {
|
|
Packit |
874993 |
helper_cairo_line_t &line = g_array_index (lines, helper_cairo_line_t, i);
|
|
Packit |
874993 |
line.finish ();
|
|
Packit |
874993 |
}
|
|
Packit |
874993 |
#if GLIB_CHECK_VERSION (2, 22, 0)
|
|
Packit |
874993 |
g_array_unref (lines);
|
|
Packit |
874993 |
#else
|
|
Packit |
874993 |
g_array_free (lines, TRUE);
|
|
Packit |
874993 |
#endif
|
|
Packit |
874993 |
}
|
|
Packit |
874993 |
|
|
Packit |
874993 |
protected:
|
|
Packit |
874993 |
|
|
Packit |
874993 |
output_options_t output_options;
|
|
Packit |
874993 |
view_options_t view_options;
|
|
Packit |
874993 |
|
|
Packit |
874993 |
void render (const font_options_t *font_opts);
|
|
Packit |
874993 |
|
|
Packit |
874993 |
hb_direction_t direction; // Remove this, make segment_properties accessible
|
|
Packit |
874993 |
GArray *lines;
|
|
Packit |
874993 |
int scale_bits;
|
|
Packit |
874993 |
};
|
|
Packit |
874993 |
|
|
Packit |
874993 |
#endif
|