X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=ttf2png.c;h=d7079d53794f5e7091ff029e4949744a9d92df1d;hb=95a574b6cbf90e1ceee50a71643fc1bec43f554a;hp=af9f56f443d84585b8400cf80849582955be39e5;hpb=cb68acf15406a683e2d722b3a52c4d3b8b2df70d;p=ttf2png.git diff --git a/ttf2png.c b/ttf2png.c index af9f56f..d7079d5 100644 --- a/ttf2png.c +++ b/ttf2png.c @@ -501,8 +501,8 @@ int init_font(Font *font, FT_Face face, const Range *ranges, unsigned n_ranges, unsigned i, j; unsigned size = 0; - font->ascent = (face->size->metrics.ascender+63)>>6; - font->descent = (face->size->metrics.descender+63)>>6; + font->ascent = (face->size->metrics.ascender+63)/64; + font->descent = (face->size->metrics.descender-63)/64; if(verbose>=1) { @@ -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;