jruby/docs BETA
org.eclipse.swt.graphics 36
E AutoscalingMode
C Color
C Cursor
C Device
C DeviceData
I Drawable
C Font
C FontData
C FontMetrics
C GC
C GCData
C GlyphMetrics
C Image
C ImageData
I ImageDataAtSizeProvider
I ImageDataProvider
I ImageFileNameProvider
I ImageGcDrawer
C ImageLoader
C ImageLoaderEvent
I ImageLoaderListener
C LineAttributes
C PaletteData
C Path
C PathData
C Pattern
C Point
C RGB
C RGBA
C Rectangle
C Region
C Resource
E RoundingMode
C TextLayout
C TextStyle
C Transform
Font — members 11+
F handle() NSFont
F extraTraits() int
C new(device, fd)
C new(device, fds)
C new(device, name, height, style)
M cocoa_new(device, handle) Font
M disposed?() boolean
M equals(object) boolean
M font_data() FontData[]
M hash_code() int
M to_string() String
from Resource
M device() Device
C dispose()

org.eclipse.swt.graphics.Font

class final extends Resource 11 members

Instances of this class manage operating system resources that define how text looks when it is displayed. Fonts may be constructed by providing a device and either name, size and style information or a FontData object which encapsulates this data.

Application code must explicitly invoke the Font.dispose() method to release the operating system resources managed by each instance when those instances are no longer required.

Fields

fieldtypenote
handle NSFont the handle to the OS font resource (Warning: This field is platform dependent)

IMPORTANT: This field is not part of the SWT public API. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms and should never be accessed from application code.

extraTraits int the traits not supported to the OS font resource (Warning: This field is platform dependent)

IMPORTANT: This field is not part of the SWT public API. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms and should never be accessed from application code.

Constructors

new

new ( Device device, FontData fd )
Java: <init>(org.eclipse.swt.graphics.Device device, org.eclipse.swt.graphics.FontData fd)

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.

nametypedescription
deviceorg.eclipse.swt.graphics.Devicethe device to create the font on
fdorg.eclipse.swt.graphics.FontDatathe 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 fd argument is null
SWTError
  • ERROR_NO_HANDLES - if a font could not be created from the given font data

new

new ( Device device, FontData[] fds )
Java: <init>(org.eclipse.swt.graphics.Device device, org.eclipse.swt.graphics.FontData[] fds)

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.

nametypedescription
deviceorg.eclipse.swt.graphics.Devicethe device to create the font on
fdsorg.eclipse.swt.graphics.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 fds argument is null
  • ERROR_INVALID_ARGUMENT - if the length of fds is zero
  • ERROR_NULL_ARGUMENT - if any fd in the array is null
SWTError
  • ERROR_NO_HANDLES - if a font could not be created from the given font data

new

new ( Device device, String name, int height, int style )
Java: <init>(org.eclipse.swt.graphics.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.

nametypedescription
deviceorg.eclipse.swt.graphics.Devicethe device to create the font on
nameStringthe name of the font (must not be null)
heightintthe font height in points
styleinta 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

Class Methods

cocoa_new

Font cocoa_new ( Device device, NSFont handle )
Java: cocoa_new(org.eclipse.swt.graphics.Device device, org.eclipse.swt.internal.cocoa.NSFont handle)

Invokes platform specific functionality to allocate a new font.

IMPORTANT: This method is not part of the public API for Font. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms, and should never be called from application code.

nametypedescription
deviceorg.eclipse.swt.graphics.Devicethe device on which to allocate the color
handleorg.eclipse.swt.internal.cocoa.NSFontthe handle for the font

Instance Methods

disposed?

boolean disposed? ( )
Java: isDisposed() · also: is_disposed

Returns true if the font has been disposed, and false otherwise.

This method gets the dispose state for the font. When a font has been disposed, it is an error to invoke any other method (except #dispose()) using the font.

Returns: true when the font is disposed and false otherwise

equals

boolean equals ( Object object )
Java: equals(Object object)

Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.

nametypedescription
objectObjectthe object to compare with this object

Returns: true if the object is the same as this object and false otherwise

font_data

FontData[] font_data ( )
Java: getFontData() · also: get_font_data

Returns an array of FontDatas representing the receiver. On Windows, only one FontData will be returned per font. On X however, a Font object may be composed of multiple X fonts. To support this case, we return an array of font data objects.

Returns: an array of font data objects describing the receiver

Throws

SWTException
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

hash_code

int hash_code ( )
Java: hashCode()

Returns an integer hash code for the receiver. Any two objects that return true when passed to equals must return the same value for this method.

Returns: the receiver's hash

to_string

String to_string ( )
Java: toString()

Returns a string containing a concise, human-readable description of the receiver.

Returns: a string representation of the receiver

Inherited

from Resource

device

Device device ( )
Java: getDevice() · also: get_device

Returns the Device where this resource was created.

Returns: Device the device of the receiver

dispose

dispose ( )
Java: dispose()

Disposes of the operating system resources associated with this resource. Applications must dispose of all resources which they allocate. This method does nothing if the resource is already disposed.