Welcome back to the fourth and last part of the TamsPalm FontBucket tutorial. In case you missed the last part-it is right here.
Today, we will cover a few random thingies that can come in helpful:
Compatibility whenn FontBucket is not installed
FontBucket was developed to transparently “forward” FontBucket calls to the Palm OS API when FontBucket is not detected. So, as long as you didnt forget to include the resources into your XRD file, there is no need to create an own non-Fontbucket version!
Selecting a font
Selecting a font with FontBucket is as easy as selecting a font with the regular Palm OS. However, the selector is NOT HiRes+ cabable and obviously returns a FmFontID. This code snippet is not HiRes+ enabled and uses a selector trigger to display the font name in the currently selected font:
char* p=(char*)MemPtrNew(1024);
FontID font;
FmSelectFont(&fontbucket, &prefs.text.font);
FmFontName(&fontbucket, prefs.text.font, p);
FmUseFont(&fontbucket,prefs.text.font, &font);
CtlGlueSetFont(getObjectPtr(pForm, CmdFont),font);
CtlSetLabel(getObjectPtr(pForm, CmdFont),p);
Reacting to font deletition
Important-if you don’t apply the bug fix described here, this WILL NOT work
Eventually, fonts tend to get deleted. The following code snippet detects fonts that “went astray” and replaces them with the default Palm OS font:
//Check if font still lives
if(FmValidFont(&fontbucket,prefs.text.font)==dmErrUniqueIDNotFound)
{
FmGetFMFontID(&fontbucket, stdFont, &prefs.text.font);
}
Overall, I hope that you enjoyed the TamsPalm FontBucket tutorial. Please tell us if you have questions or comments!!
Technorati tags:
Fonts
Palm
Palm OS
Related posts: