Class TTFont

  • All Implemented Interfaces:
    TextFont

    public class TTFont
    extends java.lang.Object
    implements TextFont
    Represents a TrueType font that can be used to draw text.

    There are two ways to obtain a font. The first is to create an instance of this class manually, which will use the local system fonts. If no font with the requested name is available, this will revert to the system's default font. The second approach is to load a font from a .ttf file using the MediaLoader class. This ensures that the requested font is available.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_SIZE  
    • Constructor Summary

      Constructors 
      Constructor Description
      TTFont​(java.lang.String family, int size, ColorRGB color)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      TTFont derive​(int newSize)
      Returns a version of this font that uses the same font family and color, but has a different size.
      TTFont derive​(ColorRGB newColor)
      Returns a version of this font which uses the same font family and size, but has a different color.
      TTFont deriveBold()
      Returns a bold version of this font.
      boolean equals​(java.lang.Object o)  
      ColorRGB getColor()  
      java.lang.String getFamily()  
      int getSize()  
      int hashCode()  
      boolean isBold()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • TTFont

        public TTFont​(java.lang.String family,
                      int size,
                      ColorRGB color)
    • Method Detail

      • getFamily

        public java.lang.String getFamily()
        Specified by:
        getFamily in interface TextFont
      • getSize

        public int getSize()
        Specified by:
        getSize in interface TextFont
      • isBold

        public boolean isBold()
      • derive

        public TTFont derive​(int newSize)
        Description copied from interface: TextFont
        Returns a version of this font that uses the same font family and color, but has a different size.
        Specified by:
        derive in interface TextFont
      • derive

        public TTFont derive​(ColorRGB newColor)
        Description copied from interface: TextFont
        Returns a version of this font which uses the same font family and size, but has a different color.
        Specified by:
        derive in interface TextFont
      • deriveBold

        public TTFont deriveBold()
        Description copied from interface: TextFont
        Returns a bold version of this font. All all properties will be identical to the current font.
        Specified by:
        deriveBold in interface TextFont
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object