]> git.tdb.fi Git - ttf2png.git/commitdiff
Fix scaling of font ascent and descent
authorMikko Rasa <tdb@tdb.fi>
Thu, 3 May 2018 10:06:26 +0000 (13:06 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 3 May 2018 11:11:35 +0000 (14:11 +0300)
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

index 42125adc91dbc1dee9af0237d8ef889500dc5b98..d7079d53794f5e7091ff029e4949744a9d92df1d 100644 (file)
--- 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)
        {