de.esw.eengine.resource
Class Font

java.lang.Object
  extended by de.esw.eengine.resource.AbstractResource
      extended by de.esw.eengine.resource.Font
All Implemented Interfaces:
IResource

public class Font
extends AbstractResource
implements IResource

Implements a font resource. Fonts are stored in a font archive (JarFile with .fnt extension) and a Manifest file for meta data. The meta data consist of a Width and a Height attriute for the font image. The image must be in JPG, PNG or GIF format.
An font always consists of the following characters in the following order:

 !"#$%&'()*+�-./0123456789:;<=>?@[\]ˆ_
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz

Therefore there must be 38 characters on the first line, and 26 on the second line. The third line is optional, so there could be 'uppercase only' fonts.

Since:
1.0
Version:
$Id: Font.java 176 2005-07-08 07:25:09Z markusw $
Author:
markusw

Constructor Summary
Font(int id, java.net.URL location, FontCodec codec)
           
 
Method Summary
 void dispose()
          Frees the memory occupied and disposes this resource.
 java.awt.image.BufferedImage getChar(char c)
          Returns a BufferedImage for rendering with the given Character.
 int getCharWidth(char c)
           
 int getHeight()
           
 int getStringWidth(java.lang.String str)
           
 void load()
          Loads the IResource.
 void save()
          Saves the IResource.
 
Methods inherited from class de.esw.eengine.resource.AbstractResource
getCodec, getId, getURL
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.esw.eengine.core.IResource
getCodec, getId, getURL
 

Constructor Detail

Font

public Font(int id,
            java.net.URL location,
            FontCodec codec)
Parameters:
id - The resource id to attach
location - Locator to the resource
codec - ICodec responsible for this resource
Method Detail

load

public void load()
          throws EEngineException
Description copied from interface: IResource
Loads the IResource.

Specified by:
load in interface IResource
Specified by:
load in class AbstractResource
Throws:
EEngineException - Thrown on loading errors
See Also:
IResource.load()

getChar

public java.awt.image.BufferedImage getChar(char c)
Returns a BufferedImage for rendering with the given Character. The user should not flush the the image.

Parameters:
c - Character to get font data for
Returns:
BufferedImage as renderable

save

public void save()
          throws EEngineException
Description copied from interface: IResource
Saves the IResource.

Specified by:
save in interface IResource
Specified by:
save in class AbstractResource
Throws:
EEngineException - Thrown on saving errors
See Also:
IResource.save()

dispose

public void dispose()
Description copied from interface: IResource
Frees the memory occupied and disposes this resource.

Specified by:
dispose in interface IResource
Specified by:
dispose in class AbstractResource
See Also:
IResource.dispose()

getHeight

public final int getHeight()
Returns:
Returns the height.

getCharWidth

public final int getCharWidth(char c)
Parameters:
c - Character to get the width for
Returns:
Width of the given character

getStringWidth

public final int getStringWidth(java.lang.String str)
Parameters:
str - String for which to calculate the width
Returns:
Width of the given String