From 16287af2a6d8dc0a1142e3ff74f66497fe71cd54 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Tue, 15 Jan 2019 14:53:57 +0800 Subject: [PATCH] fix the bug of wrong bbox handling for SUBPIXEL rendering of glyph --- RELEASE-NOTES.md | 1 + src/font/freetype2.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 82491f06..39794d37 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -47,6 +47,7 @@ Please report any bugs and incompatibilities in This bug may generate dirty dots for monobitmap glyph from TTF. 1. Skip null pixels for SUBPIXEL glyphs. This bug will always show background pixels of one SUBPIXEL glyph. + 1. Fix the bug of wrong bounding box handling for SUBPIXEL rendering of glyph. * TUNNING: 1. Tune GLYPHINFO structure and GetGlyphInfo to return BIDI glyph type. diff --git a/src/font/freetype2.c b/src/font/freetype2.c index 067acff0..2bad2a5b 100644 --- a/src/font/freetype2.c +++ b/src/font/freetype2.c @@ -397,11 +397,11 @@ get_glyph_bbox (LOGFONT* logfont, DEVFONT* devfont, FT_Glyph_Get_CBox (ft_inst_info->glyph, ft_glyph_bbox_pixels, &bbox); -#if 1 //Note: using subpixel filter, the bbox_w is 2 pixel wider than normal. - if (IS_SUBPIXEL(logfont) && (ft_inst_info->ft_lcdfilter != FT_LCD_FILTER_NONE)) - bbox.xMax += 2; -#endif + if (IS_SUBPIXEL(logfont) && (ft_inst_info->ft_lcdfilter != FT_LCD_FILTER_NONE)) { + bbox.xMin -= 1; + bbox.xMax += 1; + } /* We just save the BBOX :). */ memcpy (&ft_inst_info->bbox, &bbox, sizeof(FT_BBox));