[FreeType] Always use MONO hinting when hinting in monochrome.

This matches the behaviour of Cairo. It appears to be an undocumented
trick of font rendering on Linux that, in monochrome, all the hinting
modes expect no-hinting are mapped to FreeType's MONO hinting.

http://code.google.com/p/chromium/issues/detail?id=43252

http://codereview.appspot.com/1162041/show

git-svn-id: http://skia.googlecode.com/svn/trunk@562 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
agl@chromium.org 2010-05-10 14:15:50 +00:00
parent 652807bbc8
commit 70a303f3c9

View File

@ -356,26 +356,33 @@ SkScalerContext_FreeType::SkScalerContext_FreeType(const SkDescriptor* desc)
{
FT_Int32 loadFlags = FT_LOAD_DEFAULT;
switch (fRec.getHinting()) {
case SkPaint::kNo_Hinting:
loadFlags = FT_LOAD_NO_HINTING;
break;
case SkPaint::kSlight_Hinting:
loadFlags = FT_LOAD_TARGET_LIGHT; // This implies FORCE_AUTOHINT
break;
case SkPaint::kNormal_Hinting:
loadFlags = FT_LOAD_TARGET_NORMAL;
break;
case SkPaint::kFull_Hinting:
loadFlags = FT_LOAD_TARGET_NORMAL;
if (SkMask::kHorizontalLCD_Format == fRec.fMaskFormat)
loadFlags = FT_LOAD_TARGET_LCD;
else if (SkMask::kVerticalLCD_Format == fRec.fMaskFormat)
loadFlags = FT_LOAD_TARGET_LCD_V;
break;
default:
SkDebugf("---------- UNKNOWN hinting %d\n", fRec.getHinting());
break;
if (SkMask::kBW_Format == fRec.fMaskFormat) {
// See http://code.google.com/p/chromium/issues/detail?id=43252#c24
loadFlags = FT_LOAD_TARGET_MONO;
if (fRec.getHinting() == SkPaint::kNo_Hinting)
loadFlags = FT_LOAD_NO_HINTING;
} else {
switch (fRec.getHinting()) {
case SkPaint::kNo_Hinting:
loadFlags = FT_LOAD_NO_HINTING;
break;
case SkPaint::kSlight_Hinting:
loadFlags = FT_LOAD_TARGET_LIGHT; // This implies FORCE_AUTOHINT
break;
case SkPaint::kNormal_Hinting:
loadFlags = FT_LOAD_TARGET_NORMAL;
break;
case SkPaint::kFull_Hinting:
loadFlags = FT_LOAD_TARGET_NORMAL;
if (SkMask::kHorizontalLCD_Format == fRec.fMaskFormat)
loadFlags = FT_LOAD_TARGET_LCD;
else if (SkMask::kVerticalLCD_Format == fRec.fMaskFormat)
loadFlags = FT_LOAD_TARGET_LCD_V;
break;
default:
SkDebugf("---------- UNKNOWN hinting %d\n", fRec.getHinting());
break;
}
}
if ((fRec.fFlags & SkScalerContext::kEmbeddedBitmapText_Flag) == 0)