bug 668263 - fix erratic spacing in print-to-PDF by cherry-picking Cairo fixes from https://bugs.freedesktop.org/show_bug.cgi?id=31062. r=jrmuizel,ajohnson
authorStefan <kdevel@vogtner.de>
Tue, 17 Jan 2012 10:01:36 +0000
changeset 85877 f43cfe78a5b4049cc8c1207437a805cb2f1f8ee6
parent 85876 5ca8b35c3a4c37f3b32726404e9491601b9b20fe
child 85878 ff1bedd7d4637cbef5d354765623c210ef0d2b89
child 85891 a79c86c9392515ccc00ccd06de0b05663d5e1492
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, ajohnson
bugs668263, 31062
milestone12.0a1
bug 668263 - fix erratic spacing in print-to-PDF by cherry-picking Cairo fixes from https://bugs.freedesktop.org/show_bug.cgi?id=31062. r=jrmuizel,ajohnson
gfx/cairo/cairo/src/cairo-type1-subset.c
--- a/gfx/cairo/cairo/src/cairo-type1-subset.c
+++ b/gfx/cairo/cairo/src/cairo-type1-subset.c
@@ -64,18 +64,18 @@
 typedef struct _cairo_type1_font_subset {
     cairo_scaled_font_subset_t *scaled_font_subset;
 
     struct {
 	cairo_unscaled_font_t *unscaled_font;
 	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;
 	unsigned long  data_size;
 	unsigned long  trailer_size;
     } base;
 
     FT_Face face;
@@ -141,22 +141,22 @@ static cairo_status_t
 	status = CAIRO_INT_STATUS_UNSUPPORTED;
         goto fail1;
     }
 #endif
 
     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);
 	if (unlikely (font->base.base_font == NULL)) {
 	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	    goto fail2;
 	}
 	for (i = 0, j = 0; font->base.base_font[j]; j++) {
@@ -561,17 +561,17 @@ cairo_type1_font_subset_get_glyph_names_
 	if (error != FT_Err_Ok) {
 	    /* propagate fatal errors from FreeType */
 	    if (error == FT_Err_Out_Of_Memory)
 		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
 	    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) {
 	    /* propagate fatal errors from FreeType */
 	    if (error == FT_Err_Out_Of_Memory)
 		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
 	    return CAIRO_INT_STATUS_UNSUPPORTED;