ref: 5a1fae15a90e220e98b69ad88ee9b927aeb9c608
parent: 5be28b0d8cd069d24801415e18d2bca26472e800
author: Werner Lemberg <[email protected]>
date: Mon Jun 3 16:01:23 EDT 2002
Add 8bpp support. * src/bdf/bdflib.c (_bdf_parse_start): Handle 8bpp. * src/bdf/bdfdrivr.c (BDF_Glyph_Load): Ditto. * src/bdf/README: Updated.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2002-06-03 Werner Lemberg <[email protected]>
+
+ 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 <[email protected]>
* src/pfr/pfrload.c (pfr_phy_font_done): Free `blue_values' array.
--- a/src/bdf/README
+++ b/src/bdf/README
@@ -62,9 +62,9 @@
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
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -432,6 +432,13 @@
p += glyph.bpr;
}
break;
+
+ case 8:
+ bitmap->num_grays = 256;
+
+ FT_MEM_COPY( bitmap->buffer, glyph.bitmap,
+ bitmap->rows * bitmap->pitch );
+ break;
}
}
--- 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