Class BitmapFont

  • All Implemented Interfaces:
    TextFont

    public class BitmapFont
    extends java.lang.Object
    implements TextFont
    Describes a font that consists of a number of images. This type of font is generally used for environments that do not support rendering TrueType fonts, though the performance of bitmap fonts also tends to be better.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      BitmapFont derive​(int newSize)
      Returns a version of this font that uses the same font family and color, but has a different size.
      BitmapFont derive​(ColorRGB newColor)
      Returns a version of this font which uses the same font family and size, but has a different color.
      BitmapFont deriveBold()
      Returns a bold version of this font.
      void draw​(GraphicsContext context, java.lang.String text, float x, float y, Align align, AlphaTransform alpha)
      Draws a text with this bitmap font using the specified graphics context.
      protected int getBase()  
      protected Rect getBounds​(char c)  
      java.lang.String getFamily()  
      protected int getLineHeight()  
      int getSize()  
      static BitmapFont parseFNT​(Image image, java.lang.String fntMetadata)
      Creates a bitmap font from an image and metadata parsed from a .fnt file using the AngelCode font format.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getFamily

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

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

        protected int getLineHeight()
      • getBase

        protected int getBase()
      • getBounds

        protected Rect getBounds​(char c)
      • derive

        public BitmapFont 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 BitmapFont 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 BitmapFont 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
      • draw

        public void draw​(GraphicsContext context,
                         java.lang.String text,
                         float x,
                         float y,
                         Align align,
                         AlphaTransform alpha)
        Draws a text with this bitmap font using the specified graphics context. This method will trigger several drawing operations to draw the various sub-images.
      • parseFNT

        public static BitmapFont parseFNT​(Image image,
                                          java.lang.String fntMetadata)
        Creates a bitmap font from an image and metadata parsed from a .fnt file using the AngelCode font format. AngelCode fonts can be created using various tools, such as libGDX Hiero (https://github.com/libgdx/libgdx/wiki/Hiero).
        Throws:
        MediaException - if the font metadata cannot be parsed.