From 95a574b6cbf90e1ceee50a71643fc1bec43f554a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 3 May 2018 13:06:26 +0300 Subject: [PATCH] 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. --- ttf2png.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) { -- 2.43.0