waba.fx
Class Font

java.lang.Object
  |
  +--waba.fx.Font

public final class Font
extends Object

Font is the character font used when drawing text on a surface.

Fonts have a name, such as "Helvetica", a style and a point size (usually around 10). It's important to note that many devices have an extremely limited number of fonts. For example, most PalmPilot devices have only two fonts: plain and bold. If the font specified can't be found during drawing, the closest matching font will be used.

Here is an example showing text being drawn in a given font:

 ...
 Font font = new Font("Tiny", Font.BOLD, 10);

 public void onPaint(Graphics g)
 {
 g.setFont(font);
 g.drawText("Hello", 10, 10);
 ...
 
SuperWaba Notes:

1. If font size is >= 14, it uses the large font set.

2. Since PalmOS 2.0 dont have large fonts, you must install in the device the font files LSW.pdb located under SuperwabaSDK/lib. If this file is not present, in PalmOS 2.0, the large font set will not be used.


3. Starting from SuperWaba 2.0 beta 2, custom fonts are supported. There are lots of custom fonts under PalmGear Developer Fonts and at Handy Pilot Font Editor

4. To make the fonts usable under SuperWaba, you must change their names to match a pattern: fontName|Small/Large|Bold. Eg: suppose you download or create the font myFont. If you create the 4 supported types: small plain large plain, small bold and large bold, then you must set their name (see note 8.) to: myFontSmall, myFontSmallBold, myFontLarge, myFontLargeBold. By doing that, when creating a font under SuperWaba, you just specify its name: g.setFont(new Font("myFont", Font.PLAIN or Font.BOLD,12 or 14)).

5. If you dont follow the pattern, you must specify the full name of the font at each time it is used. Eg: myLabel.setFont(new Font("SystemNarrow",Font.PLAIN,12)); In this case, the style and size parameters are not used.

6. If you specify a font under PalmOS that dont exist and isnt installed, the default fonts from Rom will be used.

7. Under the SuperwabaSDK/lib there are 4 pdb files: LSW.pdb, MSW.pdb, HSW.pdb and 5SW.pdb. These font files are identical to the palm internal fonts, and are used to emulate the devices and are selected by the given width/height parameters.

8. To see if the font you created is installed in the target device, query its name after the creation. If the font is not found, its name is changed to match the default font.

9. Important! To change a font name, only renaming isnt enough. The font name is also stored internally in the file. Please use the utility RenameFont located at superwaba/utils.

10. You may create new fonts based on the TrueType fonts using the utility superwaba/utils/xplat/TTF2PDBs


Field Summary
static int BOLD
          A bold font style.
static int PLAIN
          A plain font style.
 
Constructor Summary
Font(String name, int style, int size)
          Creates a font of the given name, style and size.
 
Method Summary
 Font asBold()
          returns this font as Bold
 String getName()
          Returns the name of the font.
 int getSize()
          Returns the size of the font.
 int getStyle()
          Returns the style of the font.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, toString, wait, wait
 

Field Detail

PLAIN

public static final int PLAIN
A plain font style.

BOLD

public static final int BOLD
A bold font style.
Constructor Detail

Font

public Font(String name,
            int style,
            int size)
Creates a font of the given name, style and size. Font styles are defined in this class.
See Also:
PLAIN, BOLD, Graphics
Method Detail

getName

public String getName()
Returns the name of the font.

getSize

public int getSize()
Returns the size of the font.

getStyle

public int getStyle()
Returns the style of the font. Font styles are defined in this class.
See Also:
PLAIN, BOLD

asBold

public Font asBold()
returns this font as Bold