Top Description Fields Constructors Methods
org.eclipse.swt.graphics

public final Class FontData

extends Object
Class Inheritance
Imports
org.eclipse.swt.*

Instances of this class describe operating system fonts.

For platform-independent behaviour, use the get and set methods corresponding to the following properties:

height
the height of the font in points
name
the face name of the font, which may include the foundry
style
A bitwise combination of NORMAL, ITALIC and BOLD
If extra, platform-dependent functionality is required: Application code does not need to explicitly release the resources managed by each instance when those instances are no longer required, and thus no dispose() method is provided.
See Also
Font, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv String
country

The locales of the font

public float
height

The height of the font data in points (Warning: This field is platform dependent)

Important Note

This field is not part of the SWT public API.

pack-priv String
lang

The locales of the font

public String
name

the font name (Warning: This field is platform dependent)

Important Note

This field is not part of the SWT public API.

public byte[]
string

the Pango string (Warning: This field is platform dependent)

Important Note

This field is not part of the SWT public API.

public int
style

the font style (Warning: This field is platform dependent)

Important Note

This field is not part of the SWT public API.

pack-priv String
variant

The locales of the font

Constructor Summary

AccessConstructor and Description
public
FontData()

Constructs a new uninitialized font data.

public
FontData(String
the string representation of a FontData (must not be null)
string
)

Constructs a new FontData given a string representation in the form generated by the FontData.toString method.

public
FontData(String
the name of the font (must not be null)
name
,
int
the font height in points
height
,
int
a bit or combination of NORMAL, BOLD, ITALIC
style
)

Constructs a new font data given a font name, the height of the desired font in points, and a font style.

pack-priv
FontData(String name, float height, int style)

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the object is the same as this object and false otherwise
equals
(Object
the object to compare with this object
object
)

Overrides java.lang.Object.equals.

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

Returns:

the height of this FontData
getHeight
()

Returns the height of the receiver in points.

pack-priv float
public String

Returns:

the String representing a Locale object
getLocale
()

Returns the locale of the receiver.

public String

Returns:

the name of this FontData
getName
()

Returns the name of the receiver.

public int

Returns:

the style of this FontData
getStyle
()

Returns the style of the receiver which is a bitwise OR of one or more of the SWT constants NORMAL, BOLD and ITALIC.

public int

Returns:

the receiver's hash
hashCode
()

Overrides java.lang.Object.hashCode.

Returns an integer hash code for the receiver.
public void
setHeight(int
the height of the FontData
height
)

Sets the height of the receiver.

pack-priv void
setHeight(float height)

public void
setLocale(String
the String representing a Locale object
locale
)

Sets the locale of the receiver.

public void
setName(String
the name of the font data (must not be null)
name
)

Sets the name of the receiver.

public void
setStyle(int
the new style for this FontData
style
)

Sets the style of the receiver to the argument which must be a bitwise OR of one or more of the SWT constants NORMAL, BOLD and ITALIC.

public String

Returns:

a string representation of the FontData
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of the receiver which is suitable for constructing an equivalent instance using the FontData(String) constructor.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

countryback to summary
pack-priv String country

The locales of the font

heightback to summary
public float height

The height of the font data in points (Warning: This field is platform dependent)

Important Note

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.

langback to summary
pack-priv String lang

The locales of the font

nameback to summary
public String name

the font name (Warning: This field is platform dependent)

Important Note

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.

stringback to summary
public byte[] string

the Pango string (Warning: This field is platform dependent)

Important Note

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.

styleback to summary
public int style

the font style (Warning: This field is platform dependent)

Important Note

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.

variantback to summary
pack-priv String variant

The locales of the font

Constructor Detail

FontDataback to summary
public FontData()

Constructs a new uninitialized font data.

FontDataback to summary
public FontData(String string)

Constructs a new FontData given a string representation in the form generated by the FontData.toString method.

Note that the representation varies between platforms, and a FontData can only be created from a string that was generated on the same platform.

Parameters
string:String

the string representation of a FontData (must not be null)

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the argument is null
  • ERROR_INVALID_ARGUMENT - if the argument does not represent a valid description
See Also
toString
FontDataback to summary
public FontData(String name, int height, int style)

Constructs a new font data given a font name, the height of the desired font in points, and a font style.

Parameters
name:String

the name of the font (must not be null)

height:int

the font height in points

style:int

a bit or combination of NORMAL, BOLD, ITALIC

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - when the font name is null
  • ERROR_INVALID_ARGUMENT - if the height is negative
FontDataback to summary
pack-priv FontData(String name, float height, int style)

Method Detail

equalsback to summary
public boolean equals(Object object)

Overrides java.lang.Object.equals.

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

Parameters
object:Object

the object to compare with this object

Returns:boolean

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

Annotations
@Override
See Also
hashCode
getHeightback to summary
public int getHeight()

Returns the height of the receiver in points.

Returns:int

the height of this FontData

See Also
setHeight(int)
getHeightFback to summary
pack-priv float getHeightF()
getLocaleback to summary
public String getLocale()

Returns the locale of the receiver.

The locale determines which platform character set this font is going to use. Widgets and graphics operations that use this font will convert UNICODE strings to the platform character set of the specified locale.

On platforms where there are multiple character sets for a given language/country locale, the variant portion of the locale will determine the character set.

Returns:String

the String representing a Locale object

Since
3.0
getNameback to summary
public String getName()

Returns the name of the receiver. On platforms that support font foundries, the return value will be the foundry followed by a dash ("-") followed by the face name.

Returns:String

the name of this FontData

See Also
setName
getStyleback to summary
public int getStyle()

Returns the style of the receiver which is a bitwise OR of one or more of the SWT constants NORMAL, BOLD and ITALIC.

Returns:int

the style of this FontData

See Also
setStyle
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.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:int

the receiver's hash

Annotations
@Override
See Also
equals
setHeightback to summary
public void setHeight(int height)

Sets the height of the receiver. The parameter is specified in terms of points, where a point is one seventy-second of an inch.

Parameters
height:int

the height of the FontData

Exceptions
IllegalArgumentException:
  • ERROR_INVALID_ARGUMENT - if the height is negative
See Also
getHeight
setHeightback to summary
pack-priv void setHeight(float height)
setLocaleback to summary
public void setLocale(String locale)

Sets the locale of the receiver.

The locale determines which platform character set this font is going to use. Widgets and graphics operations that use this font will convert UNICODE strings to the platform character set of the specified locale.

On platforms where there are multiple character sets for a given language/country locale, the variant portion of the locale will determine the character set.

Parameters
locale:String

the String representing a Locale object

See Also
java.util.Locale#toString
setNameback to summary
public void setName(String name)

Sets the name of the receiver.

Some platforms support font foundries. On these platforms, the name of the font specified in setName() may have one of the following forms:

  1. a face name (for example, "courier")
  2. a foundry followed by a dash ("-") followed by a face name (for example, "adobe-courier")

In either case, the name returned from getName() will include the foundry.

On platforms that do not support font foundries, only the face name (for example, "courier") is used in setName() and getName().

Parameters
name:String

the name of the font data (must not be null)

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - when the font name is null
See Also
getName
setStyleback to summary
public void setStyle(int style)

Sets the style of the receiver to the argument which must be a bitwise OR of one or more of the SWT constants NORMAL, BOLD and ITALIC. All other style bits are ignored.

Parameters
style:int

the new style for this FontData

See Also
getStyle
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of the receiver which is suitable for constructing an equivalent instance using the FontData(String) constructor.

Returns:String

a string representation of the FontData

Annotations
@Override
See Also
FontData