Class Font
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.
-
Field Summary
Modifier and TypeFieldDescriptionlong
the handle to the OS font resource (Warning: This field is platform dependent) -
Constructor Summary
ConstructorDescriptionConstructs a new font given a device, a font name, the height of the desired font in points, and a font style.Constructs a new font given a device and font data which describes the desired font's appearance.Constructs a new font given a device and an array of font data which describes the desired font's appearance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.FontData[]
Returns an array ofFontData
s representing the receiver.int
hashCode()
Returns an integer hash code for the receiver.boolean
Returnstrue
if the font has been disposed, andfalse
otherwise.toString()
Returns a string containing a concise, human-readable description of the receiver.static Font
Invokes platform specific functionality to allocate a new font.static Font
Invokes platform specific functionality to allocate a new font.static Font
Invokes platform specific private constructor to allocate a new font.static Font
Used to receive a font for the given zoom in the context of the current configuration of SWT at runtime.Methods inherited from class org.eclipse.swt.graphics.Resource
dispose, getDevice, setNonDisposeHandler
-
Field Details
-
handle
public long handlethe 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.
- Restriction:
- This field is not intended to be referenced by clients.
-
-
Constructor Details
-
Font
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 onfd
- 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 fd argument is null
SWTError
-- ERROR_NO_HANDLES - if a font could not be created from the given font data
- See Also:
-
Font
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 onfds
- 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
- Since:
- 2.1
- See Also:
-
Font
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 onname
- the name of the font (must not be null)height
- the font height in pointsstyle
- 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
- See Also:
-
-
Method Details
-
equals
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison. -
getFontData
Returns an array ofFontData
s representing the receiver. On Windows, only one FontData will be returned per font. On X however, aFont
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
-
hashCode
public int hashCode()Returns an integer hash code for the receiver. Any two objects that returntrue
when passed toequals
must return the same value for this method. -
isDisposed
public boolean isDisposed()Returnstrue
if the font has been disposed, andfalse
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.- Specified by:
isDisposed
in classResource
- Returns:
true
when the font is disposed andfalse
otherwise
-
toString
Returns a string containing a concise, human-readable description of the receiver. -
win32_new
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.- Parameters:
device
- the device on which to allocate the colorhandle
- the handle for the font- Returns:
- a new font object containing the specified device and handle
- Restriction:
- This method is not intended to be referenced by clients.
-
win32_new
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.- Parameters:
device
- the device on which to allocate the fonthandle
- the handle for the fontzoom
- zoom in % of the standard resolution- Returns:
- a new font object containing the specified device and handle
- Since:
- 3.126
- Restriction:
- This method is not intended to be referenced by clients.
-
win32_new
Invokes platform specific private constructor 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.- Parameters:
device
- the device on which to allocate the fontfontData
- font data to create the font forzoom
- zoom in % of the standard resolution- Returns:
- a new font object using the specified font data with the specified zoom as factor for the font data
- Since:
- 3.126
- Restriction:
- This method is not intended to be referenced by clients.
-
win32_new
Used to receive a font for the given zoom in the context of the current configuration of SWT at runtime.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.- Parameters:
font
- font to create a font for the given target zoomtargetZoom
- zoom in % of the standard resolution- Returns:
- a font matching the specified font and zoom in %
- Since:
- 3.126
- Restriction:
- This method is not intended to be referenced by clients.
-