[cairo-commit] Branch '1.10' - 2 commits - src/cairo-pdf-operators.c src/cairo-pdf-operators-private.h src/cairo-type1-subset.c

Adrian Johnson ajohnson at kemper.freedesktop.org
Fri Oct 1 04:27:56 PDT 2010


 src/cairo-pdf-operators-private.h |    1 +
 src/cairo-pdf-operators.c         |    7 ++++++-
 src/cairo-type1-subset.c          |   12 ++++++------
 3 files changed, 13 insertions(+), 7 deletions(-)

New commits:
commit 7450a3c8a7843334d6e16af3ecef88915b5d9f26
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Fri Oct 1 19:18:28 2010 +0930

    pdf-operators: fix bug that was causing unnecessary repositioning of text
    
    This optimizes the output to increase the maximum amount of text that
    is emitted with a single Tj operator.
    (cherry picked from commit 165a14b5646d582781d119874f549ec9a02d7f53)

diff --git a/src/cairo-pdf-operators-private.h b/src/cairo-pdf-operators-private.h
index 95d4d53..67d1cc2 100644
--- a/src/cairo-pdf-operators-private.h
+++ b/src/cairo-pdf-operators-private.h
@@ -82,6 +82,7 @@ typedef struct _cairo_pdf_operators {
     double cur_y;
     int hex_width;
     int num_glyphs;
+    double glyph_buf_x_pos;
     cairo_pdf_glyph_t glyphs[PDF_GLYPH_BUFFER_SIZE];
 
     /* PDF line style */
diff --git a/src/cairo-pdf-operators.c b/src/cairo-pdf-operators.c
index 601011a..f60fbef 100644
--- a/src/cairo-pdf-operators.c
+++ b/src/cairo-pdf-operators.c
@@ -990,6 +990,7 @@ _cairo_pdf_operators_flush_glyphs (cairo_pdf_operators_t    *pdf_operators)
     }
 
     pdf_operators->num_glyphs = 0;
+    pdf_operators->glyph_buf_x_pos = pdf_operators->cur_x;
     status2 = _cairo_output_stream_destroy (word_wrap_stream);
     if (status == CAIRO_STATUS_SUCCESS)
 	status = status2;
@@ -1012,6 +1013,7 @@ _cairo_pdf_operators_add_glyph (cairo_pdf_operators_t             *pdf_operators
     pdf_operators->glyphs[pdf_operators->num_glyphs].x_position = x_position;
     pdf_operators->glyphs[pdf_operators->num_glyphs].glyph_index = glyph->subset_glyph_index;
     pdf_operators->glyphs[pdf_operators->num_glyphs].x_advance = x;
+    pdf_operators->glyph_buf_x_pos += x;
     pdf_operators->num_glyphs++;
     if (pdf_operators->num_glyphs == PDF_GLYPH_BUFFER_SIZE)
 	return _cairo_pdf_operators_flush_glyphs (pdf_operators);
@@ -1036,6 +1038,7 @@ _cairo_pdf_operators_set_text_matrix (cairo_pdf_operators_t  *pdf_operators,
     pdf_operators->text_matrix = *matrix;
     pdf_operators->cur_x = 0;
     pdf_operators->cur_y = 0;
+    pdf_operators->glyph_buf_x_pos = 0;
     _cairo_output_stream_printf (pdf_operators->stream,
 				 "%f %f %f %f %f %f Tm\n",
 				 pdf_operators->text_matrix.xx,
@@ -1091,6 +1094,7 @@ _cairo_pdf_operators_set_text_position (cairo_pdf_operators_t  *pdf_operators,
 				 translate.y0);
     pdf_operators->cur_x = 0;
     pdf_operators->cur_y = 0;
+    pdf_operators->glyph_buf_x_pos = 0;
 
     pdf_operators->cairo_to_pdftext = pdf_operators->text_matrix;
     status = cairo_matrix_invert (&pdf_operators->cairo_to_pdftext);
@@ -1140,6 +1144,7 @@ _cairo_pdf_operators_begin_text (cairo_pdf_operators_t    *pdf_operators)
 
     pdf_operators->in_text_object = TRUE;
     pdf_operators->num_glyphs = 0;
+    pdf_operators->glyph_buf_x_pos = 0;
 
     return _cairo_output_stream_get_status (pdf_operators->stream);
 }
@@ -1244,7 +1249,7 @@ _cairo_pdf_operators_emit_glyph (cairo_pdf_operators_t             *pdf_operator
      * PDF consumers that do not handle very large position
      * adjustments in TJ.
      */
-    if (fabs(x - pdf_operators->cur_x) > 10 ||
+    if (fabs(x - pdf_operators->glyph_buf_x_pos) > 10 ||
 	fabs(y - pdf_operators->cur_y) > GLYPH_POSITION_TOLERANCE)
     {
 	status = _cairo_pdf_operators_flush_glyphs (pdf_operators);
commit 43c93f2b101f534f8aa4213403af3281fcdc17fb
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Fri Oct 1 17:41:28 2010 +0930

    Fix font metrics in PDF Type 1 fonts
    
    edcefa87 introduced a bug in the Type 1 font metrics in PDF files.
    (cherry picked from commit 3f817dcfd39ffdb73ac694fd90a47d9d3a42af74)

diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index d92c860..9c0a2cf 100644
--- a/src/cairo-type1-subset.c
+++ b/src/cairo-type1-subset.c
@@ -1356,12 +1356,12 @@ _cairo_type1_subset_init (cairo_type1_subset_t		*type1_subset,
 	    font.glyphs[i].width;
     }
 
-    type1_subset->x_min = font.base.x_min;
-    type1_subset->y_min = font.base.y_min;
-    type1_subset->x_max = font.base.x_max;
-    type1_subset->y_max = font.base.y_max;
-    type1_subset->ascent = font.base.ascent;
-    type1_subset->descent = font.base.descent;
+    type1_subset->x_min = font.base.x_min/1000.0;
+    type1_subset->y_min = font.base.y_min/1000.0;
+    type1_subset->x_max = font.base.x_max/1000.0;
+    type1_subset->y_max = font.base.y_max/1000.0;
+    type1_subset->ascent = font.base.ascent/1000.0;
+    type1_subset->descent = font.base.descent/1000.0;
 
     length = font.base.header_size +
 	     font.base.data_size +


More information about the cairo-commit mailing list