Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.swt.graphics
Class FontData


java.lang.Object
  extended by 
org.eclipse.swt.graphics.FontData

public final class FontData
extends Object

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:
  • On Windows, the data member of the FontData corresponds to a Windows LOGFONT structure whose fields may be retrieved and modified.
  • On X, the fields of the FontData correspond to the entries in the font's XLFD name and may be retrieved and modified.
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
 org.eclipse.swt.internal.win32.LOGFONT data
          A Win32 LOGFONT struct (Warning: This field is platform dependent) IMPORTANT: This field is not part of the SWT public API.
 float height
          The height of the font data in points (Warning: This field is platform dependent) IMPORTANT: This field is not part of the SWT public API.
 
Constructor Summary
FontData ()
          Constructs a new uninitialized font data.
FontData ( String string)
          Constructs a new FontData given a string representation in the form generated by the FontData.toString method.
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.
 
Method Summary
 boolean equals ( Object object)
          Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
 int getHeight ()
          Returns the height of the receiver in points.
  String getLocale ()
          Returns the locale of the receiver.
  String getName ()
          Returns the name of the receiver.
 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.
 int hashCode ()
          Returns an integer hash code for the receiver.
 void setHeight (int height)
          Sets the height of the receiver.
 void setLocale ( String locale)
          Sets the locale of the receiver.
 void setName ( String name)
          Sets the name of the receiver.
 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.
  String toString ()
          Returns a string representation of the receiver which is suitable for constructing an equivalent instance using the FontData(String) constructor.
static  FontData win32_new (org.eclipse.swt.internal.win32.LOGFONT data, float height)
          Invokes platform specific functionality to allocate a new font data.
 
Methods inherited from class java.lang. Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

data

public org.eclipse.swt.internal.win32.LOGFONT data
A Win32 LOGFONT struct (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.


height

public float height
The height of the font data in points (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.

Constructor Detail

FontData

public FontData()
Constructs a new uninitialized font data.


FontData

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 - the string representation of a FontData (must not be null)
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the argument is null
  • ERROR_INVALID_ARGUMENT - if the argument does not represent a valid description
See Also:
toString()

FontData

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 - the name of the font (must not be null)
height - the font height in points
style - a bit or combination of NORMAL, BOLD, ITALIC
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - when the font name is null
  • ERROR_INVALID_ARGUMENT - if the height is negative
Method Detail

equals

public boolean equals(
Object object)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.

Overrides:
equals in class Object
Parameters:
object - the object to compare with this object
Returns:
true if the object is the same as this object and false otherwise
See Also:
hashCode()

getHeight

public int getHeight()
Returns the height of the receiver in points.

Returns:
the height of this FontData
See Also:
setHeight(int)

getLocale

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:
the String representing a Locale object
Since:
3.0

getName

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:
the name of this FontData
See Also:
setName(java.lang.String)

getStyle

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:
the style of this FontData
See Also:
setStyle(int)

hashCode

public int 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.

Overrides:
hashCode in class Object
Returns:
the receiver's hash
See Also:
equals(java.lang.Object)

setHeight

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 - the height of the FontData
Throws:
IllegalArgumentException -
  • ERROR_INVALID_ARGUMENT - if the height is negative
See Also:
getHeight()

setLocale

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 - the String representing a Locale object
See Also:
Locale.toString()

setName

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 - the name of the font data (must not be null)
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - when the font name is null
See Also:
getName()

setStyle

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 - the new style for this FontData
See Also:
getStyle()

toString

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

Overrides:
toString in class Object
Returns:
a string representation of the FontData
See Also:
FontData

win32_new

public static 
FontData win32_new(org.eclipse.swt.internal.win32.LOGFONT data,
                                 float height)
Invokes platform specific functionality to allocate a new font data.

IMPORTANT: This method is not part of the public API for FontData. 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:
data - the LOGFONT for the font data
height - the height of the font data
Returns:
a new font data object containing the specified LOGFONT and height

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire