From: Mikko Rasa Date: Thu, 3 May 2018 09:24:14 +0000 (+0300) Subject: Support monochrome bitmaps X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=17b96c26c5624aba41eb1d11cb5d2bf2d05982f5;p=ttf2png.git Support monochrome bitmaps --- diff --git a/ttf2png.c b/ttf2png.c index af9f56f..42125ad 100644 --- a/ttf2png.c +++ b/ttf2png.c @@ -594,9 +594,9 @@ int init_glyphs(Font *font, FT_Face face, const Range *range, bool autohinter) printf(": glyph %u, size %dx%d\n", n, bmp->width, bmp->rows); } - if(bmp->pixel_mode!=FT_PIXEL_MODE_GRAY) + if(bmp->pixel_mode!=FT_PIXEL_MODE_GRAY && bmp->pixel_mode!=FT_PIXEL_MODE_MONO) { - fprintf(stderr, "Warning: Glyph %u skipped, not grayscale\n", n); + fprintf(stderr, "Warning: Glyph %u skipped, incompatible pixel mode\n", n); continue; } @@ -652,8 +652,16 @@ int copy_bitmap(const FT_Bitmap *bmp, Image *image) for(y=0; yrows; ++y) { - for(x=0; xwidth; ++x) - dst[x] = src[x]; + if(bmp->pixel_mode==FT_PIXEL_MODE_MONO) + { + for(x=0; xwidth; ++x) + dst[x] = ((src[x/8]&(0x80>>(x%8))) ? 0xFF : 0x00); + } + else + { + for(x=0; xwidth; ++x) + dst[x] = src[x]; + } src += bmp->pitch; dst += image->w;