From: Mikko Rasa Date: Thu, 3 May 2018 10:06:26 +0000 (+0300) Subject: Fix scaling of font ascent and descent X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=95a574b6cbf90e1ceee50a71643fc1bec43f554a;p=ttf2png.git Fix scaling of font ascent and descent Descent value is often negative and right-shifting a negative value is implementation-defined. Best to avoid it. Also round descent down instead of up. --- diff --git a/ttf2png.c b/ttf2png.c index 42125ad..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) {