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
4 * Copyright © 2004 Red Hat, Inc
5 * Copyright © 2006 Red Hat, Inc
6 * Copyright © 2007 Adrian Johnson
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.
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
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/
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.
31 * The Original Code is the cairo graphics library.
33 * The Initial Developer of the Original Code is University of Southern
37 * Kristian Høgsberg <krh@redhat.com>
38 * Carl Worth <cworth@cworth.org>
39 * Adrian Johnson <ajohnson@redneon.com>
42 #ifndef CAIRO_PDF_OPERATORS_H
43 #define CAIRO_PDF_OPERATORS_H
45 #include "cairo-compiler-private.h"
46 #include "cairo-error-private.h"
47 #include "cairo-types-private.h"
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.
54 #define PDF_GLYPH_BUFFER_SIZE 200
56 typedef cairo_status_t (*cairo_pdf_operators_use_font_subset_t) (unsigned int font_id,
57 unsigned int subset_id,
60 typedef struct _cairo_pdf_glyph {
61 unsigned int glyph_index;
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 */
76 cairo_bool_t is_new_text_object; /* text object started but matrix and font not yet selected */
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) */
85 cairo_bool_t is_latin;
87 double glyph_buf_x_pos;
88 cairo_pdf_glyph_t glyphs[PDF_GLYPH_BUFFER_SIZE];
91 cairo_bool_t has_line_style;
93 cairo_line_cap_t line_cap;
94 cairo_line_join_t line_join;
96 cairo_bool_t has_dashes;
97 } cairo_pdf_operators_t;
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);
105 cairo_private cairo_status_t
106 _cairo_pdf_operators_fini (cairo_pdf_operators_t *pdf_operators);
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,
114 _cairo_pdf_operators_set_stream (cairo_pdf_operators_t *pdf_operators,
115 cairo_output_stream_t *stream);
119 _cairo_pdf_operators_set_cairo_to_pdf_matrix (cairo_pdf_operators_t *pdf_operators,
120 cairo_matrix_t *cairo_to_pdf);
123 _cairo_pdf_operators_enable_actual_text (cairo_pdf_operators_t *pdf_operators,
124 cairo_bool_t enable);
126 cairo_private cairo_status_t
127 _cairo_pdf_operators_flush (cairo_pdf_operators_t *pdf_operators);
130 _cairo_pdf_operators_reset (cairo_pdf_operators_t *pdf_operators);
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);
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,
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);
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);
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);
162 cairo_private cairo_int_status_t
163 _cairo_pdf_operators_show_text_glyphs (cairo_pdf_operators_t *pdf_operators,
166 cairo_glyph_t *glyphs,
168 const cairo_text_cluster_t *clusters,
170 cairo_text_cluster_flags_t cluster_flags,
171 cairo_scaled_font_t *scaled_font);
173 #endif /* CAIRO_PDF_OPERATORS_H */