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

Adrian Johnson ajohnson at kemper.freedesktop.org
Sat Oct 23 18:14:03 PDT 2010


 src/cairo-pdf-surface.c  |   15 ++++++++++++++-
 src/cairo-type1-subset.c |   30 +++++++++++++++---------------
 2 files changed, 29 insertions(+), 16 deletions(-)

New commits:
commit f47830dbbc34c7068ccdd8f7f9042e8734c9e408
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Oct 24 11:32:41 2010 +1030

    Type 1 subset: Fix glyph advance
    
    https://bugs.freedesktop.org/show_bug.cgi?id=31062
    (cherry picked from commit 6dc0b19adb6da690ad5944623081b9cdb42de066)

diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index 9c0a2cf..9650699 100644
--- a/src/cairo-type1-subset.c
+++ b/src/cairo-type1-subset.c
@@ -69,8 +69,8 @@ typedef struct _cairo_type1_font_subset {
 	unsigned int font_id;
 	char *base_font;
 	unsigned int num_glyphs;
-	long x_min, y_min, x_max, y_max;
-	long ascent, descent;
+	double x_min, y_min, x_max, y_max;
+	double ascent, descent;
 
 	const char    *data;
 	unsigned long  header_size;
@@ -146,12 +146,12 @@ _cairo_type1_font_subset_init (cairo_type1_font_subset_t  *font,
     memset (font, 0, sizeof (*font));
     font->base.unscaled_font = _cairo_unscaled_font_reference (unscaled_font);
     font->base.num_glyphs = face->num_glyphs;
-    font->base.x_min = face->bbox.xMin;
-    font->base.y_min = face->bbox.yMin;
-    font->base.x_max = face->bbox.xMax;
-    font->base.y_max = face->bbox.yMax;
-    font->base.ascent = face->ascender;
-    font->base.descent = face->descender;
+    font->base.x_min = face->bbox.xMin / (double)face->units_per_EM;
+    font->base.y_min = face->bbox.yMin / (double)face->units_per_EM;
+    font->base.x_max = face->bbox.xMax / (double)face->units_per_EM;
+    font->base.y_max = face->bbox.yMax / (double)face->units_per_EM;
+    font->base.ascent = face->ascender / (double)face->units_per_EM;
+    font->base.descent = face->descender / (double)face->units_per_EM;
 
     if (face->family_name) {
 	font->base.base_font = strdup (face->family_name);
@@ -566,7 +566,7 @@ cairo_type1_font_subset_get_glyph_names_and_widths (cairo_type1_font_subset_t *f
 	    return CAIRO_INT_STATUS_UNSUPPORTED;
 	}
 
-	font->glyphs[i].width = font->face->glyph->linearHoriAdvance / 65536.0; /* 16.16 format */
+	font->glyphs[i].width = font->face->glyph->metrics.horiAdvance / (double)font->face->units_per_EM;
 
 	error = FT_Get_Glyph_Name(font->face, i, buffer, sizeof buffer);
 	if (error != FT_Err_Ok) {
@@ -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/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;
+    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;
 
     length = font.base.header_size +
 	     font.base.data_size +
commit f747ea81fb91239690b1785bce9ed29cb58c9098
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Thu Oct 14 19:28:13 2010 +1030

    PDF: Fix regression in EXTEND_NONE gradients
    
    The test for opaque gradients in _cairo_pdf_surface_add_pdf_pattern()
    must be identical to the test in
    _cairo_pdf_surface_emit_pattern_stops() other wise the PDF file will
    reference a smask that does not exist.
    
    The _cairo_pattern_is_opaque() test is too strict for PDF as PDF can
    draw EXTEND_NONE gradients with opaque color stops without requiring a
    smask.
    (cherry picked from commit 7a17ef31760c49b81fd2890814f5b2aeb8c6b3a3)

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index c60e636..fec752f 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1202,6 +1202,18 @@ _cairo_pdf_surface_add_source_surface (cairo_pdf_surface_t	*surface,
     return status;
 }
 
+static cairo_bool_t
+_gradient_stops_are_opaque (const cairo_gradient_pattern_t *gradient)
+{
+    unsigned int i;
+
+    for (i = 0; i < gradient->n_stops; i++)
+	if (! CAIRO_COLOR_IS_OPAQUE (&gradient->stops[i].color))
+	    return FALSE;
+
+    return TRUE;
+}
+
 static cairo_status_t
 _cairo_pdf_surface_add_pdf_pattern (cairo_pdf_surface_t		*surface,
 				    const cairo_pattern_t	*pattern,
@@ -1235,7 +1247,8 @@ _cairo_pdf_surface_add_pdf_pattern (cairo_pdf_surface_t		*surface,
     if (pattern->type == CAIRO_PATTERN_TYPE_LINEAR ||
         pattern->type == CAIRO_PATTERN_TYPE_RADIAL)
     {
-        if (_cairo_pattern_is_opaque (pattern, extents) == FALSE) {
+	cairo_gradient_pattern_t *gradient = (cairo_gradient_pattern_t *) pattern;
+	if (! _gradient_stops_are_opaque (gradient)) {
             pdf_pattern.gstate_res = _cairo_pdf_surface_new_object (surface);
 	    if (pdf_pattern.gstate_res.id == 0) {
 		cairo_pattern_destroy (pdf_pattern.pattern);


More information about the cairo-commit mailing list