Eclipse Rich Ajax Platform
Release 1.3

org.eclipse.swt.graphics
Class Font

java.lang.Object
  extended byorg.eclipse.swt.graphics.Resource
      extended byorg.eclipse.swt.graphics.Font

public final class Font
extends Resource

Instances of this class manage resources that define how text looks when it is displayed.

To create fonts, it is recommended to use one of the getFont methods in class Graphics by providing a name, size and style information or a FontData object which encapsulates this data.

Since:
1.0
See Also:
FontData, Graphics, Graphics.getFont(FontData), Graphics.getFont(String, int, int)

Constructor Summary
Font(Device device, FontData fontData)
          Constructs a new font given a device and font data which describes the desired font's appearance.
Font(Device device, FontData[] fontData)
          Constructs a new font given a device and an array of font data which describes the desired font's appearance.
Font(Device device, String name, int height, int style)
          Constructs a new font given a device, a font name, the height of the desired font in points, and a font style.
 
Method Summary
 boolean equals(Object object)
           
 FontData[] getFontData()
          Returns an array of FontDatas representing the receiver.
 int hashCode()
           
 String toString()
          Returns a string containing a concise, human-readable description of the receiver.
 
Methods inherited from class org.eclipse.swt.graphics.Resource
dispose, getDevice, isDisposed
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Font

public Font(Device device,
            FontData fontData)
Constructs a new font given a device and font data which describes the desired font's appearance.

You must dispose the font when it is no longer required.

Note, this constructor is provided for convenience when single-sourcing code with SWT. For RWT, the recommended way to create fonts is to use one of the getFont methods in class Graphics.

Parameters:
device - the device to create the font on
fontData - the FontData that describes the desired font (must not be null)
Throws:
IllegalArgumentException -
SWTError -
Since:
1.3

Font

public Font(Device device,
            FontData[] fontData)
Constructs a new font given a device and an array of font data which describes the desired font's appearance.

You must dispose the font when it is no longer required.

Note, this constructor is provided for convenience when single-sourcing code with SWT. For RWT, the recommended way to create fonts is to use one of the getFont methods in class Graphics.

Parameters:
device - the device to create the font on
fontData - the array of FontData that describes the desired font (must not be null)
Throws:
IllegalArgumentException -
SWTError -
Since:
1.3

Font

public Font(Device device,
            String name,
            int height,
            int style)
Constructs a new font given a device, a font name, the height of the desired font in points, and a font style.

You must dispose the font when it is no longer required.

Parameters:
device - the device to create the font on
name - the name of the font (must not be null)
height - the font height in points
style - a bit or combination of NORMAL, BOLD, ITALIC
Throws:
IllegalArgumentException -
SWTError -
Method Detail

getFontData

public FontData[] getFontData()
Returns an array of FontDatas representing the receiver.

Returns:
an array of font data objects describing the receiver
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

equals

public boolean equals(Object object)

hashCode

public int hashCode()

toString

public String toString()
Returns a string containing a concise, human-readable description of the receiver.

Returns:
a string representation of the receiver

Eclipse Rich Ajax Platform
Release 1.3

Copyright (c) Innoopract Informationssysteme GmbH and others 2002, 2011. All rights reserved.