FreeType: fix garbled bitmap glyphs.
At some point (probably in one of the LCD patches), the fMaskFormat for bitmap glyphs changed from kA8 to kBW. Formerly, bitmap glyphs were always transformed into A8 format. With this patch, we check the fMaskFormat and pick the correct transform at run time. http://code.google.com/p/chromium/issues/detail?id=18531 http://codereview.appspot.com/104071 git-svn-id: http://skia.googlecode.com/svn/trunk@313 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
4484d23ab4
commit
558434a9e1
@ -693,7 +693,9 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) {
|
||||
const uint8_t* src = (const uint8_t*)fFace->glyph->bitmap.buffer;
|
||||
uint8_t* dst = (uint8_t*)glyph.fImage;
|
||||
|
||||
if (fFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_GRAY) {
|
||||
if (fFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_GRAY ||
|
||||
(fFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO &&
|
||||
glyph.fMaskFormat == SkMask::kBW_Format)) {
|
||||
unsigned srcRowBytes = fFace->glyph->bitmap.pitch;
|
||||
unsigned dstRowBytes = glyph.rowBytes();
|
||||
unsigned minRowBytes = SkMin32(srcRowBytes, dstRowBytes);
|
||||
@ -705,7 +707,8 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) {
|
||||
src += srcRowBytes;
|
||||
dst += dstRowBytes;
|
||||
}
|
||||
} else if (fFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) {
|
||||
} else if (fFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO &&
|
||||
glyph.fMaskFormat == SkMask::kA8_Format) {
|
||||
for (int y = 0; y < fFace->glyph->bitmap.rows; ++y) {
|
||||
uint8_t byte = 0;
|
||||
int bits = 0;
|
||||
@ -726,6 +729,8 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) {
|
||||
src += fFace->glyph->bitmap.pitch;
|
||||
dst += glyph.rowBytes();
|
||||
}
|
||||
} else {
|
||||
SkASSERT(!"unknown glyph bitmap transform needed");
|
||||
}
|
||||
|
||||
if (lcdRenderMode)
|
||||
|
Loading…
Reference in New Issue
Block a user