[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#539108: bdf2psf does not handle empty bitmaps

Package: bdf2psf
Version: 1.44
Severity: important

In the BDF font format, each glyph's shape is defined in terms of a 
bitmap of certain dimensions, located at a certain offset from the 
origin. For example, in a font that uses a 12x24 pixel character cell, 
the apostrophe glyph (') might only cover 2x4 pixels, and so it could be 
represented as a 2x4 bitmap offset upward from the origin, rather than a 
12x24 bitmap with no offset and a large number of blank pixels. A wholly 
blank glyph could legitimately be represented by a 0x0 bitmap.

This bitmap shrink-wrapping is performed by many tools that deal with 
BDF fonts, including gbdfed and otf2bdf. bdf2psf handles it well, except 
for the degenerate 0x0 bitmap case.

Steps to reproduce:

1. Get a sample BDF file with an empty bitmap for the U+0020 SPACE glyph:

   sudo aptitude install ttf-bitstream-vera otf2bdf
   otf2bdf -r 72 -p 12 -c C \
     /usr/share/fonts/truetype/ttf-bitstream-vera/VeraMono.ttf |
     sed -e "s/AVERAGE_WIDTH.*/AVERAGE_WIDTH 80/" > vera-mono-12.bdf

   (the sed invocation is required because bdf2psf sanity-checks the 
   AVERAGE_WIDTH property rather than the font bounding box, or checking 
   the DWIDTHs of the glyphs that it actually uses)
2. Convert the BDF file to a PSF file:

   bdf2psf vera-mono-12.bdf \
     /usr/share/bdf2psf/standard.equivalents \
     /usr/share/bdf2psf/required.set+/usr/share/bdf2psf/useful.set \
     256 \

3. Load the resulting psf file:

   consolechars -f vera-mono-12.psf

Expected result:
Character cells containing a U+0020 SPACE glyph should be blank.

Actual result:
Character cells containing a U+0020 SPACE glyph contain random noise, as 
though they displayed uninitialised memory.


If you apply the following patch to the BDF file and re-convert it to 
PSF, the resulting font works as expected:

--- vera-mono-12.bdf    2009-07-29 17:19:50.000000000 +1000
+++ vera-mono-12-fixed.bdf      2009-07-29 17:20:38.000000000 +1000
@@ -31,8 +31,9 @@
 SWIDTH 583 0
-BBX 0 0 0 0
+BBX 0 1 0 0

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-2-686 (SMP w/1 CPU core)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages bdf2psf depends on:
ii  perl                          5.10.0-24  Larry Wall's Practical Extraction 

bdf2psf recommends no packages.

bdf2psf suggests no packages.

-- no debconf information

Reply to: