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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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-types-private.h"
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.
53 #define PDF_GLYPH_BUFFER_SIZE 200
55 typedef cairo_status_t (*cairo_pdf_operators_use_font_subset_t
) (unsigned int font_id
,
56 unsigned int subset_id
,
59 typedef struct _cairo_pdf_glyph
{
60 unsigned int glyph_index
;
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 */
75 cairo_bool_t is_new_text_object
; /* text object started but matrix and font not yet selected */
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) */
85 cairo_pdf_glyph_t glyphs
[PDF_GLYPH_BUFFER_SIZE
];
88 cairo_bool_t has_line_style
;
90 cairo_line_cap_t line_cap
;
91 cairo_line_join_t line_join
;
93 cairo_bool_t has_dashes
;
94 } cairo_pdf_operators_t
;
97 _cairo_pdf_operators_init (cairo_pdf_operators_t
*pdf_operators
,
98 cairo_output_stream_t
*stream
,
99 cairo_matrix_t
*cairo_to_pdf
,
100 cairo_scaled_font_subsets_t
*font_subsets
);
102 cairo_private cairo_status_t
103 _cairo_pdf_operators_fini (cairo_pdf_operators_t
*pdf_operators
);
106 _cairo_pdf_operators_set_font_subsets_callback (cairo_pdf_operators_t
*pdf_operators
,
107 cairo_pdf_operators_use_font_subset_t use_font_subset
,
111 _cairo_pdf_operators_set_stream (cairo_pdf_operators_t
*pdf_operators
,
112 cairo_output_stream_t
*stream
);
116 _cairo_pdf_operators_set_cairo_to_pdf_matrix (cairo_pdf_operators_t
*pdf_operators
,
117 cairo_matrix_t
*cairo_to_pdf
);
120 _cairo_pdf_operators_enable_actual_text (cairo_pdf_operators_t
*pdf_operators
,
121 cairo_bool_t enable
);
123 cairo_private cairo_status_t
124 _cairo_pdf_operators_flush (cairo_pdf_operators_t
*pdf_operators
);
127 _cairo_pdf_operators_reset (cairo_pdf_operators_t
*pdf_operators
);
129 cairo_private cairo_int_status_t
130 _cairo_pdf_operators_clip (cairo_pdf_operators_t
*pdf_operators
,
131 cairo_path_fixed_t
*path
,
132 cairo_fill_rule_t fill_rule
);
134 cairo_private cairo_int_status_t
135 _cairo_pdf_operators_emit_stroke_style (cairo_pdf_operators_t
*pdf_operators
,
136 cairo_stroke_style_t
*style
,
139 cairo_private cairo_int_status_t
140 _cairo_pdf_operators_stroke (cairo_pdf_operators_t
*pdf_operators
,
141 cairo_path_fixed_t
*path
,
142 cairo_stroke_style_t
*style
,
144 cairo_matrix_t
*ctm_inverse
);
146 cairo_private cairo_int_status_t
147 _cairo_pdf_operators_fill (cairo_pdf_operators_t
*pdf_operators
,
148 cairo_path_fixed_t
*path
,
149 cairo_fill_rule_t fill_rule
);
151 cairo_private cairo_int_status_t
152 _cairo_pdf_operators_fill_stroke (cairo_pdf_operators_t
*pdf_operators
,
153 cairo_path_fixed_t
*path
,
154 cairo_fill_rule_t fill_rule
,
155 cairo_stroke_style_t
*style
,
157 cairo_matrix_t
*ctm_inverse
);
159 cairo_private cairo_int_status_t
160 _cairo_pdf_operators_show_text_glyphs (cairo_pdf_operators_t
*pdf_operators
,
163 cairo_glyph_t
*glyphs
,
165 const cairo_text_cluster_t
*clusters
,
167 cairo_text_cluster_flags_t cluster_flags
,
168 cairo_scaled_font_t
*scaled_font
);
170 #endif /* CAIRO_PDF_OPERATORS_H */