Bug 1400721 - Fix Skia's glyph LCD filter padding for FreeType 2.8.1. r=jrmuizel, a=jcristau FIREFOX_52_4_0esr_BUILD2 FIREFOX_52_4_0esr_RELEASE
authorLee Salzman <lsalzman@mozilla.com>
Mon, 18 Sep 2017 15:28:37 -0400
changeset 682540 285cde3988335103bd8d60cc09d6fa36db3c4d78
parent 682539 a1d0065a275a979b3f3d7fc7ecccd38a18183664
child 682541 fe4f50a5fd43b775479c712b8c4367e355c62859
push id85093
push userbmo:jlorenzo@mozilla.com
push dateWed, 18 Oct 2017 15:30:37 +0000
reviewersjrmuizel, jcristau
bugs1400721
milestone52.4.0
Bug 1400721 - Fix Skia's glyph LCD filter padding for FreeType 2.8.1. r=jrmuizel, a=jcristau MozReview-Commit-ID: JFvnANsTS0r
gfx/skia/skia/src/ports/SkFontHost_cairo.cpp
--- a/gfx/skia/skia/src/ports/SkFontHost_cairo.cpp
+++ b/gfx/skia/skia/src/ports/SkFontHost_cairo.cpp
@@ -676,20 +676,25 @@ void SkScalerContext_CairoFT::generateMe
         bbox.yMin &= ~63;
         bbox.xMax = (bbox.xMax + 63) & ~63;
         bbox.yMax = (bbox.yMax + 63) & ~63;
         glyph->fWidth  = SkToU16(SkFDot6Floor(bbox.xMax - bbox.xMin));
         glyph->fHeight = SkToU16(SkFDot6Floor(bbox.yMax - bbox.yMin));
         glyph->fTop    = -SkToS16(SkFDot6Floor(bbox.yMax));
         glyph->fLeft   = SkToS16(SkFDot6Floor(bbox.xMin));
 
-        if (isLCD(fRec) &&
-            gSetLcdFilter &&
-            (fLcdFilter == FT_LCD_FILTER_DEFAULT ||
-             fLcdFilter == FT_LCD_FILTER_LIGHT)) {
+        if (isLCD(fRec)) {
+            // In FreeType < 2.8.1, LCD filtering, if explicitly used, may
+            // add padding to the glyph. When not used, there is no padding.
+            // As of 2.8.1, LCD filtering is now always supported and may
+            // add padding even if an LCD filter is not explicitly set.
+            // Regardless, if no LCD filtering is used, or if LCD filtering
+            // doesn't add padding, it is safe to modify the glyph's bounds
+            // here. generateGlyphImage will detect if the mask is smaller
+            // than the bounds and clip things appropriately.
             if (fRec.fFlags & kLCD_Vertical_Flag) {
                 glyph->fTop -= 1;
                 glyph->fHeight += 2;
             } else {
                 glyph->fLeft -= 1;
                 glyph->fWidth += 2;
             }
         }