-
+
/*
* Copyright 2006 The Android Open Source Project
*
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);
};
///////////////////////////////////////////////////////////////////////////
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;
}
glyph->zeroMetrics();
return;
}
+ emboldenIfNeeded(fFace, fFace->glyph);
switch ( fFace->glyph->format ) {
case FT_GLYPH_FORMAT_OUTLINE:
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);
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;
return;
}
+ emboldenIfNeeded(fFace, fFace->glyph);
generateGlyphImage(fFace, glyph);
}
path->reset();
return;
}
+ emboldenIfNeeded(fFace, fFace->glyph);
generateGlyphPath(fFace, path);
}
}
+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"
FT_BBox bbox;
FT_Bitmap target;
- if (fRec.fFlags & SkScalerContext::kEmbolden_Flag &&
- !(face->style_flags & FT_STYLE_FLAG_BOLD)) {
- emboldenOutline(face, outline);
- }
-
int dx = 0, dy = 0;
if (fRec.fFlags & SkScalerContext::kSubpixelPositioning_Flag) {
dx = SkFixedToFDot6(glyph.getSubXFixed());
void SkScalerContext_FreeType_Base::generateGlyphPath(FT_Face face,
SkPath* path)
{
- if (fRec.fFlags & SkScalerContext::kEmbolden_Flag) {
- emboldenOutline(face, &face->glyph->outline);
- }
-
FT_Outline_Funcs funcs;
funcs.move_to = move_proc;
path->close();
}
-
-void SkScalerContext_FreeType_Base::emboldenOutline(FT_Face face, FT_Outline* outline)
-{
- FT_Pos strength;
- strength = FT_MulFix(face->units_per_EM, face->size->metrics.y_scale)
- / 24;
- FT_Outline_Embolden(outline, strength);
-}