danger.ui
Class Typeface

java.lang.Object
  extended by danger.ui.Typeface


EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.

public abstract class Typeface
extends Object

A typeface represents a font definition that one would typically find in a file such as a true-type file. It defines how to produce glyphs to represent character codes such as unicode. A font represents a particular set of glyphs rasterized to a particular size, ready to be rendered. The typeface acts as a factory to fonts. Ideally the definition is defined as a set of scalable paths, and any size of font can be produced from the typeface. Some font definitions are provided as bitmaps however, and these font definitions can only be presented in the sizes for which the bitmaps are available.


Constructor Summary
Typeface()
          EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs. 
 
Method Summary
static String add(byte[] facedef)
          EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.Add a new typeface definition to the font system.
static String addFromResource(Class c, String filename)
          EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.A convenience interface to the add(byte[]) method which loads a font definition as a resource relative to a class using Class.getResourceAsStreamm.
static Typeface create(byte[] def)
          EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.Create a typeface from a truetype font definition.
static Typeface createFromResource(Class c, String filename)
          EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.A convenience interface to the create(byte[]) method which loads a font definition as a resource relative to a class using Class.getResourceAsStreamm.
 void dispose()
          EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.Dispose of the typeface, removing it from the font system and freeing the memory consumed by it.
abstract  String getFamily()
          EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.Fetch the font family name.
 Font getFont(int size)
          EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.Fetch a font of the given point size.
 String getName()
          EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.Fetch the name used to represent the typeface and serve as the basename of font requests.
abstract  int[] getSupportedSizes()
          EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.Fetch the sizes available with this typeface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Typeface

public Typeface()
EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.
Method Detail

create

public static Typeface create(byte[] def)
EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.
Create a typeface from a truetype font definition. This is the preferred way for applications to create their own fonts. When the application quits, it should call dispose() to free up resources used.

Fonts created from the typeface directly will not be found in queries to Font.findFont(java.lang.String). This keeps the fonts from being shared by other applications, so that they can be safely unloaded by the application that creates the fonts.

Returns:
The typeface object to use to create fonts.

createFromResource

public static Typeface createFromResource(Class c,
                                          String filename)
EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.
A convenience interface to the create(byte[]) method which loads a font definition as a resource relative to a class using Class.getResourceAsStreamm.

Parameters:
c - The class from which the resource should be loaded.
filename - The name of the resource. This will be a relative path from the class given.
Returns:
The typeface object to use to create fonts. If the definition couldn't be loaded (because an IOException was thrown or the resource coulnd not be found) null will be returned.

add

public static String add(byte[] facedef)
EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.
Add a new typeface definition to the font system. Once a typeface has been registered it can be used to create fonts. To create fonts from the typeface registered, simply use the normal name-based font creation mechanism. The name used however must be in the following format:


     familyname-style-size

 
where familyname is the familyname of the font, style is the concatonation of the names of the style flags, and size is the desired point size of the font. This is most easily produced by concatonating the name returned by this method with a dash and size string.

Parameters:
facedef - byte array representing the contents of a font typeface definition (i.e. the contents of a font file such as a true-type or open-type file).
Returns:
The name of the typeface. This name will be unique from other typeface names, and can be used to remove the typeface from the font system. Null will be returned if the font could not be added.

addFromResource

public static String addFromResource(Class c,
                                     String filename)
EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.
A convenience interface to the add(byte[]) method which loads a font definition as a resource relative to a class using Class.getResourceAsStreamm.

Parameters:
c - The class from which the resource should be loaded.
filename - The name of the resource. This will be a relative path from the class given.
Returns:
The typeface object to use to create fonts. If the definition couldn't be loaded (because an IOException was thrown or the resource coulnd not be found) null will be returned.

getFont

public Font getFont(int size)
EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.
Fetch a font of the given point size. If this typeface is based upon glyph outlines, the requested size will be returned. If the typeface is composed of embedded bitmaps, the nearest available size will be returned.


getName

public String getName()
EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.
Fetch the name used to represent the typeface and serve as the basename of font requests. This name is


getFamily

public abstract String getFamily()
EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.
Fetch the font family name.


getSupportedSizes

public abstract int[] getSupportedSizes()
EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.
Fetch the sizes available with this typeface. If the return value is null, the face is scalable and any size may be requested.


dispose

public void dispose()
EXPERIMENTAL Experimental APIs are APIs that are early-stage and not yet finalized or fully qualified. In future releases, these APIs may be changed in incompatible ways, replaced or even removed completely without warning. For these reasons, Danger will not publish applications that use any experimental APIs.
Dispose of the typeface, removing it from the font system and freeing the memory consumed by it. This call also disposes all fonts that were created by this typeface.