Palmphi


Tutorial 5a: Fonts

1. Using existing fonts

Using fonts with Palmphi is very easy.
If you have a .pfn file already you can simply create a new TFont component pressing the button on the object inspector :



and changing the property File :



To change this property press either cursor-right or click with the mouse over the marked area. Then select the pfn file and press ok. You can also insert directly the name of the file.

You can either initialize the font yourself or let Palmphi do it. By default the property Autoload is true, this means that the Font will be automatically loaded and will be available during the whole life of the program. If you set this property to False you have to write in your program : Font7.Init(); before you attempt to use it.

Whether autoloaded or not, you have now this font available at each control which support fonts : TLabel, TEdit, TButton, TChechbox, TComboBox and TListBox.
Each of these components has a property "Font". This is a pop-down list which contains the default fonts and now a new one called Font7 or the name you chose for it. The name of the font is followed by the Id of the font (Font7 128), you won't need this id though.

2. Creating custom fonts

Anyway, probably you won't have any pfn files and after you looked for them in internet you are a bit disappointed, they are difficult to find. Still there is another possibility, you can create them.

Create a new TFont or use the last created one (as I will do). This time, press the button "Edit font" in the object inspector :



Now the font editor appears and you could edit the individual characters of the font. We don't have any, so instead a blank area appears "This character is not defined. Press "create" to define one". Well, you can press Create and edit one by one all the characters you may need. You can leave as much characters undefined as you want, but remember that you can't use undefined characters in your application. Empty characters are ok, but undefined characters will at least freeze your PalmOS.

There is a more comfortable way to get your characters ... Use import from system. A new dialog appears with options, which characters and from which font. For now we will just press Ok in this dialog. Now you are again in the font editor. But now you have a font imported from system.

The buttons in the font editor are self-explanatory. You have two buttons "+","-" on the selected row and selected column, they add/delete the Row/column. By deleting/adding a new column you change the width of the character. To change the width of all characters use the button "Change height". You have hotkeys for this add/del row/col buttons, they appear as a hint when you leave the mouse over them. The buttons "Create" and "Delete" define/ undefine an individual character. If you haven't defined any character, by creating the first you will be prompted for a height.

You can use "Copy" and "Paste" to copy a character to the clipboard and paste it to another character.

By pressing onto the character number, you are prompted for a new location, so you can easily jump from character 21 to character 233 without clicking on the button "Next character" x times. You can also use PgDn and PgUp to go to next/previous character.

When you are tired of editing you can press Ok to save your changes to the file specified in the "File" property. If you didn't specify any (as I did) a new file will be created with the name of the font. By pressing Cancel you won't save anything.