From bd64a4dd0d45eb7ea09dd46e2e5f3291655dbc5e Mon Sep 17 00:00:00 2001 From: Victoria Lease Date: Wed, 30 May 2012 13:39:03 -0700 Subject: Use FreeType's "embolden", but only if face is not already bold. A side-effect of not knowing the actual SkTypeface used to draw text until render-time is that we cannot make decisions based upon the face's proper font metrics. As a result, attempts to draw bold text will fail when a fallback font with normal weight is selected. With this, we can feel free to enable fake bold mode even if the primary font is bold, as the extraneous fake bold bit will just get ignored at render-time if the actual font used to draw the text is bold. Bug: 6522642 Change-Id: Icdd13f6bd36a85ba374b6ed7a08b596d4c31e86f --- src/ports/SkFontHost_FreeType.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/ports') diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index ada0751..621c94a 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -1029,7 +1029,7 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) { break; } - if (fRec.fFlags & kEmbolden_Flag) { + if ((fRec.fFlags & kEmbolden_Flag) && !(fFace->style_flags & FT_STYLE_FLAG_BOLD)) { emboldenOutline(&fFace->glyph->outline); } @@ -1051,7 +1051,7 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) { } case FT_GLYPH_FORMAT_BITMAP: - if (fRec.fFlags & kEmbolden_Flag) { + if ((fRec.fFlags & kEmbolden_Flag) && !(fFace->style_flags & FT_STYLE_FLAG_BOLD)) { FT_GlyphSlot_Own_Bitmap(fFace->glyph); FT_Bitmap_Embolden(gFTLibrary, &fFace->glyph->bitmap, kBitmapEmboldenStrength, 0); } @@ -1100,7 +1100,7 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) { goto ERROR; } - if (fRec.fFlags & kEmbolden_Flag) { + if ((fRec.fFlags & kEmbolden_Flag) && !(fFace->style_flags & FT_STYLE_FLAG_BOLD)) { emboldenOutline(&fFace->glyph->outline); } } @@ -1330,7 +1330,7 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) { FT_BBox bbox; FT_Bitmap target; - if (fRec.fFlags & kEmbolden_Flag) { + if ((fRec.fFlags & kEmbolden_Flag) && !(fFace->style_flags & FT_STYLE_FLAG_BOLD)) { emboldenOutline(outline); } @@ -1373,7 +1373,7 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) { } break; case FT_GLYPH_FORMAT_BITMAP: { - if (fRec.fFlags & kEmbolden_Flag) { + if ((fRec.fFlags & kEmbolden_Flag) && !(fFace->style_flags & FT_STYLE_FLAG_BOLD)) { FT_GlyphSlot_Own_Bitmap(fFace->glyph); FT_Bitmap_Embolden(gFTLibrary, &fFace->glyph->bitmap, kBitmapEmboldenStrength, 0); } @@ -1516,7 +1516,7 @@ void SkScalerContext_FreeType::generatePath(const SkGlyph& glyph, return; } - if (fRec.fFlags & kEmbolden_Flag) { + if ((fRec.fFlags & kEmbolden_Flag) && !(fFace->style_flags & FT_STYLE_FLAG_BOLD)) { emboldenOutline(&fFace->glyph->outline); } @@ -1598,7 +1598,7 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx, if (x_glyph) { FT_BBox bbox; FT_Load_Glyph(fFace, x_glyph, fLoadGlyphFlags); - if (fRec.fFlags & kEmbolden_Flag) { + if ((fRec.fFlags & kEmbolden_Flag) && !(fFace->style_flags & FT_STYLE_FLAG_BOLD)) { emboldenOutline(&fFace->glyph->outline); } FT_Outline_Get_CBox(&fFace->glyph->outline, &bbox); -- cgit v1.1