|
Home |
|
|
|
|
|
Developer's Info |
Using custom fonts in PalmPilotPalm III - Palm recommended approachInclude your font as resource into application. Insert the following code into StartApplication (do not forget error checking): static int StartApplication(void) { VoidHand fontHandle; FontType *fontPtr; // 'Font' and 0x1000 are resourse type and ID, // defined by you in resource description fontHandle=DmGetResource('Font',0x1000); fontPtr=MemHandleLock(fontHandle); // user defined fonts start from 129 FntDefineFont(129,fontPtr); FrmGotoForm(frmMain); } static int StopApplication(void) { VoidHand fontHandle; FontType *fontPtr; fontHandle=DmGetResource('Font',0x1000); fontPtr=MemHandleUnlock(fontHandle); } This would allow you to use user-defined font ids in forms and other UI resources: LABEL "your label" AUTOID AT (25 55) USABLE FONT 129 Hacking standard fontsThe previously listed code that restored system fonts from ROM no longer works, starting with OS 4.0. You should backup upon startup any values you are changing within your application and restore them on exit. // Sets current font from locked pointer Using the above functions: static int StartApplication(void) { VoidHand fontHandle; FontType *fontPtr; // 'Font' and 0x1000 are resourse type and ID, // defined by you in resource description fontHandle=DmGetResource('Font',0x1000); fontPtr=MemHandleLock(fontHandle); // 0 - standard font SetFont(0,fonthandle); FrmGotoForm(frmMain); } static int StopApplication(void) { VoidHand fontHandle; FontType *fontPtr; SetStandardFont(0); fontHandle=DmGetResource('Font',0x1000); fontPtr=MemHandleUnlock(fontHandle); } NotesYou also can set font immediately before drawing functions, although this would not allow you to use it in the form resource. The following code sets font from locked pointer until next FntSetFont is called: // This routine sets user-defined font from pointer // pointer should be locked Boolean SetFontPtr(FontType *fontPtr) { DWord version; FtrGet(sysFtrCreator,sysFtrNumROMVersion,&version); if(version<0x03000000l) *((DWord *)0x1ce)=(DWord)fp; else *((DWord *)0x1d6)=(DWord)fp; return true; } To return to system value, simply call FntSetFont(0); Metrowerks Codewarrior (cortesy of James Lynes)After some research and experimentation, I think the best way to use CW on windows to include your binary font is as follows:
read 'Font' (1000) "MYFNT.PFT"
IT WORKS!
|
Pilot Font Editor |
(C) Sergey Menshikov 1998-2001