+ for (y = 0; y < h; ++y)
+ {
+ dst = imagedata + y * pitch;
+ src = bmp->buffer + y * bmp->pitch;
+
+ switch (bmp->pixel_mode)
+ {
+ case FT_PIXEL_MODE_MONO:
+ dst += bytesPerPixel - 1; // shift to alpha byte
+ for (x = 0; x < bmp->width; x += 8)
+ {
+ unsigned char ch = *src++;
+ *dst = 255 * !!((ch & 0x80) >> 7); dst += bytesPerPixel;
+ *dst = 255 * !!((ch & 0x40) >> 6); dst += bytesPerPixel;
+ *dst = 255 * !!((ch & 0x20) >> 5); dst += bytesPerPixel;
+ *dst = 255 * !!((ch & 0x10) >> 4); dst += bytesPerPixel;
+ *dst = 255 * !!((ch & 0x08) >> 3); dst += bytesPerPixel;
+ *dst = 255 * !!((ch & 0x04) >> 2); dst += bytesPerPixel;
+ *dst = 255 * !!((ch & 0x02) >> 1); dst += bytesPerPixel;
+ *dst = 255 * !!((ch & 0x01) >> 0); dst += bytesPerPixel;
+ }
+ break;
+ case FT_PIXEL_MODE_GRAY2:
+ dst += bytesPerPixel - 1; // shift to alpha byte
+ for (x = 0; x < bmp->width; x += 4)
+ {
+ unsigned char ch = *src++;
+ *dst = ( ((ch & 0xA0) >> 6) * 0x55 ); ch <<= 2; dst += bytesPerPixel;
+ *dst = ( ((ch & 0xA0) >> 6) * 0x55 ); ch <<= 2; dst += bytesPerPixel;
+ *dst = ( ((ch & 0xA0) >> 6) * 0x55 ); ch <<= 2; dst += bytesPerPixel;
+ *dst = ( ((ch & 0xA0) >> 6) * 0x55 ); ch <<= 2; dst += bytesPerPixel;
+ }
+ break;
+ case FT_PIXEL_MODE_GRAY4:
+ dst += bytesPerPixel - 1; // shift to alpha byte
+ for (x = 0; x < bmp->width; x += 2)
+ {
+ unsigned char ch = *src++;
+ *dst = ( ((ch & 0xF0) >> 4) * 0x11); dst += bytesPerPixel;
+ *dst = ( ((ch & 0x0F) ) * 0x11); dst += bytesPerPixel;
+ }
+ break;
+ case FT_PIXEL_MODE_GRAY:
+ // in this case pitch should equal width
+ for (tp = 0; tp < bmp->pitch; ++tp)
+ dst[(bytesPerPixel - 1) + tp*bytesPerPixel] = src[tp]; // copy the grey value into the alpha bytes
+
+ //memcpy((void*)dst, (void*)src, bmp->pitch);
+ //dst += bmp->pitch;
+ break;
+ default:
+ break;
+ }
+ }
+
+ pad_l = gpad_l;
+ pad_r = gpad_r;
+ pad_t = gpad_t;
+ pad_b = gpad_b;
+ Font_Postprocess(font, imagedata, pitch, bytesPerPixel, w, h, &pad_l, &pad_r, &pad_t, &pad_b);
+ }
+ else
+ {
+ pad_l = gpad_l;
+ pad_r = gpad_r;
+ pad_t = gpad_t;
+ pad_b = gpad_b;
+ Font_Postprocess(font, NULL, pitch, bytesPerPixel, w, h, &pad_l, &pad_r, &pad_t, &pad_b);