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:

FmFontID font;

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);

//Work here

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.

Technorati tags:

Related posts:

  1. Compiling FontBucket with PODS Part 4
  2. Compiling FontBucket with PODS Part 2
  3. Compiling FontBucket with PODS 1.2
  4. A little bug in FontBucket.c, routine FmValidFont
  5. Using FontBucket with OnBoardC

Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting

© 2013 TamsPalm - the Palm OS / web OS Blog Suffusion theme by Sayontan Sinha