Index: src/ports/SkFontHost_FreeType_common.cpp |
diff --git a/src/ports/SkFontHost_FreeType_common.cpp b/src/ports/SkFontHost_FreeType_common.cpp |
index 245ded1283572362da007c6837caf4e9d9486e0a..26e02fd1b9a4d00777c29a17e9304281ce5d2397 100644 |
--- a/src/ports/SkFontHost_FreeType_common.cpp |
+++ b/src/ports/SkFontHost_FreeType_common.cpp |
@@ -177,8 +177,18 @@ static void copyFT2LCD16(const FT_Bitmap& bitmap, const SkMask& mask, int lcdIsB |
* TODO: All of these N need to be Y or otherwise ruled out. |
*/ |
static void copyFTBitmap(const FT_Bitmap& srcFTBitmap, SkMask& dstMask) { |
- SkASSERT(dstMask.fBounds.width() == static_cast<int>(srcFTBitmap.width)); |
- SkASSERT(dstMask.fBounds.height() == static_cast<int>(srcFTBitmap.rows)); |
+ SkASSERTF(dstMask.fBounds.width() == static_cast<int>(srcFTBitmap.width), |
+ "dstMask.fBounds.width() = %d\n" |
+ "static_cast<int>(srcFTBitmap.width) = %d", |
+ dstMask.fBounds.width(), |
+ static_cast<int>(srcFTBitmap.width) |
+ ); |
+ SkASSERTF(dstMask.fBounds.height() == static_cast<int>(srcFTBitmap.rows), |
+ "dstMask.fBounds.height() = %d\n" |
+ "static_cast<int>(srcFTBitmap.rows) = %d", |
+ dstMask.fBounds.height(), |
+ static_cast<int>(srcFTBitmap.rows) |
+ ); |
const uint8_t* src = reinterpret_cast<const uint8_t*>(srcFTBitmap.buffer); |
const FT_Pixel_Mode srcFormat = static_cast<FT_Pixel_Mode>(srcFTBitmap.pixel_mode); |
@@ -334,7 +344,11 @@ inline SkColorType SkColorType_for_SkMaskFormat(SkMask::Format format) { |
} |
} |
-void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face, const SkGlyph& glyph) { |
+void SkScalerContext_FreeType_Base::generateGlyphImage( |
+ FT_Face face, |
+ const SkGlyph& glyph, |
+ const SkMatrix& bitmapTransform) |
+{ |
const bool doBGR = SkToBool(fRec.fFlags & SkScalerContext::kLCD_BGROrder_Flag); |
const bool doVert = SkToBool(fRec.fFlags & SkScalerContext::kLCD_Vertical_Flag); |
@@ -402,20 +416,8 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face, const SkGly |
SkMask::kARGB32_Format == maskFormat || |
SkMask::kLCD16_Format == maskFormat); |
- if (fRec.fFlags & SkScalerContext::kEmbolden_Flag && |
- !(face->style_flags & FT_STYLE_FLAG_BOLD)) |
- { |
- FT_GlyphSlot_Own_Bitmap(face->glyph); |
- FT_Bitmap_Embolden(face->glyph->library, &face->glyph->bitmap, |
- kBitmapEmboldenStrength, 0); |
- } |
- |
// If no scaling needed, directly copy glyph bitmap. |
- if (glyph.fWidth == face->glyph->bitmap.width && |
- glyph.fHeight == face->glyph->bitmap.rows && |
- glyph.fTop == -face->glyph->bitmap_top && |
- glyph.fLeft == face->glyph->bitmap_left) |
- { |
+ if (bitmapTransform.isIdentity()) { |
SkMask dstMask; |
glyph.toMask(&dstMask); |
copyFTBitmap(face->glyph->bitmap, dstMask); |
@@ -426,6 +428,7 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face, const SkGly |
// Copy the FT_Bitmap into an SkBitmap (either A8 or ARGB) |
SkBitmap unscaledBitmap; |
+ // TODO: mark this as sRGB when the blits will be sRGB. |
unscaledBitmap.allocPixels(SkImageInfo::Make(face->glyph->bitmap.width, |
face->glyph->bitmap.rows, |
SkColorType_for_FTPixelMode(pixel_mode), |
@@ -447,6 +450,7 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face, const SkGly |
bitmapRowBytes = glyph.rowBytes(); |
} |
SkBitmap dstBitmap; |
+ // TODO: mark this as sRGB when the blits will be sRGB. |
dstBitmap.setInfo(SkImageInfo::Make(glyph.fWidth, glyph.fHeight, |
SkColorType_for_SkMaskFormat(maskFormat), |
kPremul_SkAlphaType), |
@@ -459,9 +463,15 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face, const SkGly |
// Scale unscaledBitmap into dstBitmap. |
SkCanvas canvas(dstBitmap); |
+#ifdef SK_SHOW_TEXT_BLIT_COVERAGE |
+ canvas.clear(0x33FF0000); |
+#else |
canvas.clear(SK_ColorTRANSPARENT); |
- canvas.scale(SkIntToScalar(glyph.fWidth) / SkIntToScalar(face->glyph->bitmap.width), |
- SkIntToScalar(glyph.fHeight) / SkIntToScalar(face->glyph->bitmap.rows)); |
+#endif |
+ canvas.translate(-glyph.fLeft, -glyph.fTop); |
+ canvas.concat(bitmapTransform); |
+ canvas.translate(face->glyph->bitmap_left, -face->glyph->bitmap_top); |
+ |
SkPaint paint; |
paint.setFilterQuality(kMedium_SkFilterQuality); |
canvas.drawBitmap(unscaledBitmap, 0, 0, &paint); |