Class Font

java.lang.Object
ro.sync.exml.view.graphics.Font

@API(type=EXTENDABLE, src=PRIVATE) public class Font extends Object
Font common class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The bold style constant.
    static final int
    The italicized style constant.
    static final int
    The plain style constant.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Font(String name, int style, int size)
    Creates a new Font from the specified name, style and point size.
    Font(String name, int style, int size, int letterSpacing)
    Creates a new Font from the specified name, style and point size.
    Font(String name, int style, int size, int letterSpacing, String[] fontFamilies)
    Creates a new Font from the specified name, style and point size.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Font
    Decodes a font property value, having the format "name,style,size"
    static String
    Encodes a font as: "name,style,size"
    boolean
    Checks if the two colors have the same RGB value.
    Get the array of font names.
    int
    Get the letter spacing.
     
    int
     
    int
     
     
    static final String
    hash(String[] fontNames, int style, int size, int letterSpacing)
    Hash the font
    static final String
    hash(String name, int style, int size)
    Hash the font
    static final String
    hash(String fontFamily, int style, int size, int letterSpacing)
    Hash the font
    int
     
    boolean
    Indicates whether or not this Font object's style is BOLD.
    boolean
    Indicates whether or not this Font object's style is ITALIC.
    boolean
    Indicates whether or not this Font object's style is PLAIN.
    Converts this Font object to a String representation.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • PLAIN

      public static final int PLAIN
      The plain style constant.
      See Also:
    • BOLD

      public static final int BOLD
      The bold style constant. This can be combined with the other style constants (except PLAIN) for mixed styles.
      See Also:
    • ITALIC

      public static final int ITALIC
      The italicized style constant. This can be combined with the other style constants (except PLAIN) for mixed styles.
      See Also:
  • Constructor Details

    • Font

      public Font(String name, int style, int size)
      Creates a new Font from the specified name, style and point size.
      Parameters:
      name - the font name. This can be a logical font name or a font face name. A logical name must be either: Dialog, DialogInput, Monospaced, Serif, or SansSerif. If name is null, the name of the new Font is set to the name "Default".
      style - the style constant for the Font The style argument is an integer bitmask that may be PLAIN, or a bitwise union of BOLD and/or ITALIC (for example, ITALIC or BOLD|ITALIC).
      size - the point size of the Font
    • Font

      public Font(String name, int style, int size, int letterSpacing)
      Creates a new Font from the specified name, style and point size.
      Parameters:
      name - the font name. This can be a logical font name or a font face name. A logical name must be either: Dialog, DialogInput, Monospaced, Serif, or SansSerif. If name is null, the name of the new Font is set to the name "Default".
      style - the style constant for the Font The style argument is an integer bitmask that may be PLAIN, or a bitwise union of BOLD and/or ITALIC (for example, ITALIC or BOLD|ITALIC).
      size - the point size of the Font
      letterSpacing - MThe amount of advance pixels. Default is "0".
    • Font

      public Font(String name, int style, int size, int letterSpacing, String[] fontFamilies)
      Creates a new Font from the specified name, style and point size.
      Parameters:
      name - the font name. This can be a logical font name or a font face name. A logical name must be either: Dialog, DialogInput, Monospaced, Serif, or SansSerif. If name is null, the name of the new Font is set to the name "Default".
      style - the style constant for the Font The style argument is an integer bitmask that may be PLAIN, or a bitwise union of BOLD and/or ITALIC (for example, ITALIC or BOLD|ITALIC).
      size - the point size of the Font
      letterSpacing - MThe amount of advance pixels. Default is "0".
      fontFamilies - The array of font families. The first entry from the array should be the same as the name parameter (the main font family name). The next entries are fallback family names, used when the main font does not support all the glyphs. This is cloned, for immutability.
  • Method Details

    • getName

      public String getName()
      Returns:
      The name
    • getSize

      public int getSize()
      Returns:
      The size
    • getStyle

      public int getStyle()
      Returns:
      The style
    • getLetterSpacing

      public int getLetterSpacing()
      Get the letter spacing.
      Returns:
      Returns the letterSpacing.
    • toString

      public String toString()
      Converts this Font object to a String representation.
      Overrides:
      toString in class Object
      Returns:
      a String representation of this Font object.
    • isPlain

      public boolean isPlain()
      Indicates whether or not this Font object's style is PLAIN.
      Returns:
      true if this Font has a PLAIN sytle; false otherwise.
      See Also:
    • isBold

      public boolean isBold()
      Indicates whether or not this Font object's style is BOLD.
      Returns:
      true if this Font object's style is BOLD; false otherwise.
      See Also:
    • isItalic

      public boolean isItalic()
      Indicates whether or not this Font object's style is ITALIC.
      Returns:
      true if this Font object's style is ITALIC; false otherwise.
      See Also:
    • hash

      public String hash()
      Returns:
      A hash of the font
    • hash

      public static final String hash(String name, int style, int size)
      Hash the font
      Parameters:
      name - The the font main family one
      style - Style
      size - Size
      Returns:
      The hash
    • hash

      public static final String hash(String fontFamily, int style, int size, int letterSpacing)
      Hash the font
      Parameters:
      fontFamily - The the font main family one
      style - Style
      size - Size
      letterSpacing - Letter spacing in pixels
      Returns:
      The hash
    • hash

      public static final String hash(String[] fontNames, int style, int size, int letterSpacing)
      Hash the font
      Parameters:
      fontNames - The list of font names, the main one and the fallback ones.
      style - Style
      size - Size
      letterSpacing - Letter spacing in pixels
      Returns:
      The hash
    • equals

      public boolean equals(Object obj)
      Checks if the two colors have the same RGB value. The alpha is also taken into account.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • encodeFont

      public static String encodeFont(Font font)
      Encodes a font as: "name,style,size"
      Parameters:
      font - The font to be encoded.
      Returns:
      The encoded value.
    • decodeFont

      public static Font decodeFont(String value)
      Decodes a font property value, having the format "name,style,size"
      Parameters:
      value - The value to be decoded.
      Returns:
      The font.
    • getFontNames

      public String[] getFontNames()
      Get the array of font names. The first entry from the array should be the same as the name parameter (the main font family name). The next entries are fallback family names, used when the main font does not support all the glyphs.
      Returns:
      The entire list of font names, including the main one (on the first position), and the fallback ones.