The Palm OS’s display system had to undergo three mayor overhauls in the last few years – dynamic UI(long time ago), HiRes+ and 5way navigation. The path to dynamic UI was very, very buggy afaik, HiRes+ worked well and 5way nav is, umm, more like dynamic UI to me.

Anyways, I had a nice modal form that reacted to WinDisplayChangedEvents. That form was popped up via FrmPopupForm(the only such form in the entire app…all others worked fine =) ). The resizing didn’t quite work out on Chris Schrinner’s TX:
a Fixing 5way navigation distortion   or   how to prevent the blue ring from fuxating your modal form
b Fixing 5way navigation distortion   or   how to prevent the blue ring from fuxating your modal form

There seems to be some kind of quirk with PalmOne engineers having placed a cache into their 5way nav system that stores whats behind the blue ring. Now, when the form gets resized, this cache somehow screws up and distorts/obfuscates the proximity of the poor control that happened to be selected.

Fixing the problem is rather simple – remove the focus, do the movement and then restore focus. Here is how I did it(no special headers needed btw):

UInt32 buffer;
Err err;
err = FtrGet(sysFtrCreator, sysFtrNumFiveWayNavVersion, &buffer);
if (err == errNone)
{
// One-handed navigation is supported
buffer=FrmGetFocus(pForm);
FrmSetFocus(pForm,noFocus);
FrmNavRemoveFocusRing (pForm);
}

//Party with the controls here

if(err==errNone && buffer!=noFocus)
{
FrmSetFocus(pForm,buffer);
}
FrmDrawForm(pForm);

P.s. I know that this code doesn’t detect the Treo 600 as 5way capable. But since the Treo 600 has no HiRes+ screen, I don’t really care as it will never see this code anyways….

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:


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);
oldfont=FntSetFont(font);
if(prefs.text.drawmode==plain)

//Work here

FntSetFont(oldfont);
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:


BinaryClock 2.0 basically is ready and will be released soon-so its time to cover some extra details of the compile process.

We covered preparational steps for PODS(FontBucket for PODS) and for OnBoardC(FontBucket for OnBoardC). You might also wish to fix a bug in FontBucket.c before reading this-because we get our hands dirty now!

The .h files that ships with the program blasts PODS with an Error 1 whenn included into an arbitary file-you need to remove a bit of code to get the stuff compiling-the modified file is online here.

The .r file that ships woith FontBucket contains three string resources that you need to add to your xrd file manually-they are:

string_resource RESOURCE_ID="9500"
text "System" /text

string_resource RESOURCE_ID="9504"
text "VGA Font Name" /text

string_resource RESOURCE_ID="9550"
text "Bold" /text

Define a global Fontbucket reference type. This type gets initialized when FontBucket is opened and needs to be untouched until FontBucket is closed(so, a global variable is best):

FmType fontbucket;

You must open FontBucket before using it. The opening code looks like this:

FmInit(&fontbucket, kDefaultFontStart,kDefaultFontMax, false);

You can close FontBucket with the following call. It also closes all open fonts(altough it will return an error)-so this is the one and only call that you need to call before closing your app:

FmClose(&fontbucket);

Tune in soon for details on how to use FontBucket!

Truetype fonts are great; they are even greater if they are free.

Finding a random, funky looking font is very easy nowadays, but finding a font that is well suited for programmers needs is still very difficult. The characters need to be simple, you need to be able to differentiate i and L easily, etc.

Keith Devens decided to fight back and created a list of programmer’s fonts on his web site:

http://keithdevens.com/wiki/ProgrammerFonts

Many people permanentely bicker about how Palm OS handhelds lack true type font support. Indeed, most Palm OS programs lack font support-but FontBucket actually does a pretty good job. Here are a few samples from a beta of BinaryClock for Palm OS with FontBucket support:

Comic sans MS
 A look at FontBucket
 A look at FontBucket

Times new Roman
 A look at FontBucket
 A look at FontBucket

Garamond
 A look at FontBucket
 A look at FontBucket

As you can see, the fonts look very smooth even on OS5 handhelds, the high resolution of the screen is supported!

Should you experience pixelated fonts, exchanging the font files will help. Most font files that float around the internet currently are not OS5 optimized, and thus render badly….

I always wondered why no programmer uses FontBucket from HandsHigh software-as far as I can recall, the program always worked pretty well and actually was prety fast. Anyways, BinaryClock will use FontBucket from now on-so, lets try to get it running in PODS.

Step 1-Download FontBucket
As if that wasn’t clear-you need FontBucket files to run FontBucket. You can download the files from the HandsHigh web site.

Step 2-Add the files to the PODS project
This is also pretty straight-forward. Create a subdirectory called FontBucket, and then import the FontBucket.c and FontBucket.h files into the program.

Step 3-Change the include paths
The include paths in the files were designated for CodeWarrior-PODS requires a different path layout. The code given below is intended for the files beeing placed in /src/fontbucket; you may need to change them if you place your files somewhere else.
FontBucket.h

#include "ErrorBase.h"

FontBucket.c

#include #include #include "FontBucket.h"

Step 4-Add the glue library
OK; the files now are included and everything, but the compile will end with Error 0. If you look at the console, you will find the following report:

src/fontbucket/FontBucket.o(.text+0x26a):FontBucket.c: undefined reference to `FntGlueGetDefaultFontID’
src/fontbucket/FontBucket.o(.text+0x7b6):FontBucket.c: undefined reference to `FntGlueGetDefaultFontID’

OK; the program still lacks the object code part of the Palm OS Glue Library. So, do the steps given below to get it up and running:
Glue Library for PODS

Now, your program will compile with FontBucket included. Stay tuned for an article covering usage-and BinaryClock users, look forward to truetype fonts!

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