Bug 445087. Add extra pixel on each side of the glyph's black box returned by GetGlyphOutlineW, to avoid clipping ClearType pixels. r=vlad

This commit is contained in:
Jonathan Kew 2009-02-05 21:06:14 +13:00
parent 3c26c1d1a0
commit 377a2dbc2b
3 changed files with 32 additions and 0 deletions

View File

@ -44,6 +44,8 @@ glyph-safety-margin.patch: Change the glyph dropping safety margin from 2em to 1
win32-vertically-offset-glyph.patch: bug 454098; vertical positioning errors when drawing glyph runs including delta-y offsets on screen via GDI
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

View File

@ -986,6 +986,16 @@ _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 {
/* 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,
* therefore, we add a pixel of "slop" to left side of the nominal "black" area,
* 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)

View File

@ -0,0 +1,20 @@
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,16 @@ _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 {
+ /* 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,
+ * therefore, we add a pixel of "slop" to left side of the nominal "black" area,
+ * 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)