Chromium Code Reviews| Index: src/ports/SkFontHost_FreeType.cpp |
| diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp |
| index f79e27b7ed06890e7d4d5a4c3bab75286c1f4f45..62c7c128a7fbb33921c1923fd7c5d48b10830089 100644 |
| --- a/src/ports/SkFontHost_FreeType.cpp |
| +++ b/src/ports/SkFontHost_FreeType.cpp |
| @@ -1,4 +1,4 @@ |
| - |
| + |
|
ukai
2014/01/28 05:21:46
why did it add some binary data?
(0xEF 0xBB 0xBF 0
bungeman-skia
2014/01/28 16:12:17
This (0xEF 0xBB 0xBF) is the UTF-8 encoding of the
|
| /* |
| * Copyright 2006 The Android Open Source Project |
| * |
| @@ -216,6 +216,9 @@ |
| bool getCBoxForLetter(char letter, FT_BBox* bbox); |
| // Caller must lock gFTMutex before calling this function. |
| void updateGlyphIfLCD(SkGlyph* glyph); |
| + // Caller must lock gFTMutex before calling this function. |
| + // update FreeType2 glyph slot with glyph emboldened |
| + void emboldenIfNeeded(FT_Face face, FT_GlyphSlot glyph); |
| }; |
| /////////////////////////////////////////////////////////////////////////// |
| @@ -1136,10 +1139,7 @@ |
| return false; |
| if (FT_Load_Glyph(fFace, glyph_id, fLoadGlyphFlags) != 0) |
| return false; |
| - if ((fRec.fFlags & kEmbolden_Flag) && |
| - !(fFace->style_flags & FT_STYLE_FLAG_BOLD)) { |
| - emboldenOutline(fFace, &fFace->glyph->outline); |
| - } |
| + emboldenIfNeeded(fFace, fFace->glyph); |
| FT_Outline_Get_CBox(&fFace->glyph->outline, bbox); |
| return true; |
| } |
| @@ -1189,6 +1189,7 @@ |
| glyph->zeroMetrics(); |
| return; |
| } |
| + emboldenIfNeeded(fFace, fFace->glyph); |
| switch ( fFace->glyph->format ) { |
| case FT_GLYPH_FORMAT_OUTLINE: |
| @@ -1198,10 +1199,6 @@ |
| glyph->fTop = 0; |
| glyph->fLeft = 0; |
| } else { |
| - if (fRec.fFlags & kEmbolden_Flag && !(fFace->style_flags & FT_STYLE_FLAG_BOLD)) { |
| - emboldenOutline(fFace, &fFace->glyph->outline); |
| - } |
| - |
| FT_BBox bbox; |
| getBBoxForCurrentGlyph(glyph, &bbox, true); |
| @@ -1215,11 +1212,6 @@ |
| 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); |
| - } |
| - |
| if (fRec.fFlags & SkScalerContext::kVertical_Flag) { |
| FT_Vector vector; |
| vector.x = fFace->glyph->metrics.vertBearingX - fFace->glyph->metrics.horiBearingX; |
| @@ -1298,6 +1290,7 @@ |
| return; |
| } |
| + emboldenIfNeeded(fFace, fFace->glyph); |
| generateGlyphImage(fFace, glyph); |
| } |
| @@ -1325,6 +1318,7 @@ |
| path->reset(); |
| return; |
| } |
| + emboldenIfNeeded(fFace, fFace->glyph); |
| generateGlyphPath(fFace, path); |
| @@ -1466,6 +1460,25 @@ |
| } |
| } |
| +void SkScalerContext_FreeType::emboldenIfNeeded(FT_Face face, FT_GlyphSlot glyph) |
| +{ |
| + if (fRec.fFlags & SkScalerContext::kEmbolden_Flag) { |
| + switch ( glyph->format ) { |
| + case FT_GLYPH_FORMAT_OUTLINE: |
| + FT_Pos strength; |
| + strength = FT_MulFix(face->units_per_EM, face->size->metrics.y_scale) / 24; |
| + FT_Outline_Embolden(&glyph->outline, strength); |
| + break; |
| + case FT_GLYPH_FORMAT_BITMAP: |
| + FT_GlyphSlot_Own_Bitmap(glyph); |
| + FT_Bitmap_Embolden(glyph->library, &glyph->bitmap, kBitmapEmboldenStrength, 0); |
| + break; |
| + default: |
| + SkDEBUGFAIL("unknown glyph format"); |
| + } |
| + } |
| +} |
| + |
| /////////////////////////////////////////////////////////////////////////////// |
| #include "SkUtils.h" |