From: bungeman@google.com Date: Thu, 12 Apr 2012 15:53:23 +0000 (+0000) Subject: Fix crash with LCD vertical text. X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~16421 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=875eb9835a2325e405daa61cc97c2d624feae814;p=platform%2Fupstream%2FlibSkiaSharp.git Fix crash with LCD vertical text. https://codereview.appspot.com/6012050/ git-svn-id: http://skia.googlecode.com/svn/trunk@3660 2bbb7eff-a529-9590-31e7-b0007b416f81 --- diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index 514a041..3399ec7 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -173,6 +173,7 @@ private: void getBBoxForCurrentGlyph(SkGlyph* glyph, FT_BBox* bbox, bool snapToPixelBoundary = false); void updateGlyphIfLCD(SkGlyph* glyph); + void updateGlyphPosIfLCD(SkGlyph* glyph); }; /////////////////////////////////////////////////////////////////////////// @@ -1008,6 +1009,15 @@ void SkScalerContext_FreeType::updateGlyphIfLCD(SkGlyph* glyph) { } } } +void SkScalerContext_FreeType::updateGlyphPosIfLCD(SkGlyph* glyph) { + if (isLCD(fRec)) { + if (fLCDIsVert) { + glyph->fTop -= gLCDExtra >> 1; + } else { + glyph->fLeft -= gLCDExtra >> 1; + } + } +} void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) { SkAutoMutexAcquire ac(gFTMutex); @@ -1142,7 +1152,7 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) { glyph->fLeft = SkFixedRoundToInt(vLeft - vOrigin.x); glyph->fTop = -SkFixedRoundToInt(vTop - vOrigin.y); - updateGlyphIfLCD(glyph); + updateGlyphPosIfLCD(glyph); // use the vertical advance values computed by freetype glyph->fAdvanceX = -SkFixedMul(fMatrix22.xy, fFace->glyph->linearVertAdvance);