Font

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 <code>FontData</code> object which encapsulates this data. <p> Application code must explicitly invoke the <code>Font.dispose()</code> method to release the operating system resources managed by each instance when those instances are no longer required. </p>

@see FontData @see <a href="http://www.eclipse.org/swt/snippets/#font">Font snippets</a> @see <a href="http://www.eclipse.org/swt/examples.php">SWT Examples: GraphicsExample, PaintExample</a> @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>

Constructors

this
this(Device device, FontData fd)

Constructs a new font given a device and font data which describes the desired font's appearance. <p> You must dispose the font when it is no longer required. </p>

this
this(Device device, FontData[] fds)

Constructs a new font given a device and an array of font data which describes the desired font's appearance. <p> You must dispose the font when it is no longer required. </p>

this
this(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. <p> You must dispose the font when it is no longer required. </p>

Members

Functions

getFontData
FontData[] getFontData()

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

isDisposed
bool isDisposed()

Returns <code>true</code> if the font has been disposed, and <code>false</code> otherwise. <p> This method gets the dispose state for the font. When a font has been disposed, it is an error to invoke any other method using the font.

opEquals
equals_t opEquals(Object object)

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

toHash
hash_t toHash()

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

toString
String toString()

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

Static functions

gtk_new
Font gtk_new(Device device, PangoFontDescription* handle)

Invokes platform specific functionality to allocate a new font. <p> <b>IMPORTANT:</b> This method is <em>not</em> part of the public API for <code>Font</code>. 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. </p>

Variables

handle
PangoFontDescription* handle;

the handle to the OS font resource (Warning: This field is platform dependent) <p> <b>IMPORTANT:</b> This field is <em>not</em> 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. </p>

Inherited Members

From Resource

device
Device device;

the device where this resource was created

dispose
void dispose()

Disposes of the operating system resources associated with this resource. Applications must dispose of all resources which they allocate.

getDevice
Device getDevice()

Returns the <code>Device</code> where this resource was created.

isDisposed
bool isDisposed()

Returns <code>true</code> if the resource has been disposed, and <code>false</code> otherwise. <p> This method gets the dispose state for the resource. When a resource has been disposed, it is an error to invoke any other method using the resource.

Meta