From e76073bfcd30f8742a377d636bbad84183b275ec Mon Sep 17 00:00:00 2001 From: "agl@chromium.org" Date: Fri, 4 Jun 2010 20:31:17 +0000 Subject: Add support for fake bold of bitmap fonts. BUG=45874 http://codereview.appspot.com/1558041/show git-svn-id: http://skia.googlecode.com/svn/trunk@574 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/ports/SkFontHost_FreeType.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/ports') diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index b0746b6204..0e32d7b832 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -33,6 +33,7 @@ #include FT_OUTLINE_H #include FT_SIZES_H #include FT_TRUETYPE_TABLES_H +#include FT_BITMAP_H #if defined(SK_SUPPORT_LCDTEXT) #include FT_LCD_FILTER_H @@ -50,6 +51,7 @@ #include #include #include +#include #endif //#define ENABLE_GLYPH_SPEW // for tracing calls @@ -78,6 +80,10 @@ static bool gLCDSupport; // true iff LCD is supported by the runtime. ///////////////////////////////////////////////////////////////////////// +// See http://freetype.sourceforge.net/freetype2/docs/reference/ft2-bitmap_handling.html#FT_Bitmap_Embolden +// This value was chosen by eyeballing the result in Firefox and trying to match it. +static const FT_Pos kBitmapEmboldenStrength = 1 << 6; + static bool InitFreetype() { FT_Error err = FT_Init_FreeType(&gFTLibrary); @@ -600,6 +606,10 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) { break; case FT_GLYPH_FORMAT_BITMAP: + if (fRec.fFlags & kEmbolden_Flag) { + FT_GlyphSlot_Own_Bitmap(fFace->glyph); + FT_Bitmap_Embolden(gFTLibrary, &fFace->glyph->bitmap, kBitmapEmboldenStrength, 0); + } glyph->fWidth = SkToU16(fFace->glyph->bitmap.width); glyph->fHeight = SkToU16(fFace->glyph->bitmap.rows); glyph->fTop = -SkToS16(fFace->glyph->bitmap_top); @@ -719,6 +729,10 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) { } break; case FT_GLYPH_FORMAT_BITMAP: { + if (fRec.fFlags & kEmbolden_Flag) { + FT_GlyphSlot_Own_Bitmap(fFace->glyph); + FT_Bitmap_Embolden(gFTLibrary, &fFace->glyph->bitmap, kBitmapEmboldenStrength, 0); + } SkASSERT_CONTINUE(glyph.fWidth == fFace->glyph->bitmap.width); SkASSERT_CONTINUE(glyph.fHeight == fFace->glyph->bitmap.rows); SkASSERT_CONTINUE(glyph.fTop == -fFace->glyph->bitmap_top); -- cgit v1.2.3