b=490475 disable hinting when printing r=karlt a=joe
authorAdrian Johnson <ajohnson@redneon.com>
Wed, 26 Jan 2011 08:59:41 +1300
changeset 61354 922a9e593e6f
parent 61353 52aa9a2bc021
child 61355 df375746f0cd
push id18328
push userktomlinson@mozilla.com
push dateThu, 27 Jan 2011 02:02:38 +0000
treeherdermozilla-central@58d3e2cfdbd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt, joe
bugs490475
milestone2.0b11pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
b=490475 disable hinting when printing r=karlt a=joe
gfx/thebes/gfxPangoFonts.cpp
--- a/gfx/thebes/gfxPangoFonts.cpp
+++ b/gfx/thebes/gfxPangoFonts.cpp
@@ -94,16 +94,18 @@
 #endif
 #ifndef PANGO_GLYPH_EMPTY
 #define PANGO_GLYPH_EMPTY           ((PangoGlyph)0)
 #endif
 // For g a PangoGlyph,
 #define IS_MISSING_GLYPH(g) ((g) & PANGO_GLYPH_UNKNOWN_FLAG)
 #define IS_EMPTY_GLYPH(g) ((g) == PANGO_GLYPH_EMPTY)
 
+#define PRINTING_FC_PROPERTY "gfx.printing"
+
 class gfxPangoFcFont;
 
 // Same as pango_units_from_double from Pango 1.16 (but not in older versions)
 int moz_pango_units_from_double(double d) {
     return NS_lround(d * FLOAT_PANGO_SCALE);
 }
 
 static PangoLanguage *GuessPangoLanguage(nsIAtom *aLanguage);
@@ -1675,16 +1677,17 @@ PrepareSortPattern(FcPattern *aPattern, 
     // options for non-GTK X11 toolkits, but less efficient than using GDK to
     // pick up dynamic changes.
     if(aIsPrinterFont) {
        cairo_font_options_t *options = cairo_font_options_create();
        cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_NONE);
        cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_GRAY);
        cairo_ft_font_options_substitute(options, aPattern);
        cairo_font_options_destroy(options);
+       FcPatternAddBool(aPattern, PRINTING_FC_PROPERTY, FcTrue);
     } else {
 #ifdef MOZ_GFX_OPTIMIZE_MOBILE
        cairo_font_options_t *options = cairo_font_options_create();
        cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
        cairo_ft_font_options_substitute(options, aPattern);
        cairo_font_options_destroy(options);
 #endif
 #ifdef MOZ_WIDGET_GTK2
@@ -2425,16 +2428,21 @@ CreateScaledFont(FcPattern *aPattern, ca
     cairo_matrix_t fontMatrix;
     FcMatrix *fcMatrix;
     if (FcPatternGetMatrix(aPattern, FC_MATRIX, 0, &fcMatrix) == FcResultMatch)
         cairo_matrix_init(&fontMatrix, fcMatrix->xx, -fcMatrix->yx, -fcMatrix->xy, fcMatrix->yy, 0, 0);
     else
         cairo_matrix_init_identity(&fontMatrix);
     cairo_matrix_scale(&fontMatrix, size, size);
 
+    FcBool printing;
+    if (FcPatternGetBool(aPattern, PRINTING_FC_PROPERTY, 0, &printing) != FcResultMatch) {
+        printing = FcFalse;
+    }
+
     // The cairo_scaled_font is created with a unit ctm so that metrics and
     // positions are in user space, but this means that hinting effects will
     // not be estimated accurately for non-unit transformations.
     cairo_matrix_t identityMatrix;
     cairo_matrix_init_identity(&identityMatrix);
 
     // Font options are set explicitly here to improve cairo's caching
     // behavior and to record the relevant parts of the pattern for
@@ -2470,17 +2478,21 @@ CreateScaledFont(FcPattern *aPattern, ca
     // affect glyph metrics.  The default behaves as CAIRO_HINT_METRICS_ON.
     // We should be considering the font_options of the surface on which this
     // font will be used, but currently we don't have different gfxFonts for
     // different surface font_options, so we'll create a font suitable for the
     // Screen. Image and xlib surfaces default to CAIRO_HINT_METRICS_ON.
 #ifdef MOZ_GFX_OPTIMIZE_MOBILE
     cairo_font_options_set_hint_metrics(fontOptions, CAIRO_HINT_METRICS_OFF);
 #else
-    cairo_font_options_set_hint_metrics(fontOptions, CAIRO_HINT_METRICS_ON);
+    if (printing) {
+        cairo_font_options_set_hint_metrics(fontOptions, CAIRO_HINT_METRICS_OFF);
+    } else {
+        cairo_font_options_set_hint_metrics(fontOptions, CAIRO_HINT_METRICS_ON);
+    }
 #endif
 
     // The remaining options have been recorded on the pattern and the face.
     // _cairo_ft_options_merge has some logic to decide which options from the
     // scaled_font or from the cairo_ft_font_face take priority in the way the
     // font behaves.
     //
     // In the majority of cases, _cairo_ft_options_merge uses the options from
@@ -2502,17 +2514,17 @@ CreateScaledFont(FcPattern *aPattern, ca
     // Fallback values here mirror treatment of defaults in cairo-ft-font.c.
     FcBool hinting = FcFalse;
 #ifndef MOZ_GFX_OPTIMIZE_MOBILE
     if (FcPatternGetBool(aPattern, FC_HINTING, 0, &hinting) != FcResultMatch) {
         hinting = FcTrue;
     }
 #endif
     cairo_hint_style_t hint_style;
-    if (!hinting) {
+    if (printing || !hinting) {
         hint_style = CAIRO_HINT_STYLE_NONE;
     } else {
 #ifdef FC_HINT_STYLE  // FC_HINT_STYLE is available from fontconfig 2.2.91.
         int fc_hintstyle;
         if (FcPatternGetInteger(aPattern, FC_HINT_STYLE,
                                 0, &fc_hintstyle        ) != FcResultMatch) {
             fc_hintstyle = FC_HINT_FULL;
         }