From 8ed436c9b04548787442ddf3d7895a217b258fd5 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Thu, 21 Jul 2011 14:12:36 +0000 Subject: [PATCH] disable hinting when rotated, since it looks bad we do the same thing on windows (mac seems to handle rotation fine) git-svn-id: http://skia.googlecode.com/svn/trunk@1924 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/ports/SkFontHost_FreeType.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index a5d097e0d9..be5446e0f0 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -598,6 +598,17 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics( } /////////////////////////////////////////////////////////////////////////// +static bool bothZero(SkScalar a, SkScalar b) { + return 0 == a && 0 == b; +} + +// returns false if there is any non-90-rotation or skew +static bool isAxisAligned(const SkScalerContext::Rec& rec) { + return 0 == rec.fPreSkewX && + (bothZero(rec.fPost2x2[0][1], rec.fPost2x2[1][0]) || + bothZero(rec.fPost2x2[0][0], rec.fPost2x2[1][1])); +} + void SkFontHost::FilterRec(SkScalerContext::Rec* rec) { if (!gLCDSupportValid) { InitFreetype(); @@ -619,6 +630,10 @@ void SkFontHost::FilterRec(SkScalerContext::Rec* rec) { // to do subpixel, we must have at most slight hinting h = SkPaint::kSlight_Hinting; } + // rotated text looks bad with hinting, so we disable it as needed + if (!isAxisAligned(*rec)) { + h = SkPaint::kNo_Hinting; + } rec->setHinting(h); } -- 2.34.1