waba.fx
Class Font

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

public final class Font
extends java.lang.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 = Font.getFont("Tiny", true, Font.NORMAL_SIZE);
 edName.setFont(font);

 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/fonts folder there are 5 pdb files: LSW.pdb, MSW.pdb, HSW.pdb, 5SW.pdb and 6SW.pdb. These font files are used to emulate the various supported devices (PalmOS, Symbian, etc.). For an even better rendering, some of them are identical to the device internal fonts (PalmOS4/5 for instance), 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 BIG_SIZE
          A normal-sized font
static int BOLD
          Deprecated. The style parameter is now a boolean.
static java.lang.String DEFAULT
          The default font name: "SW".
 FontMetrics fm
           
 java.lang.String name
          Read only field that contains the font's name.
static int NORMAL_SIZE
          A big-sized font
static int PLAIN
          Deprecated. The style parameter is now a boolean.
 int size
          Read only field that contains the font's size.
 int style
          Read only field that contains the font's style.
 
Constructor Summary
Font(java.lang.String name, int style, int size)
          Deprecated. This class is now a singleton. Please use the Font.getFont method instead.
 
Method Summary
 Font asBold()
          Returns this font as Bold
static Font getFont(java.lang.String name, boolean boldStyle, int size)
          Gets the instance of a font of the given name, style and size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

public java.lang.String name
Read only field that contains the font's name. Note that changing this directly will have no effect.

style

public int style
Read only field that contains the font's style. Note that changing this directly will have no effect.
See Also:
PLAIN, BOLD

size

public int size
Read only field that contains the font's size. Note that changing this directly will have no effect.

fm

public FontMetrics fm

PLAIN

public static final int PLAIN
Deprecated. The style parameter is now a boolean.

A plain font style.

BOLD

public static final int BOLD
Deprecated. The style parameter is now a boolean.

A bold font style.

BIG_SIZE

public static final int BIG_SIZE
A normal-sized font

NORMAL_SIZE

public static final int NORMAL_SIZE
A big-sized font

DEFAULT

public static final java.lang.String DEFAULT
The default font name: "SW". If a specified font is not found, the default font is used instead.
Constructor Detail

Font

public Font(java.lang.String name,
            int style,
            int size)
Deprecated. This class is now a singleton. Please use the Font.getFont method instead.

Creates a font of the given name, style and size. Font styles are defined in this class.
Parameters:
name - Use DEFAULT to use the default font ("SW"). You must install other fonts if you want to use them.
style - Font.PLAIN or Font.BOLD
size - If font size is >= 14, it uses the large font set; otherwise, if < 14, it uses the normal font set.
See Also:
PLAIN, BOLD
Method Detail

getFont

public static Font getFont(java.lang.String name,
                           boolean boldStyle,
                           int size)
Gets the instance of a font of the given name, style and size. Font styles are defined in this class.
Parameters:
name - "SW" is the default font. You must install other fonts if you want to use them.
boldStyle - If true, a bold font is used. Otherwise, a plain font is used.
size - If font size is >= 14, it uses the large font set; otherwise, if < 14, it uses the normal font set. You can also use Font.BIG_SIZE and Font.NORMAL_SIZE.
See Also:
PLAIN, BOLD

asBold

public Font asBold()
Returns this font as Bold