Welcome back to te third part of the TamsPalm FontBucket tutorial. Today, we will get our hands dirty by modifying a drawing routine to use FontBucket! In case you missed the last parts, part 2 is right here.
The regular Palm OS font API is simple-each font is assigned a 8bit ID, and you assign the font to a control that uses it from now on(after a redraw). FontBucket can’t modify that concept, but it dynamically fills the 255 font slots with the fonts needed sort or like a color palette enabled app did on a Palm IIIc.
FontBucket itself identifies fonts with a 32 bit ‘creator id’. This ID stays constant while the font lives on the device-so, you can store the font ID like this:
The font ID should be initalized to the Palm OS default font when the prefs structure is created with the following code snippet:
FmGetFMFontID(&fontbucket, stdFont, &prefs->text.font);
Now, when you want to use a font, you need to ‘enable’ it. Enabling it ‘decompresses’ the font and assigns it a 8bit id:
FontID font, oldfont;
FmUseFont (&fontbucket, prefs.text.font, &font);
FmFreeFont(&fontbucket, font);//You can omit this
This ID can then be used like a regular Palm OS font ID. More information on the Palm OS font system is available here.
Tune in soon for details on font selection, font names and compatiblity.