Tizen 2.0 Release
[framework/graphics/cairo.git] / src / cairo-pdf-operators-private.h
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-error-private.h"
47 #include "cairo-types-private.h"
48
49 /* The glyph buffer size is based on the expected maximum glyphs in a
50  * line so that an entire line can be emitted in as one string. If the
51  * glyphs in a line exceeds this size the only downside is the slight
52  * overhead of emitting two strings.
53  */
54 #define PDF_GLYPH_BUFFER_SIZE 200
55
56 typedef cairo_status_t (*cairo_pdf_operators_use_font_subset_t) (unsigned int  font_id,
57                                                                  unsigned int  subset_id,
58                                                                  void         *closure);
59
60 typedef struct _cairo_pdf_glyph {
61     unsigned int glyph_index;
62     double x_position;
63     double x_advance;
64 } cairo_pdf_glyph_t;
65
66 typedef struct _cairo_pdf_operators {
67     cairo_output_stream_t *stream;
68     cairo_matrix_t cairo_to_pdf;
69     cairo_scaled_font_subsets_t *font_subsets;
70     cairo_pdf_operators_use_font_subset_t use_font_subset;
71     void *use_font_subset_closure;
72     cairo_bool_t use_actual_text;
73     cairo_bool_t in_text_object; /* inside BT/ET pair */
74
75     /* PDF text state */
76     cairo_bool_t is_new_text_object; /* text object started but matrix and font not yet selected */
77     unsigned int font_id;
78     unsigned int subset_id;
79     cairo_matrix_t text_matrix; /* PDF text matrix (Tlm in the PDF reference) */
80     cairo_matrix_t cairo_to_pdftext; /* translate cairo coords to PDF text space */
81     cairo_matrix_t font_matrix_inverse;
82     double cur_x; /* Current position in PDF text space (Tm in the PDF reference) */
83     double cur_y;
84     int hex_width;
85     cairo_bool_t is_latin;
86     int num_glyphs;
87     double glyph_buf_x_pos;
88     cairo_pdf_glyph_t glyphs[PDF_GLYPH_BUFFER_SIZE];
89
90     /* PDF line style */
91     cairo_bool_t         has_line_style;
92     double               line_width;
93     cairo_line_cap_t     line_cap;
94     cairo_line_join_t    line_join;
95     double               miter_limit;
96     cairo_bool_t         has_dashes;
97 } cairo_pdf_operators_t;
98
99 cairo_private void
100 _cairo_pdf_operators_init (cairo_pdf_operators_t       *pdf_operators,
101                            cairo_output_stream_t       *stream,
102                            cairo_matrix_t              *cairo_to_pdf,
103                            cairo_scaled_font_subsets_t *font_subsets);
104
105 cairo_private cairo_status_t
106 _cairo_pdf_operators_fini (cairo_pdf_operators_t       *pdf_operators);
107
108 cairo_private void
109 _cairo_pdf_operators_set_font_subsets_callback (cairo_pdf_operators_t                *pdf_operators,
110                                                 cairo_pdf_operators_use_font_subset_t use_font_subset,
111                                                 void                                 *closure);
112
113 cairo_private void
114 _cairo_pdf_operators_set_stream (cairo_pdf_operators_t   *pdf_operators,
115                                  cairo_output_stream_t   *stream);
116
117
118 cairo_private void
119 _cairo_pdf_operators_set_cairo_to_pdf_matrix (cairo_pdf_operators_t *pdf_operators,
120                                               cairo_matrix_t        *cairo_to_pdf);
121
122 cairo_private void
123 _cairo_pdf_operators_enable_actual_text (cairo_pdf_operators_t *pdf_operators,
124                                          cairo_bool_t           enable);
125
126 cairo_private cairo_status_t
127 _cairo_pdf_operators_flush (cairo_pdf_operators_t        *pdf_operators);
128
129 cairo_private void
130 _cairo_pdf_operators_reset (cairo_pdf_operators_t        *pdf_operators);
131
132 cairo_private cairo_int_status_t
133 _cairo_pdf_operators_clip (cairo_pdf_operators_t        *pdf_operators,
134                            const cairo_path_fixed_t     *path,
135                            cairo_fill_rule_t             fill_rule);
136
137 cairo_private cairo_int_status_t
138 _cairo_pdf_operators_emit_stroke_style (cairo_pdf_operators_t           *pdf_operators,
139                                         const cairo_stroke_style_t      *style,
140                                         double                           scale);
141
142 cairo_private cairo_int_status_t
143 _cairo_pdf_operators_stroke (cairo_pdf_operators_t      *pdf_operators,
144                              const cairo_path_fixed_t   *path,
145                              const cairo_stroke_style_t *style,
146                              const cairo_matrix_t       *ctm,
147                              const cairo_matrix_t       *ctm_inverse);
148
149 cairo_private cairo_int_status_t
150 _cairo_pdf_operators_fill (cairo_pdf_operators_t        *pdf_operators,
151                            const cairo_path_fixed_t     *path,
152                            cairo_fill_rule_t            fill_rule);
153
154 cairo_private cairo_int_status_t
155 _cairo_pdf_operators_fill_stroke (cairo_pdf_operators_t         *pdf_operators,
156                                   const cairo_path_fixed_t      *path,
157                                   cairo_fill_rule_t              fill_rule,
158                                   const cairo_stroke_style_t    *style,
159                                   const cairo_matrix_t          *ctm,
160                                   const cairo_matrix_t          *ctm_inverse);
161
162 cairo_private cairo_int_status_t
163 _cairo_pdf_operators_show_text_glyphs (cairo_pdf_operators_t      *pdf_operators,
164                                        const char                 *utf8,
165                                        int                         utf8_len,
166                                        cairo_glyph_t              *glyphs,
167                                        int                         num_glyphs,
168                                        const cairo_text_cluster_t *clusters,
169                                        int                         num_clusters,
170                                        cairo_text_cluster_flags_t  cluster_flags,
171                                        cairo_scaled_font_t        *scaled_font);
172
173 #endif /* CAIRO_PDF_OPERATORS_H */