fonts - olikraus/dogm128 GitHub Wiki
This project includes a small tool bdf2dogm to convert the BDF file format into the
internal data structure used by the dogm128 library.
bdf2dogm is a simple c-file bdf2dogm.c. To generate the executable (unix systems),
simply compile
the c-file:
cc bdf2dogm.c -o bdf2dogm
This is the conversion procedure for truetype fonts:
- Find out a suitable point size (ftview)
- Convert TTF to BDF (otf2bdf)
- Convert BDF to a c-file (bdf2dogm)
A truetype font often does not look very well with every point size. You can use
the unix command ftview from the freetype tool collection to check the font with
different point sizes:
ftview 8 <fontname>.ttf
Different point sizes can be accessed with cursor up and down. Often it is useful to turn off aliasing by pressing "a".
The tool otf2bdf can convert the truetype font into bitmap format (bdf).
For a linux environment, otf2bdf should be available as software package.
This conversion is done for a specific point size:
otf2bdf -p <pointsize> -r 75 -o <fontname>.bdf <fontname>.ttf
The result can be checked with `fontforge'.
Use the tool bdf2dgom (part of this project) to create a c-file:
bdf2dogm <fontname>.bdf <fontname>.c <fontname>
Copy the c-file into the Dogm/utility directory and place the declaration
extern const dog_pgm_uint8_t <fontname>[]; /* version 1.6 and above */
or
extern const char <fontname>[] PROGMEM; /* version 1.5 and below */
into your source code:
#include <Dogm.h>
extern const dog_pgm_uint8_t <fontname>[];
int a0Pin = 9; // address line a0 for the dogm module
Dogm dogm(a0Pin); // initialize the dogm library
void setup() {
}
void loop() {
dogm.start();
do{
dogm.setFont(my_fontname);
dogm.setXY(10,10);
dogm.drawStr("Hello World!");
} while( dogm.next() );
delay(100);
}
Fonts distributed in the .pcf or .pcf.gz file format are part of the X11
distribution. Steps are:
- Convert PCF to BDF (pcf2bdf)
- Convert BDF to the internal representation (bdf2dogm)
pcf2bdf is often available as a software package on a linux system:
pcf2bdf -o <fontname>.bdf <fontname>.pcf.gz
See the section for truetype conversion for further handling of the BDF file.
There are several tools available for the creation of new fonts: