Bitmap fonts (PCF/BDF) support with Pango - Desktop Customization & Workflow

Users browsing this thread: 1 Guest(s)
venam
Administrators
Hello nixers,
This is a tutorial thread on how to convert your bitmap fonts, be it PCF, BDF, and others to a format supported by Pango.

What we need to do is to put the bitmap inside a container format that Pango/Harfbuzz loader supports, namely SFNT, which is the format of both TTF, OTF, and other fonts.

First of all, go to your fontconfig conf directory, usually /etc/fonts/conf.d and make sure that the file filter 70-no-bitmaps.conf is not there. If it is, remove the symbolic link, and replace it with a symbolic link to ../conf.avail/70-yes-bitmaps.conf.
If you are so inclined also symlink 10-scale-bitmap-fonts.conf.

The next step consists of converting the bitmap font to OTB/SFNT.

If you have a PCF you can use the tool pcf2bdf to convert it to BDF, which is more workable.

After that there are multiple possibilities, either rely on fontconfig scripting to do the work, with a script similar to this:

Code:
#!/usr/bin/fontforge
i=1
while ( i<$argc )
    Open($argv[i])
    Generate($argv[i]:r + ".otb")
    i = i+1
endloop


Or convert the bitmap font to an outline using this script, but it doesn't give crisp results.

Or you can clone the latest version of fonttosfnt, which can be used as follows:

Code:
fonttosfnt -b -c -g 2 -m 2 -o lime.otb lime.pcf

Adjust the options as you see fit but when not adding scalability the font might not work with some programs.

Build fonttosfnt using:
Code:
autoreconf -v --install
./configure
make
configure should warn you of any missing dependencies such as libfreetype2 and libfontenc.

After that, you can either install the font locally in $HOME/.local/share/fonts/ or globally in /usr/share/fonts/.

Be sure to refresh your fontconfig cache: fc-cache
And test using
Code:
> fc-query lime.otb  | grep 'family: '
        family: "lime"(s)
> fc-match 'lime'
lime.otb: "lime" "Regular"
> fc-list | grep 'lime'
/home/user/.local/share/fonts/lime.otb: lime lime:style=Regular

I hope this help!


Messages In This Thread
Bitmap fonts (PCF/BDF) support with Pango - by venam - 24-08-2020, 05:47 AM