diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPaint.cpp | 10 | ||||
-rw-r--r-- | src/ports/SkFontHost_FreeType.cpp | 18 | ||||
-rw-r--r-- | src/ports/SkFontHost_mac_atsui.cpp | 2 |
3 files changed, 23 insertions, 7 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index f28e15c332..21b7534f9b 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -160,6 +160,11 @@ void SkPaint::setEmbeddedBitmapText(bool doEmbeddedBitmapText) this->setFlags(SkSetClearMask(fFlags, doEmbeddedBitmapText, kEmbeddedBitmapText_Flag)); } +void SkPaint::setAutohinted(bool useAutohinter) +{ + this->setFlags(SkSetClearMask(fFlags, useAutohinter, kAutoHinting_Flag)); +} + void SkPaint::setLinearText(bool doLinearText) { this->setFlags(SkSetClearMask(fFlags, doLinearText, kLinearText_Flag)); @@ -1311,12 +1316,15 @@ void SkScalerContext::MakeRec(const SkPaint& paint, rec->fStrokeJoin = 0; } - rec->fSubpixelPositioning = paint.isSubpixelText(); rec->fMaskFormat = SkToU8(computeMaskFormat(paint)); rec->fFlags = SkToU8(flags); rec->setHinting(computeHinting(paint)); if (paint.isEmbeddedBitmapText()) rec->fFlags |= SkScalerContext::kEmbeddedBitmapText_Flag; + if (paint.isSubpixelText()) + rec->fFlags |= SkScalerContext::kSubpixelPositioning_Flag; + if (paint.isAutohinted()) + rec->fFlags |= SkScalerContext::kAutohinting_Flag; /* Allow the fonthost to modify our rec before we use it as a key into the cache. This way if we're asking for something that they will ignore, diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index fd85bb28ba..b7645ddce6 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -293,7 +293,8 @@ void SkFontHost::FilterRec(SkScalerContext::Rec* rec) { if (SkPaint::kFull_Hinting == h && !rec->isLCD()) { // collapse full->normal hinting if we're not doing LCD h = SkPaint::kNormal_Hinting; - } else if (rec->fSubpixelPositioning && SkPaint::kNo_Hinting != h) { + } else if ((rec->fFlags & SkScalerContext::kSubpixelPositioning_Flag) && + SkPaint::kNo_Hinting != h) { // to do subpixel, we must have at most slight hinting h = SkPaint::kSlight_Hinting; } @@ -379,9 +380,16 @@ SkScalerContext_FreeType::SkScalerContext_FreeType(const SkDescriptor* desc) loadFlags = FT_LOAD_TARGET_LIGHT; // This implies FORCE_AUTOHINT break; case SkPaint::kNormal_Hinting: - loadFlags = FT_LOAD_TARGET_NORMAL; + if (fRec.fFlags & SkScalerContext::kAutohinting_Flag) + loadFlags = FT_LOAD_FORCE_AUTOHINT; + else + loadFlags = FT_LOAD_NO_AUTOHINT; break; case SkPaint::kFull_Hinting: + if (fRec.fFlags & SkScalerContext::kAutohinting_Flag) { + loadFlags = FT_LOAD_FORCE_AUTOHINT; + break; + } loadFlags = FT_LOAD_TARGET_NORMAL; if (SkMask::kHorizontalLCD_Format == fRec.fMaskFormat) loadFlags = FT_LOAD_TARGET_LCD; @@ -587,7 +595,7 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) { } FT_Outline_Get_CBox(&fFace->glyph->outline, &bbox); - if (fRec.fSubpixelPositioning) { + if (fRec.fFlags & SkScalerContext::kSubpixelPositioning_Flag) { int dx = glyph->getSubXFixed() >> 10; int dy = glyph->getSubYFixed() >> 10; // negate dy since freetype-y-goes-up and skia-y-goes-down @@ -624,7 +632,7 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) { goto ERROR; } - if (!fRec.fSubpixelPositioning) { + if ((fRec.fFlags & SkScalerContext::kSubpixelPositioning_Flag) == 0) { glyph->fAdvanceX = SkFDot6ToFixed(fFace->glyph->advance.x); glyph->fAdvanceY = -SkFDot6ToFixed(fFace->glyph->advance.y); if (fRec.fFlags & kDevKernText_Flag) { @@ -684,7 +692,7 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) { } int dx = 0, dy = 0; - if (fRec.fSubpixelPositioning) { + if (fRec.fFlags & SkScalerContext::kSubpixelPositioning_Flag) { dx = glyph.getSubXFixed() >> 10; dy = glyph.getSubYFixed() >> 10; // negate dy since freetype-y-goes-up and skia-y-goes-down diff --git a/src/ports/SkFontHost_mac_atsui.cpp b/src/ports/SkFontHost_mac_atsui.cpp index a0239e224c..9c01dfe7f6 100644 --- a/src/ports/SkFontHost_mac_atsui.cpp +++ b/src/ports/SkFontHost_mac_atsui.cpp @@ -246,7 +246,7 @@ void SkScalerContext_Mac::generateMetrics(SkGlyph* glyph) { return; } - if (!fRec.fSubpixelPositioning) { + if ((fRec.fFlags & SkScalerContext::kSubpixelPositioning_Flag) == 0) { glyph->fAdvanceX = SkFloatToFixed(screenMetrics.deviceAdvance.x); glyph->fAdvanceY = -SkFloatToFixed(screenMetrics.deviceAdvance.y); } else { |