ports/opt (3.3): thunderbird: fix font rendering with freetype 2.8.1 "
commit a6642e327e09b34f8b98f5d4ec152525c1430cdd Author: Fredrik Rinnestam <fredrik@crux.nu> Date: Thu Oct 5 14:15:58 2017 +0200 thunderbird: fix font rendering with freetype 2.8.1 " Closes FS#1482 diff --git a/thunderbird/.md5sum b/thunderbird/.md5sum index 920b65df2..06cbe76c1 100644 --- a/thunderbird/.md5sum +++ b/thunderbird/.md5sum @@ -1,3 +1,4 @@ +0561f7201118e3e97b5f527854be7032 freetype-2.8.1.patch 5841ee1a70423b9385110c82b78bef47 thunderbird-52.3.0.source.tar.xz 9a78c5c35311cc20425913c5598bf2b9 thunderbird-install-dir.patch 87f8666f06ba8c3668e39068050bb77a thunderbird.desktop diff --git a/thunderbird/.signature b/thunderbird/.signature index 4f7a0f270..93d7038b1 100644 --- a/thunderbird/.signature +++ b/thunderbird/.signature @@ -1,7 +1,8 @@ untrusted comment: verify with /etc/ports/opt.pub -RWSE3ohX2g5d/fj0a07OpFdkNW7EDVOWnLmry2NEfExBzDV2CiDGT5beCpTA15CXJFHFIZ2+C5HSXBWDoilCks33N6BQiCeUmgA= -SHA256 (Pkgfile) = 4f5267e51674453e801794910a19a24d451d7c29803a7fafc53572612d51f767 +RWSE3ohX2g5d/QxY56e+Luc+MfaiVfMvhKS58BIoRMsvd7i6jUPkiMyFh15VJlBxFkc6FOHWyW2G//E7jxglS0dtmf2vg6hyeQY= +SHA256 (Pkgfile) = 697c52ddf6ea0997bb9e5b68ac7db1565aa459826a7d3d5bb841cf5e9716ba47 SHA256 (.footprint) = d32de78e18ab67c713ba07095b648690beaeb008b75dbf43c85a15dba4a5024a SHA256 (thunderbird-52.3.0.source.tar.xz) = 050acc320a9c50365a53e4faa6538a0ad7f9a302d5f2cfb6edf0c6fe1b573b18 SHA256 (thunderbird.desktop) = c6bc6a66f16951c4f7560d019dad48968169aef6587cef4e98380a300078299a SHA256 (thunderbird-install-dir.patch) = 6c13be23eb494fe80b9e593f299138ddebe4d90e6459ba7ec40b530765ac3768 +SHA256 (freetype-2.8.1.patch) = cdd8226b3be70476bd60da8c4e92cde15b8e8e46af937ab02e3d6d75d2ce8216 diff --git a/thunderbird/Pkgfile b/thunderbird/Pkgfile index 823e14387..0f3d96b3c 100644 --- a/thunderbird/Pkgfile +++ b/thunderbird/Pkgfile @@ -5,14 +5,15 @@ name=thunderbird version=52.3.0 -release=1 +release=2 source=(http://ftp.mozilla.org/pub/thunderbird/releases/$version/source/$name-$versi... - $name.desktop thunderbird-install-dir.patch) + $name.desktop thunderbird-install-dir.patch freetype-2.8.1.patch) build() { cd $name-$version sed -i '/^ftglyph.h/ i freetype/ftfntfmt.h' mozilla/config/system-headers patch -p1 -i $SRC/thunderbird-install-dir.patch + patch -p1 -i $SRC/freetype-2.8.1.patch export LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/lib/$name" export CFLAGS="$CFLAGS -fno-delete-null-pointer-checks -fno-lifetime-dse -fno-schedule-insns2" export CXXFLAGS="$CXXFLAGS -fno-delete-null-pointer-checks -fno-lifetime-dse -fno-schedule-insns2" diff --git a/thunderbird/freetype-2.8.1.patch b/thunderbird/freetype-2.8.1.patch new file mode 100644 index 000000000..c462e652c --- /dev/null +++ b/thunderbird/freetype-2.8.1.patch @@ -0,0 +1,192 @@ + +# HG changeset patch +# User Lee Salzman <lsalzman@mozilla.com> +# Date 1505762917 14400 +# Node ID 285cde3988335103bd8d60cc09d6fa36db3c4d78 +# Parent a1d0065a275a979b3f3d7fc7ecccd38a18183664 +Bug 1400721 - Fix Skia's glyph LCD filter padding for FreeType 2.8.1. r=jrmuizel, a=jcristau + +MozReview-Commit-ID: JFvnANsTS0r + +diff --git a/mozilla/gfx/skia/skia/src/ports/SkFontHost_cairo.cpp b/mozilla/gfx/skia/skia/src/ports/SkFontHost_cairo.cpp +--- a/mozilla/gfx/skia/skia/src/ports/SkFontHost_cairo.cpp ++++ b/mozilla/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; + } + } + + +# HG changeset patch +# User Lee Salzman <lsalzman@mozilla.com> +# Date 1504640559 14400 +# Node ID 4eec2a60622c46f0525ba5c49d9fd1756208ece3 +# Parent 76d8d91b3f0f3d6b8b361035b864974921061ef5 +Bug 1393467 - Clip FreeType glyph bitmap to mask in Skia. r=jrmuizel, a=jcristau + +diff --git a/mozilla/gfx/skia/skia/src/ports/SkFontHost_FreeType_common.cpp b/mozilla/gfx/skia/skia/src/ports/SkFontHost_FreeType_common.cpp +--- a/mozilla/gfx/skia/skia/src/ports/SkFontHost_FreeType_common.cpp ++++ b/mozilla/gfx/skia/skia/src/ports/SkFontHost_FreeType_common.cpp +@@ -350,58 +350,118 @@ void SkScalerContext_FreeType_Base::gene + const SkMatrix& bitmapTransform) + { + const bool doBGR = SkToBool(fRec.fFlags & SkScalerContext::kLCD_BGROrder_Flag); + const bool doVert = SkToBool(fRec.fFlags & SkScalerContext::kLCD_Vertical_Flag); + + switch ( face->glyph->format ) { + case FT_GLYPH_FORMAT_OUTLINE: { + FT_Outline* outline = &face->glyph->outline; +- FT_BBox bbox; +- FT_Bitmap target; + + int dx = 0, dy = 0; + if (fRec.fFlags & SkScalerContext::kSubpixelPositioning_Flag) { + dx = SkFixedToFDot6(glyph.getSubXFixed()); + dy = SkFixedToFDot6(glyph.getSubYFixed()); + // negate dy since freetype-y-goes-up and skia-y-goes-down + dy = -dy; + } +- FT_Outline_Get_CBox(outline, &bbox); +- /* +- what we really want to do for subpixel is +- offset(dx, dy) +- compute_bounds +- offset(bbox & !63) +- but that is two calls to offset, so we do the following, which +- achieves the same thing with only one offset call. +- */ +- FT_Outline_Translate(outline, dx - ((bbox.xMin + dx) & ~63), +- dy - ((bbox.yMin + dy) & ~63)); ++ memset(glyph.fImage, 0, glyph.rowBytes() * glyph.fHeight); + + if (SkMask::kLCD16_Format == glyph.fMaskFormat) { +- FT_Render_Glyph(face->glyph, doVert ? FT_RENDER_MODE_LCD_V : FT_RENDER_MODE_LCD); ++ FT_Outline_Translate(outline, dx, dy); ++ FT_Error err = FT_Render_Glyph(face->glyph, doVert ? FT_RENDER_MODE_LCD_V : FT_RENDER_MODE_LCD); ++ if (err) { ++ return; ++ } ++ + SkMask mask; + glyph.toMask(&mask); ++ ++ FT_GlyphSlotRec& ftGlyph = *face->glyph; ++ ++ if (!SkIRect::Intersects(mask.fBounds, ++ SkIRect::MakeXYWH( ftGlyph.bitmap_left, ++ -ftGlyph.bitmap_top, ++ ftGlyph.bitmap.width, ++ ftGlyph.bitmap.rows))) ++ { ++ return; ++ } ++ ++ // If the FT_Bitmap extent is larger, discard bits of the bitmap outside the mask. ++ // If the SkMask extent is larger, shrink mask to fit bitmap (clearing discarded). ++ unsigned char* origBuffer = ftGlyph.bitmap.buffer; ++ // First align the top left (origin). ++ if (-ftGlyph.bitmap_top < mask.fBounds.fTop) { ++ int32_t topDiff = mask.fBounds.fTop - (-ftGlyph.bitmap_top); ++ ftGlyph.bitmap.buffer += ftGlyph.bitmap.pitch * topDiff; ++ ftGlyph.bitmap.rows -= topDiff; ++ ftGlyph.bitmap_top = -mask.fBounds.fTop; ++ } ++ if (ftGlyph.bitmap_left < mask.fBounds.fLeft) { ++ int32_t leftDiff = mask.fBounds.fLeft - ftGlyph.bitmap_left; ++ ftGlyph.bitmap.buffer += leftDiff; ++ ftGlyph.bitmap.width -= leftDiff; ++ ftGlyph.bitmap_left = mask.fBounds.fLeft; ++ } ++ if (mask.fBounds.fTop < -ftGlyph.bitmap_top) { ++ mask.fImage += mask.fRowBytes * (-ftGlyph.bitmap_top - mask.fBounds.fTop); ++ mask.fBounds.fTop = -ftGlyph.bitmap_top; ++ } ++ if (mask.fBounds.fLeft < ftGlyph.bitmap_left) { ++ mask.fImage += sizeof(uint16_t) * (ftGlyph.bitmap_left - mask.fBounds.fLeft); ++ mask.fBounds.fLeft = ftGlyph.bitmap_left; ++ } ++ // Origins aligned, clean up the width and height. ++ int ftVertScale = (doVert ? 3 : 1); ++ int ftHoriScale = (doVert ? 1 : 3); ++ if (mask.fBounds.height() * ftVertScale < SkToInt(ftGlyph.bitmap.rows)) { ++ ftGlyph.bitmap.rows = mask.fBounds.height() * ftVertScale; ++ } ++ if (mask.fBounds.width() * ftHoriScale < SkToInt(ftGlyph.bitmap.width)) { ++ ftGlyph.bitmap.width = mask.fBounds.width() * ftHoriScale; ++ } ++ if (SkToInt(ftGlyph.bitmap.rows) < mask.fBounds.height() * ftVertScale) { ++ mask.fBounds.fBottom = mask.fBounds.fTop + ftGlyph.bitmap.rows / ftVertScale; ++ } ++ if (SkToInt(ftGlyph.bitmap.width) < mask.fBounds.width() * ftHoriScale) { ++ mask.fBounds.fRight = mask.fBounds.fLeft + ftGlyph.bitmap.width / ftHoriScale; ++ } ++ + if (fPreBlend.isApplicable()) { +- copyFT2LCD16<true>(face->glyph->bitmap, mask, doBGR, ++ copyFT2LCD16<true>(ftGlyph.bitmap, mask, doBGR, + fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); + } else { +- copyFT2LCD16<false>(face->glyph->bitmap, mask, doBGR, ++ copyFT2LCD16<false>(ftGlyph.bitmap, mask, doBGR, + fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); + } ++ // Restore the buffer pointer so FreeType can properly free it. ++ ftGlyph.bitmap.buffer = origBuffer; + } else { ++ FT_BBox bbox; ++ FT_Bitmap target; ++ FT_Outline_Get_CBox(outline, &bbox); ++ /* ++ what we really want to do for subpixel is ++ offset(dx, dy) ++ compute_bounds ++ offset(bbox & !63) ++ but that is two calls to offset, so we do the following, which ++ achieves the same thing with only one offset call. ++ */ ++ FT_Outline_Translate(outline, dx - ((bbox.xMin + dx) & ~63), ++ dy - ((bbox.yMin + dy) & ~63)); ++ + target.width = glyph.fWidth; + target.rows = glyph.fHeight; + target.pitch = glyph.rowBytes(); + target.buffer = reinterpret_cast<uint8_t*>(glyph.fImage); + target.pixel_mode = compute_pixel_mode( (SkMask::Format)fRec.fMaskFormat); + target.num_grays = 256; + +- memset(glyph.fImage, 0, glyph.rowBytes() * glyph.fHeight); + FT_Outline_Get_Bitmap(face->glyph->library, outline, &target); + } + } break; + + case FT_GLYPH_FORMAT_BITMAP: { + FT_Pixel_Mode pixel_mode = static_cast<FT_Pixel_Mode>(face->glyph->bitmap.pixel_mode); + SkMask::Format maskFormat = static_cast<SkMask::Format>(glyph.fMaskFormat); + +
participants (1)
-
crux@crux.nu