Class TTFont


  • public class TTFont
    extends java.lang.Object
    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.
      boolean equals​(java.lang.Object o)  
      ColorRGB getColor()  
      java.lang.String getFamily()  
      int getSize()  
      int hashCode()  
      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()
      • getSize

        public int getSize()
      • derive

        public TTFont derive​(int newSize)
        Returns a version of this font that uses the same font family and color, but has a different size.
      • derive

        public TTFont derive​(ColorRGB newColor)
        Returns a version of this font which uses the same font family and size, but has a different color.
      • 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