summaryrefslogtreecommitdiff
path: root/src/cairo-pdf-operators-private.h
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2008-06-04 22:47:50 +0930
committerAdrian Johnson <ajohnson@redneon.com>2008-06-04 22:47:50 +0930
commit83e4825fae85acb49ec032c0ddf51a615ee76a9e (patch)
tree9fbad26b21943b3c1bd774e05c4013c9e514c1e4 /src/cairo-pdf-operators-private.h
parentf3d457db0c5cf79264bf48f0bef9209d68bd259f (diff)
downloadcairo-83e4825fae85acb49ec032c0ddf51a615ee76a9e.tar.gz
Rewrite _cairo_pdf_operators_show_glyphs()
Rewrite the PDF operators show_glyphs() function to make it more maintainable and better optimized. The changes include: - Use a separate function to output each text operator and update the internal state. - Store glyphs in a buffer until they can be written out as one string. This reduces the complexity of the code for emitting glyph strings and significantly optimizes the output size as glyphs from multiple calls to show_glyphs() can be accumulated and written in one string. - The code now better handles rotated text. Previously, using rotated text resulted in the text matrix emitted for every glyph. Now rotated text can be emitted as strings in the some way as non rotated text. This is particulary useful for printing in landscape mode where all text on the page is rotated.
Diffstat (limited to 'src/cairo-pdf-operators-private.h')
-rw-r--r--src/cairo-pdf-operators-private.h28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/cairo-pdf-operators-private.h b/src/cairo-pdf-operators-private.h
index 3486d13a3..e29834b09 100644
--- a/src/cairo-pdf-operators-private.h
+++ b/src/cairo-pdf-operators-private.h
@@ -45,17 +45,41 @@
#include "cairo-compiler-private.h"
#include "cairo-types-private.h"
+/* The glyph buffer size is based on the expected maximum glyphs in a
+ * line so that an entire line can be emitted in as one string. If the
+ * glyphs in a line exceeds this size the only downside is the slight
+ * overhead of emitting two strings.
+ */
+#define PDF_GLYPH_BUFFER_SIZE 200
+
typedef cairo_status_t (*cairo_pdf_operators_use_font_subset_t) (unsigned int font_id,
unsigned int subset_id,
void *closure);
+typedef struct _cairo_pdf_glyph {
+ unsigned int glyph_index;
+ double x_position;
+ double x_advance;
+} cairo_pdf_glyph_t;
+
typedef struct _cairo_pdf_operators {
cairo_output_stream_t *stream;
cairo_matrix_t cairo_to_pdf;
cairo_scaled_font_subsets_t *font_subsets;
cairo_pdf_operators_use_font_subset_t use_font_subset;
void *use_font_subset_closure;
- cairo_bool_t in_text;
+ cairo_bool_t in_text_object; /* inside BT/ET pair */
+
+ /* PDF text state */
+ unsigned int font_id;
+ unsigned int subset_id;
+ cairo_matrix_t text_matrix; /* PDF text matrix (Tlm in the PDF reference) */
+ cairo_matrix_t cairo_to_pdftext; /* translate cairo coords to PDF text space */
+ double cur_x; /* Current position in PDF text space (Tm in the PDF reference) */
+ double cur_y;
+ int hex_width;
+ int num_glyphs;
+ cairo_pdf_glyph_t glyphs[PDF_GLYPH_BUFFER_SIZE];
} cairo_pdf_operators_t;
cairo_private void
@@ -81,7 +105,7 @@ cairo_private void
_cairo_pdf_operators_set_cairo_to_pdf_matrix (cairo_pdf_operators_t *pdf_operators,
cairo_matrix_t *cairo_to_pdf);
-cairo_private cairo_int_status_t
+cairo_private cairo_status_t
_cairo_pdf_operators_flush (cairo_pdf_operators_t *pdf_operators);
cairo_private cairo_int_status_t