Rev 1892 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1892 | serge | 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 |
||
38 | * Carl Worth |
||
39 | * Adrian Johnson |
||
40 | */ |
||
41 | |||
42 | #ifndef CAIRO_PDF_OPERATORS_H |
||
43 | #define CAIRO_PDF_OPERATORS_H |
||
44 | |||
45 | #include "cairo-compiler-private.h" |
||
3959 | Serge | 46 | #include "cairo-error-private.h" |
1892 | serge | 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 | |||
3959 | Serge | 56 | typedef cairo_int_status_t |
57 | (*cairo_pdf_operators_use_font_subset_t) (unsigned int font_id, |
||
58 | unsigned int subset_id, |
||
59 | void *closure); |
||
1892 | serge | 60 | |
61 | typedef struct _cairo_pdf_glyph { |
||
62 | unsigned int glyph_index; |
||
63 | double x_position; |
||
64 | double x_advance; |
||
65 | } cairo_pdf_glyph_t; |
||
66 | |||
67 | typedef struct _cairo_pdf_operators { |
||
68 | cairo_output_stream_t *stream; |
||
69 | cairo_matrix_t cairo_to_pdf; |
||
70 | cairo_scaled_font_subsets_t *font_subsets; |
||
71 | cairo_pdf_operators_use_font_subset_t use_font_subset; |
||
72 | void *use_font_subset_closure; |
||
73 | cairo_bool_t use_actual_text; |
||
74 | cairo_bool_t in_text_object; /* inside BT/ET pair */ |
||
75 | |||
76 | /* PDF text state */ |
||
77 | cairo_bool_t is_new_text_object; /* text object started but matrix and font not yet selected */ |
||
78 | unsigned int font_id; |
||
79 | unsigned int subset_id; |
||
80 | cairo_matrix_t text_matrix; /* PDF text matrix (Tlm in the PDF reference) */ |
||
81 | cairo_matrix_t cairo_to_pdftext; /* translate cairo coords to PDF text space */ |
||
82 | cairo_matrix_t font_matrix_inverse; |
||
83 | double cur_x; /* Current position in PDF text space (Tm in the PDF reference) */ |
||
84 | double cur_y; |
||
85 | int hex_width; |
||
3959 | Serge | 86 | cairo_bool_t is_latin; |
1892 | serge | 87 | int num_glyphs; |
88 | double glyph_buf_x_pos; |
||
89 | cairo_pdf_glyph_t glyphs[PDF_GLYPH_BUFFER_SIZE]; |
||
90 | |||
91 | /* PDF line style */ |
||
92 | cairo_bool_t has_line_style; |
||
93 | double line_width; |
||
94 | cairo_line_cap_t line_cap; |
||
95 | cairo_line_join_t line_join; |
||
96 | double miter_limit; |
||
97 | cairo_bool_t has_dashes; |
||
98 | } cairo_pdf_operators_t; |
||
99 | |||
100 | cairo_private void |
||
101 | _cairo_pdf_operators_init (cairo_pdf_operators_t *pdf_operators, |
||
102 | cairo_output_stream_t *stream, |
||
103 | cairo_matrix_t *cairo_to_pdf, |
||
104 | cairo_scaled_font_subsets_t *font_subsets); |
||
105 | |||
106 | cairo_private cairo_status_t |
||
107 | _cairo_pdf_operators_fini (cairo_pdf_operators_t *pdf_operators); |
||
108 | |||
109 | cairo_private void |
||
110 | _cairo_pdf_operators_set_font_subsets_callback (cairo_pdf_operators_t *pdf_operators, |
||
111 | cairo_pdf_operators_use_font_subset_t use_font_subset, |
||
112 | void *closure); |
||
113 | |||
114 | cairo_private void |
||
115 | _cairo_pdf_operators_set_stream (cairo_pdf_operators_t *pdf_operators, |
||
116 | cairo_output_stream_t *stream); |
||
117 | |||
118 | |||
119 | cairo_private void |
||
120 | _cairo_pdf_operators_set_cairo_to_pdf_matrix (cairo_pdf_operators_t *pdf_operators, |
||
121 | cairo_matrix_t *cairo_to_pdf); |
||
122 | |||
123 | cairo_private void |
||
124 | _cairo_pdf_operators_enable_actual_text (cairo_pdf_operators_t *pdf_operators, |
||
125 | cairo_bool_t enable); |
||
126 | |||
127 | cairo_private cairo_status_t |
||
128 | _cairo_pdf_operators_flush (cairo_pdf_operators_t *pdf_operators); |
||
129 | |||
130 | cairo_private void |
||
131 | _cairo_pdf_operators_reset (cairo_pdf_operators_t *pdf_operators); |
||
132 | |||
133 | cairo_private cairo_int_status_t |
||
3959 | Serge | 134 | _cairo_pdf_operators_clip (cairo_pdf_operators_t *pdf_operators, |
135 | const cairo_path_fixed_t *path, |
||
1892 | serge | 136 | cairo_fill_rule_t fill_rule); |
137 | |||
138 | cairo_private cairo_int_status_t |
||
139 | _cairo_pdf_operators_emit_stroke_style (cairo_pdf_operators_t *pdf_operators, |
||
140 | const cairo_stroke_style_t *style, |
||
141 | double scale); |
||
142 | |||
143 | cairo_private cairo_int_status_t |
||
144 | _cairo_pdf_operators_stroke (cairo_pdf_operators_t *pdf_operators, |
||
3959 | Serge | 145 | const cairo_path_fixed_t *path, |
1892 | serge | 146 | const cairo_stroke_style_t *style, |
147 | const cairo_matrix_t *ctm, |
||
148 | const cairo_matrix_t *ctm_inverse); |
||
149 | |||
150 | cairo_private cairo_int_status_t |
||
3959 | Serge | 151 | _cairo_pdf_operators_fill (cairo_pdf_operators_t *pdf_operators, |
152 | const cairo_path_fixed_t *path, |
||
153 | cairo_fill_rule_t fill_rule); |
||
1892 | serge | 154 | |
155 | cairo_private cairo_int_status_t |
||
156 | _cairo_pdf_operators_fill_stroke (cairo_pdf_operators_t *pdf_operators, |
||
3959 | Serge | 157 | const cairo_path_fixed_t *path, |
1892 | serge | 158 | cairo_fill_rule_t fill_rule, |
159 | const cairo_stroke_style_t *style, |
||
160 | const cairo_matrix_t *ctm, |
||
161 | const cairo_matrix_t *ctm_inverse); |
||
162 | |||
163 | cairo_private cairo_int_status_t |
||
164 | _cairo_pdf_operators_show_text_glyphs (cairo_pdf_operators_t *pdf_operators, |
||
165 | const char *utf8, |
||
166 | int utf8_len, |
||
167 | cairo_glyph_t *glyphs, |
||
168 | int num_glyphs, |
||
169 | const cairo_text_cluster_t *clusters, |
||
170 | int num_clusters, |
||
171 | cairo_text_cluster_flags_t cluster_flags, |
||
172 | cairo_scaled_font_t *scaled_font); |
||
173 | |||
174 | #endif /* CAIRO_PDF_OPERATORS_H */ |