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
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index e09e542..c7e310e 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -693,7 +693,9 @@
             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 @@
                     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 @@
                     src += fFace->glyph->bitmap.pitch;
                     dst += glyph.rowBytes();
                 }
+            } else {
+              SkASSERT(!"unknown glyph bitmap transform needed");
             }
 
             if (lcdRenderMode)