Class FontData


  • public final class FontData
    extends java.lang.Object
    Instances of this class describe fonts.

    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.

    Since:
    1.0
    See Also:
    Font
    • Constructor Summary

      Constructors 
      Constructor Description
      FontData()
      Constructs a new uninitialized font data.
      FontData​(java.lang.String string)
      Constructs a new FontData given a string representation in the form generated by the FontData.toString method.
      FontData​(java.lang.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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)
      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.
      java.lang.String getLocale()
      Returns the locale of the receiver.
      java.lang.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​(java.lang.String locale)
      Sets the locale of the receiver.
      void setName​(java.lang.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.
      java.lang.String toString()
      Returns a string representation of the receiver which is suitable for constructing an equivalent instance using the FontData(String) constructor.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • FontData

        public FontData()
        Constructs a new uninitialized font data.
        Since:
        1.4
      • FontData

        public FontData​(java.lang.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:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - when the font name is null
        • ERROR_INVALID_ARGUMENT - if the height is negative
      • FontData

        public FontData​(java.lang.String string)
        Constructs a new FontData given a string representation in the form generated by the FontData.toString method.
        Parameters:
        string - the string representation of a FontData (must not be null)
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the argument is null
        • ERROR_INVALID_ARGUMENT - if the argument does not represent a valid description
        See Also:
        toString()
    • Method Detail

      • toString

        public java.lang.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 java.lang.Object
        Returns:
        a string representation of the FontData
      • getHeight

        public int getHeight()
        Returns the height of the receiver in points.
        Returns:
        the height of this FontData
        See Also:
        setHeight(int)
      • getName

        public java.lang.String getName()
        Returns the name of the receiver.
        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)
      • getLocale

        public java.lang.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:
        1.3
      • 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:
        java.lang.IllegalArgumentException -
        • ERROR_INVALID_ARGUMENT - if the height is negative
        Since:
        1.4
        See Also:
        getHeight()
      • setName

        public void setName​(java.lang.String name)
        Sets the name of the receiver.
        Parameters:
        name - the name of the font data (must not be null)
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - when the font name is null
        Since:
        1.4
        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
        Since:
        1.4
        See Also:
        getStyle()
      • setLocale

        public void setLocale​(java.lang.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
        Since:
        1.4
        See Also:
        Locale.toString()
      • equals

        public boolean equals​(java.lang.Object obj)
        Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the object to compare with this object
        Returns:
        true if the object is the same as this object and false otherwise
        See Also:
        hashCode()
      • 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 java.lang.Object
        Returns:
        the receiver's hash
        See Also:
        equals(java.lang.Object)