User:Nedbrek/Extracting bit patterns from BDF
Jump to navigation
Jump to search
The BDF format is plain text. The spec is available from Adobe. It is very old, and quite amusing to read (it talks about handling the tapes).
Awk parser
Here is a simple parser in awk to extract the individual glyphs to a single line each:
BEGIN {
line = 0
}
/^STARTCHAR/, /^ENDCHAR/ {
if ($1 == "STARTCHAR")
{
printf $2 "\t"
line = 1
}
else if ($1 == "ENDCHAR")
{
printf "\n"
line = 0
}
else if ($1 == "ENCODING")
{
printf $2 " "
}
else if ($1 == "BITMAP")
{
line = 2
}
else if( line == 2 )
{
printf $1 " "
}
}
This will produce output like:
exclam 33 00 20 20 20 20 20 00 20 00 00 quotedbl 34 00 50 50 50 00 00 00 00 00 00
- The first column is the glyph name (useful for you to see, maybe not needed in your OS).
- The second column is the encoding. 0..127 are the standard ASCII codes. 128..255 are extended ASCII. Larger numbers are UTF-8.
- The remaining columns are the rows of the glyph (padded to 8 bits). This example is from the 6x10 font, so there are 10 rows, 6 bits each (the padding is in the least significant bits). The most significant bits are leftmost in the glyph. The first row is topmost.