public final class Font extends Resource
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.
Modifier and Type | Field and Description |
---|---|
int |
handle
the handle to the OS font resource
(Warning: This field is platform dependent)
IMPORTANT: This field is not part of the SWT
public API.
|
Constructor and Description |
---|
Font(Device device)
Prevents uninitialized instances from being created outside the package.
|
Font(Device device,
FontData fd)
Constructs a new font given a device and font data
which describes the desired font's appearance.
|
Font(Device device,
FontData[] fds)
Constructs a new font given a device and an array
of font data which describes the desired font's
appearance.
|
Font(Device device,
java.lang.String name,
float height,
int style) |
Font(Device device,
java.lang.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.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
destroy() |
boolean |
equals(java.lang.Object object)
Compares the argument to the receiver, and returns true
if they represent the same object using a class
specific comparison.
|
FontData[] |
getFontData()
Returns an array of
FontData s representing the receiver. |
int |
hashCode()
Returns an integer hash code for the receiver.
|
(package private) void |
init(FontData fd) |
boolean |
isDisposed()
Returns
true if the font has been disposed,
and false otherwise. |
java.lang.String |
toString()
Returns a string containing a concise, human-readable
description of the receiver.
|
static Font |
win32_new(Device device,
int handle)
Invokes platform specific functionality to allocate a new font.
|
public int handle
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.
Font(Device device)
public Font(Device device, FontData fd)
You must dispose the font when it is no longer required.
device
- the device to create the font onfd
- the FontData that describes the desired font (must not be null)java.lang.IllegalArgumentException
- SWTError
- public Font(Device device, FontData[] fds)
You must dispose the font when it is no longer required.
device
- the device to create the font onfds
- the array of FontData that describes the desired font (must not be null)java.lang.IllegalArgumentException
- SWTError
- public Font(Device device, java.lang.String name, int height, int style)
You must dispose the font when it is no longer required.
device
- the device to create the font onname
- the name of the font (must not be null)height
- the font height in pointsstyle
- a bit or combination of NORMAL, BOLD, ITALICjava.lang.IllegalArgumentException
- SWTError
- Font(Device device, java.lang.String name, float height, int style)
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
object
- the object to compare with this objecttrue
if the object is the same as this object and false
otherwisehashCode()
public FontData[] getFontData()
FontData
s 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.SWTException
- public int hashCode()
true
when passed to
equals
must return the same value for this
method.hashCode
in class java.lang.Object
equals(java.lang.Object)
void init(FontData fd)
public boolean isDisposed()
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 Resource.dispose()
) using the font.
isDisposed
in class Resource
true
when the font is disposed and false
otherwisepublic java.lang.String toString()
toString
in class java.lang.Object
public static Font win32_new(Device device, int handle)
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.
device
- the device on which to allocate the colorhandle
- the handle for the font