Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
  2. /* cairo - a vector graphics library with display and print output
  3.  *
  4.  * Copyright © 2004 Red Hat, Inc
  5.  * Copyright © 2006 Red Hat, Inc
  6.  * Copyright © 2007 Adrian Johnson
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it either under the terms of the GNU Lesser General Public
  10.  * License version 2.1 as published by the Free Software Foundation
  11.  * (the "LGPL") or, at your option, under the terms of the Mozilla
  12.  * Public License Version 1.1 (the "MPL"). If you do not alter this
  13.  * notice, a recipient may use your version of this file under either
  14.  * the MPL or the LGPL.
  15.  *
  16.  * You should have received a copy of the LGPL along with this library
  17.  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
  18.  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
  19.  * You should have received a copy of the MPL along with this library
  20.  * in the file COPYING-MPL-1.1
  21.  *
  22.  * The contents of this file are subject to the Mozilla Public License
  23.  * Version 1.1 (the "License"); you may not use this file except in
  24.  * compliance with the License. You may obtain a copy of the License at
  25.  * http://www.mozilla.org/MPL/
  26.  *
  27.  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  28.  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  29.  * the specific language governing rights and limitations.
  30.  *
  31.  * The Original Code is the cairo graphics library.
  32.  *
  33.  * The Initial Developer of the Original Code is University of Southern
  34.  * California.
  35.  *
  36.  * Contributor(s):
  37.  *      Kristian Høgsberg <krh@redhat.com>
  38.  *      Carl Worth <cworth@cworth.org>
  39.  *      Adrian Johnson <ajohnson@redneon.com>
  40.  */
  41.  
  42. #ifndef CAIRO_PDF_OPERATORS_H
  43. #define CAIRO_PDF_OPERATORS_H
  44.  
  45. #include "cairo-compiler-private.h"
  46. #include "cairo-types-private.h"
  47.  
  48. /* The glyph buffer size is based on the expected maximum glyphs in a
  49.  * line so that an entire line can be emitted in as one string. If the
  50.  * glyphs in a line exceeds this size the only downside is the slight
  51.  * overhead of emitting two strings.
  52.  */
  53. #define PDF_GLYPH_BUFFER_SIZE 200
  54.  
  55. typedef cairo_status_t (*cairo_pdf_operators_use_font_subset_t) (unsigned int  font_id,
  56.                                                                  unsigned int  subset_id,
  57.                                                                  void         *closure);
  58.  
  59. typedef struct _cairo_pdf_glyph {
  60.     unsigned int glyph_index;
  61.     double x_position;
  62.     double x_advance;
  63. } cairo_pdf_glyph_t;
  64.  
  65. typedef struct _cairo_pdf_operators {
  66.     cairo_output_stream_t *stream;
  67.     cairo_matrix_t cairo_to_pdf;
  68.     cairo_scaled_font_subsets_t *font_subsets;
  69.     cairo_pdf_operators_use_font_subset_t use_font_subset;
  70.     void *use_font_subset_closure;
  71.     cairo_bool_t use_actual_text;
  72.     cairo_bool_t in_text_object; /* inside BT/ET pair */
  73.  
  74.     /* PDF text state */
  75.     cairo_bool_t is_new_text_object; /* text object started but matrix and font not yet selected */
  76.     unsigned int font_id;
  77.     unsigned int subset_id;
  78.     cairo_matrix_t text_matrix; /* PDF text matrix (Tlm in the PDF reference) */
  79.     cairo_matrix_t cairo_to_pdftext; /* translate cairo coords to PDF text space */
  80.     cairo_matrix_t font_matrix_inverse;
  81.     double cur_x; /* Current position in PDF text space (Tm in the PDF reference) */
  82.     double cur_y;
  83.     int hex_width;
  84.     int num_glyphs;
  85.     double glyph_buf_x_pos;
  86.     cairo_pdf_glyph_t glyphs[PDF_GLYPH_BUFFER_SIZE];
  87.  
  88.     /* PDF line style */
  89.     cairo_bool_t         has_line_style;
  90.     double               line_width;
  91.     cairo_line_cap_t     line_cap;
  92.     cairo_line_join_t    line_join;
  93.     double               miter_limit;
  94.     cairo_bool_t         has_dashes;
  95. } cairo_pdf_operators_t;
  96.  
  97. cairo_private void
  98. _cairo_pdf_operators_init (cairo_pdf_operators_t       *pdf_operators,
  99.                            cairo_output_stream_t       *stream,
  100.                            cairo_matrix_t              *cairo_to_pdf,
  101.                            cairo_scaled_font_subsets_t *font_subsets);
  102.  
  103. cairo_private cairo_status_t
  104. _cairo_pdf_operators_fini (cairo_pdf_operators_t       *pdf_operators);
  105.  
  106. cairo_private void
  107. _cairo_pdf_operators_set_font_subsets_callback (cairo_pdf_operators_t                *pdf_operators,
  108.                                                 cairo_pdf_operators_use_font_subset_t use_font_subset,
  109.                                                 void                                 *closure);
  110.  
  111. cairo_private void
  112. _cairo_pdf_operators_set_stream (cairo_pdf_operators_t   *pdf_operators,
  113.                                  cairo_output_stream_t   *stream);
  114.  
  115.  
  116. cairo_private void
  117. _cairo_pdf_operators_set_cairo_to_pdf_matrix (cairo_pdf_operators_t *pdf_operators,
  118.                                               cairo_matrix_t        *cairo_to_pdf);
  119.  
  120. cairo_private void
  121. _cairo_pdf_operators_enable_actual_text (cairo_pdf_operators_t *pdf_operators,
  122.                                          cairo_bool_t           enable);
  123.  
  124. cairo_private cairo_status_t
  125. _cairo_pdf_operators_flush (cairo_pdf_operators_t        *pdf_operators);
  126.  
  127. cairo_private void
  128. _cairo_pdf_operators_reset (cairo_pdf_operators_t        *pdf_operators);
  129.  
  130. cairo_private cairo_int_status_t
  131. _cairo_pdf_operators_clip (cairo_pdf_operators_t        *pdf_operators,
  132.                            cairo_path_fixed_t           *path,
  133.                            cairo_fill_rule_t             fill_rule);
  134.  
  135. cairo_private cairo_int_status_t
  136. _cairo_pdf_operators_emit_stroke_style (cairo_pdf_operators_t           *pdf_operators,
  137.                                         const cairo_stroke_style_t      *style,
  138.                                         double                           scale);
  139.  
  140. cairo_private cairo_int_status_t
  141. _cairo_pdf_operators_stroke (cairo_pdf_operators_t      *pdf_operators,
  142.                              cairo_path_fixed_t         *path,
  143.                              const cairo_stroke_style_t *style,
  144.                              const cairo_matrix_t       *ctm,
  145.                              const cairo_matrix_t       *ctm_inverse);
  146.  
  147. cairo_private cairo_int_status_t
  148. _cairo_pdf_operators_fill (cairo_pdf_operators_t        *pdf_operators,
  149.                            cairo_path_fixed_t           *path,
  150.                            cairo_fill_rule_t            fill_rule);
  151.  
  152. cairo_private cairo_int_status_t
  153. _cairo_pdf_operators_fill_stroke (cairo_pdf_operators_t         *pdf_operators,
  154.                                   cairo_path_fixed_t            *path,
  155.                                   cairo_fill_rule_t              fill_rule,
  156.                                   const cairo_stroke_style_t    *style,
  157.                                   const cairo_matrix_t          *ctm,
  158.                                   const cairo_matrix_t          *ctm_inverse);
  159.  
  160. cairo_private cairo_int_status_t
  161. _cairo_pdf_operators_show_text_glyphs (cairo_pdf_operators_t      *pdf_operators,
  162.                                        const char                 *utf8,
  163.                                        int                         utf8_len,
  164.                                        cairo_glyph_t              *glyphs,
  165.                                        int                         num_glyphs,
  166.                                        const cairo_text_cluster_t *clusters,
  167.                                        int                         num_clusters,
  168.                                        cairo_text_cluster_flags_t  cluster_flags,
  169.                                        cairo_scaled_font_t        *scaled_font);
  170.  
  171. #endif /* CAIRO_PDF_OPERATORS_H */
  172.