gfx/cairo/win32-cleartype-clipping.patch

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 diff --git a/gfx/cairo/cairo/src/cairo-win32-font.c b/gfx/cairo/cairo/src/cairo-win32-font.c
michael@0 2 --- a/gfx/cairo/cairo/src/cairo-win32-font.c
michael@0 3 +++ b/gfx/cairo/cairo/src/cairo-win32-font.c
michael@0 4 @@ -986,6 +986,19 @@ _cairo_win32_scaled_font_init_glyph_metr
michael@0 5 &metrics, 0, NULL, &matrix) == GDI_ERROR) {
michael@0 6 status = _cairo_win32_print_gdi_error ("_cairo_win32_scaled_font_init_glyph_metrics:GetGlyphOutlineW");
michael@0 7 memset (&metrics, 0, sizeof (GLYPHMETRICS));
michael@0 8 + } else {
michael@0 9 + if (metrics.gmBlackBoxX > 0 && scaled_font->base.options.antialias != CAIRO_ANTIALIAS_NONE) {
michael@0 10 + /* The bounding box reported by Windows supposedly contains the glyph's "black" area;
michael@0 11 + * however, antialiasing (especially with ClearType) means that the actual image that
michael@0 12 + * needs to be rendered may "bleed" into the adjacent pixels, mainly on the right side.
michael@0 13 + * To avoid clipping the glyphs when drawn by _cairo_surface_fallback_show_glyphs,
michael@0 14 + * for example, or other code that uses glyph extents to determine the area to update,
michael@0 15 + * we add a pixel of "slop" to left side of the nominal "black" area returned by GDI,
michael@0 16 + * and two pixels to the right (as tests show some glyphs bleed into this column).
michael@0 17 + */
michael@0 18 + metrics.gmptGlyphOrigin.x -= 1;
michael@0 19 + metrics.gmBlackBoxX += 3;
michael@0 20 + }
michael@0 21 }
michael@0 22 cairo_win32_scaled_font_done_font (&scaled_font->base);
michael@0 23 if (status)

mercurial