Reason for revert: broke some win7 bots R=bungeman@google.com, reed@google.com, zheng.xu@arm.com, robertphillips@google.com, rmistry@google.com TBR=bungeman@google.com, reed@google.com, zheng.xu@arm.com NOTREECHECKS=true NOTRY=true BUG= Author: bensong@google.com Review URL: https://codereview.chromium.org/119943002 git-svn-id: http://skia.googlecode.com/svn/trunk@12794 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
22e967228d
commit
5f2fd5dd5d
@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
@ -216,9 +216,6 @@ private:
|
||||
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);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -1142,7 +1139,10 @@ bool SkScalerContext_FreeType::getCBoxForLetter(char letter, FT_BBox* bbox) {
|
||||
return false;
|
||||
if (FT_Load_Glyph(fFace, glyph_id, fLoadGlyphFlags) != 0)
|
||||
return false;
|
||||
emboldenIfNeeded(fFace, fFace->glyph);
|
||||
if ((fRec.fFlags & kEmbolden_Flag) &&
|
||||
!(fFace->style_flags & FT_STYLE_FLAG_BOLD)) {
|
||||
emboldenOutline(fFace, &fFace->glyph->outline);
|
||||
}
|
||||
FT_Outline_Get_CBox(&fFace->glyph->outline, bbox);
|
||||
return true;
|
||||
}
|
||||
@ -1192,7 +1192,6 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) {
|
||||
glyph->zeroMetrics();
|
||||
return;
|
||||
}
|
||||
emboldenIfNeeded(fFace, fFace->glyph);
|
||||
|
||||
switch ( fFace->glyph->format ) {
|
||||
case FT_GLYPH_FORMAT_OUTLINE:
|
||||
@ -1202,6 +1201,10 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) {
|
||||
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,6 +1218,11 @@ 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);
|
||||
}
|
||||
|
||||
if (fRec.fFlags & SkScalerContext::kVertical_Flag) {
|
||||
FT_Vector vector;
|
||||
vector.x = fFace->glyph->metrics.vertBearingX - fFace->glyph->metrics.horiBearingX;
|
||||
@ -1293,7 +1301,6 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) {
|
||||
return;
|
||||
}
|
||||
|
||||
emboldenIfNeeded(fFace, fFace->glyph);
|
||||
generateGlyphImage(fFace, glyph);
|
||||
}
|
||||
|
||||
@ -1321,7 +1328,6 @@ void SkScalerContext_FreeType::generatePath(const SkGlyph& glyph,
|
||||
path->reset();
|
||||
return;
|
||||
}
|
||||
emboldenIfNeeded(fFace, fFace->glyph);
|
||||
|
||||
generateGlyphPath(fFace, path);
|
||||
|
||||
@ -1463,25 +1469,6 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx,
|
||||
}
|
||||
}
|
||||
|
||||
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"
|
||||
|
@ -344,6 +344,11 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face, const SkGly
|
||||
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());
|
||||
@ -542,6 +547,10 @@ static int cubic_proc(const FT_Vector* pt0, const FT_Vector* pt1,
|
||||
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;
|
||||
@ -560,3 +569,11 @@ void SkScalerContext_FreeType_Base::generateGlyphPath(FT_Face face,
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ protected:
|
||||
|
||||
void generateGlyphImage(FT_Face face, const SkGlyph& glyph);
|
||||
void generateGlyphPath(FT_Face face, SkPath* path);
|
||||
void emboldenOutline(FT_Face face, FT_Outline* outline);
|
||||
|
||||
private:
|
||||
typedef SkScalerContext INHERITED;
|
||||
|
Loading…
Reference in New Issue
Block a user