aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontHost_FreeType.cpp
diff options
context:
space:
mode:
authorGravatar Ben Wagner <bungeman@google.com>2017-06-26 12:47:33 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-27 14:01:35 +0000
commitc3aef18419c1bb16951370e11758c7ef131fa10b (patch)
treef991fa9668072f9b87a9929c7834b55cd9175fff /src/ports/SkFontHost_FreeType.cpp
parent8c3d5156c7ab2bf723c307043841815d670895c5 (diff)
Load FreeType glyph bitmap before emboldening.
If a bitmap glyph was loaded with FT_LOAD_BITMAP_METRICS_ONLY then the glyph must be re-loaded without this flag before accessing the bitmap. BUG=chromium:725975 Change-Id: If5e5a6844e9c32238560135e141fea7f77ad7fac Reviewed-on: https://skia-review.googlesource.com/20830 Reviewed-by: Herb Derby <herb@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'src/ports/SkFontHost_FreeType.cpp')
-rw-r--r--src/ports/SkFontHost_FreeType.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index b87af6ff04..0d61d5f426 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -496,7 +496,7 @@ private:
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);
+ void emboldenIfNeeded(FT_Face face, FT_GlyphSlot glyph, SkGlyphID gid);
bool shouldSubpixelBitmap(const SkGlyph&, const SkMatrix&);
};
@@ -1107,7 +1107,7 @@ bool SkScalerContext_FreeType::getCBoxForLetter(char letter, FT_BBox* bbox) {
if (FT_Load_Glyph(fFace, glyph_id, fLoadGlyphFlags) != 0) {
return false;
}
- emboldenIfNeeded(fFace, fFace->glyph);
+ emboldenIfNeeded(fFace, fFace->glyph, SkTo<SkGlyphID>(glyph_id));
FT_Outline_Get_CBox(&fFace->glyph->outline, bbox);
return true;
}
@@ -1159,7 +1159,7 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) {
glyph->zeroMetrics();
return;
}
- emboldenIfNeeded(fFace, fFace->glyph);
+ emboldenIfNeeded(fFace, fFace->glyph, glyph->getGlyphID());
switch ( fFace->glyph->format ) {
case FT_GLYPH_FORMAT_OUTLINE:
@@ -1269,7 +1269,7 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) {
return;
}
- emboldenIfNeeded(fFace, fFace->glyph);
+ emboldenIfNeeded(fFace, fFace->glyph, glyph.getGlyphID());
SkMatrix* bitmapMatrix = &fMatrix22Scalar;
SkMatrix subpixelBitmapMatrix;
if (this->shouldSubpixelBitmap(glyph, *bitmapMatrix)) {
@@ -1304,7 +1304,7 @@ void SkScalerContext_FreeType::generatePath(SkGlyphID glyphID, SkPath* path) {
path->reset();
return;
}
- emboldenIfNeeded(fFace, fFace->glyph);
+ emboldenIfNeeded(fFace, fFace->glyph, glyphID);
generateGlyphPath(fFace, path);
@@ -1460,8 +1460,7 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* metrics
///////////////////////////////////////////////////////////////////////////////
-void SkScalerContext_FreeType::emboldenIfNeeded(FT_Face face, FT_GlyphSlot glyph)
-{
+void SkScalerContext_FreeType::emboldenIfNeeded(FT_Face face, FT_GlyphSlot glyph, SkGlyphID gid) {
// check to see if the embolden bit is set
if (0 == (fRec.fFlags & SkScalerContext::kEmbolden_Flag)) {
return;
@@ -1475,6 +1474,9 @@ void SkScalerContext_FreeType::emboldenIfNeeded(FT_Face face, FT_GlyphSlot glyph
FT_Outline_Embolden(&glyph->outline, strength);
break;
case FT_GLYPH_FORMAT_BITMAP:
+ if (!fFace->glyph->bitmap.buffer) {
+ FT_Load_Glyph(fFace, gid, fLoadGlyphFlags);
+ }
FT_GlyphSlot_Own_Bitmap(glyph);
FT_Bitmap_Embolden(glyph->library, &glyph->bitmap, kBitmapEmboldenStrength, 0);
break;