Bug 445087; add extra pixel on each side of the glyph's black box returned by GetGlyphOutlineW, to avoid clipping ClearType pixels; r=(roc + vladimir) sr=roc

This commit is contained in:
Jonathan Kew 2009-02-24 17:53:31 +01:00
Родитель 565160c8b7
Коммит 1f1f9c6f35
4 изменённых файлов: 39 добавлений и 1 удалений

Просмотреть файл

@ -48,6 +48,8 @@ ignore-rank0.patch: bug 474886; Not redrawing the background when changing page
win32-canvas-glyph-position.patch: bug 475092; horizontal positioning errors when drawing glyph runs with delta-y offsets to canvas through win32-font
win32-cleartype-clipping.patch: bug 445087; some glyphs are clipped, mainly on right-hand edge, when ClearType is enabled and drawing to RGBA canvas
==== pixman patches ====
endian.patch: include cairo-platform.h for endian macros

Просмотреть файл

@ -986,6 +986,19 @@ _cairo_win32_scaled_font_init_glyph_metrics (cairo_win32_scaled_font_t *scaled_f
&metrics, 0, NULL, &matrix) == GDI_ERROR) {
status = _cairo_win32_print_gdi_error ("_cairo_win32_scaled_font_init_glyph_metrics:GetGlyphOutlineW");
memset (&metrics, 0, sizeof (GLYPHMETRICS));
} else {
if (metrics.gmBlackBoxX > 0 && scaled_font->base.options.antialias != CAIRO_ANTIALIAS_NONE) {
/* The bounding box reported by Windows supposedly contains the glyph's "black" area;
* however, antialiasing (especially with ClearType) means that the actual image that
* needs to be rendered may "bleed" into the adjacent pixels, mainly on the right side.
* To avoid clipping the glyphs when drawn by _cairo_surface_fallback_show_glyphs,
* for example, or other code that uses glyph extents to determine the area to update,
* we add a pixel of "slop" to left side of the nominal "black" area returned by GDI,
* and two pixels to the right (as tests show some glyphs bleed into this column).
*/
metrics.gmptGlyphOrigin.x -= 1;
metrics.gmBlackBoxX += 3;
}
}
cairo_win32_scaled_font_done_font (&scaled_font->base);
if (status)

Просмотреть файл

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

Просмотреть файл

@ -439,7 +439,7 @@ random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 333970-1.html 333970-1-ref.html # bug 3
== 352980-3f.html 352980-3-ref.html
== 355548-1.xml 355548-1-ref.xml
== 355548-2.xml 355548-2-ref.xml
== 355548-3.xml 355548-3-ref.xml
fails-if(MOZ_WIDGET_TOOLKIT=="windows") == 355548-3.xml 355548-3-ref.xml # see bug 445087
== 355548-4.xml 355548-4-ref.xml
== 355548-5.xml 355548-5-ref.xml
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == 356774-1.html 356774-1-ref.html # probably bug 379317