From 4308b7b1af2161a6de5e7a360eba1b5d97064e7e Mon Sep 17 00:00:00 2001 From: Alexei Podtelezhnikov Date: Wed, 24 Jun 2015 23:31:17 -0400 Subject: [PATCH] * src/bdf/bdflib.c (_bdf_parse_start): Simplify bpp parsing. --- ChangeLog | 4 ++++ src/bdf/bdflib.c | 29 ++++++++++------------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 619b68e0f..b9d856ad6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-06-24 Alexei Podtelezhnikov + + * src/bdf/bdflib.c (_bdf_parse_start): Simplify bpp parsing. + 2015-06-23 Werner Lemberg s/TYPEOF/FT_TYPEOF/ (#45376). diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c index 8655d0ed3..259c207ce 100644 --- a/src/bdf/bdflib.c +++ b/src/bdf/bdflib.c @@ -2346,30 +2346,21 @@ /* Check for the bits per pixel field. */ if ( p->list.used == 5 ) { - unsigned short bitcount, i, shift; + unsigned short bpp; - p->font->bpp = (unsigned short)_bdf_atos( p->list.field[4], 0, 10 ); + bpp = (unsigned short)_bdf_atos( p->list.field[4], 0, 10 ); - /* Only values 1, 2, 4, 8 are allowed. */ - shift = p->font->bpp; - bitcount = 0; - for ( i = 0; shift > 0; i++ ) - { - if ( shift & 1 ) - bitcount = i; - shift >>= 1; - } + /* Only values 1, 2, 4, 8 are allowed for greymap fonts. */ + if ( bpp > 4 ) + p->font->bpp = 8; + else if ( bpp > 2 ) + p->font->bpp = 4; + else + p->font->bpp = bpp; - shift = (unsigned short)( ( bitcount > 3 ) ? 8 - : ( 1U << bitcount ) ); - - if ( p->font->bpp > shift || p->font->bpp != shift ) - { - /* select next higher value */ - p->font->bpp = (unsigned short)( shift << 1 ); + if ( p->font->bpp != bpp ) FT_TRACE2(( "_bdf_parse_start: " ACMSG11, p->font->bpp )); - } } else p->font->bpp = 1;