From 48426ab477a4290216f74953565e090b0fcb7ecf Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Mon, 3 Jun 2002 20:01:23 +0000 Subject: [PATCH] Add 8bpp support. * src/bdf/bdflib.c (_bdf_parse_start): Handle 8bpp. * src/bdf/bdfdrivr.c (BDF_Glyph_Load): Ditto. * src/bdf/README: Updated. --- ChangeLog | 8 ++++++++ src/bdf/README | 6 +++--- src/bdf/bdfdrivr.c | 7 +++++++ src/bdf/bdflib.c | 26 +++++++++++++++++--------- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1c4a625e5..db3dc9fac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2002-06-03 Werner Lemberg + + Add 8bpp support. + + * src/bdf/bdflib.c (_bdf_parse_start): Handle 8bpp. + * src/bdf/bdfdrivr.c (BDF_Glyph_Load): Ditto. + * src/bdf/README: Updated. + 2002-06-02 Detlef Würkner * src/pfr/pfrload.c (pfr_phy_font_done): Free `blue_values' array. diff --git a/src/bdf/README b/src/bdf/README index bb1a5c0c6..d45e4fb15 100644 --- a/src/bdf/README +++ b/src/bdf/README @@ -62,9 +62,9 @@ xmbdfed bitmap font editor. Microsoft's SBIT tool expects bitmap fonts in that format for adding anti-aliased them to TrueType fonts. It introduces a fourth field to the `SIZE' keyword which gives the bpp value (bits per pixel) of the glyph data in the font. Possible values are 1 (the default), -2 (four gray levels), and 4 (16 gray levels). The driver returns either a -bitmap with 1 bit per pixel or a pixmap with 8bits per pixel (using 4 and 16 -gray levels, respectively). +2 (four gray levels), 4 (16 gray levels), and 8 (256 gray levels). The +driver returns either a bitmap with 1 bit per pixel or a pixmap with 8bits +per pixel (using 4, 16, and 256 gray levels, respectively). Known problems diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c index 8e5dd62cf..c29a916ee 100644 --- a/src/bdf/bdfdrivr.c +++ b/src/bdf/bdfdrivr.c @@ -432,6 +432,13 @@ THE SOFTWARE. p += glyph.bpr; } break; + + case 8: + bitmap->num_grays = 256; + + FT_MEM_COPY( bitmap->buffer, glyph.bitmap, + bitmap->rows * bitmap->pitch ); + break; } } diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c index dde4e854f..debfdea0d 100644 --- a/src/bdf/bdflib.c +++ b/src/bdf/bdflib.c @@ -2150,20 +2150,28 @@ /* Check for the bits per pixel field. */ if ( p->list.used == 5 ) { - p->font->bpp = _bdf_atos( p->list.field[4], 0, 10 ); - if ( p->font->bpp > 1 && ( p->font->bpp & 1 ) ) + unsigned short bitcount, i, shift; + + + p->font->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++ ) { - /* Move up to the next bits per pixel value if an odd number */ - /* is encountered. */ - p->font->bpp++; - if ( p->font->bpp <= 4 ) - FT_TRACE2(( "_bdf_parse_start: " ACMSG11, p->font->bpp )); + if ( shift & 1 ) + bitcount = i; + shift >>= 1; } - if ( p->font->bpp > 4 ) + shift = ( bitcount > 3 ) ? 8 : ( 1 << bitcount ); + + if ( p->font->bpp > shift || p->font->bpp != shift ) { + /* select next higher value */ + p->font->bpp = shift << 1; FT_TRACE2(( "_bdf_parse_start: " ACMSG11, p->font->bpp )); - p->font->bpp = 4; } } else