Class Font


public class Font extends Resource
Instances of this class manage resources that define how text looks when it is displayed.
Since:
1.0
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    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.
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object object)
     
    Returns an array of FontDatas representing the receiver.
    int
     
    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 Details

    • 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.

      Parameters:
      device - the device to create the font on
      fontData - the FontData that describes the desired font (must not be null)
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if device is null and there is no current device
      • ERROR_NULL_ARGUMENT - if the fontData argument is null
      SWTError -
      • ERROR_NO_HANDLES - if a font could not be created from the given font data
      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.

      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 -
      • ERROR_NULL_ARGUMENT - if device is null and there is no current device
      • ERROR_NULL_ARGUMENT - if the fontData argument is null
      • ERROR_INVALID_ARGUMENT - if the length of fontData is zero
      • ERROR_NULL_ARGUMENT - if any font data in the array is null
      SWTError -
      • ERROR_NO_HANDLES - if a font could not be created from the given font data
      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 -
      • ERROR_NULL_ARGUMENT - if device is null and there is no current device
      • ERROR_NULL_ARGUMENT - if the name argument is null
      • ERROR_INVALID_ARGUMENT - if the height is negative
      SWTError -
      • ERROR_NO_HANDLES - if a font could not be created from the given arguments
  • Method Details

    • 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)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Returns a string containing a concise, human-readable description of the receiver.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the receiver