Class Font

  • All Implemented Interfaces:
    java.io.Serializable

    public class Font
    extends java.lang.Object
    implements java.io.Serializable
    Provides access to fonts for use with the display or images. The actual font data is held as a series of glyphs with all inter character spacing removed. The format of the bitmap is in standard leJOS format (so aligned for use on NXT LCD display). There is one bit per pixel. The pixels are packed into bytes with each byte spanning 8 scan lines. The least significant bit of each byte is the pixel for the top most scan line, the most significant bit is the 8th scan line. Values of 1 represent black. 0 white.
    Author:
    Andy
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Font​(byte[] glyphs, int width, int height, int base, int glyphWidth, int count, int first)
      Create a new font for the specified NXT format glyph map
    • Field Detail

      • width

        public final int width
      • height

        public final int height
      • glyphWidth

        public final int glyphWidth
      • glyphCount

        public final int glyphCount
      • firstChar

        public final int firstChar
      • base

        public final int base
      • glyphs

        public final byte[] glyphs
    • Constructor Detail

      • Font

        protected Font​(byte[] glyphs,
                       int width,
                       int height,
                       int base,
                       int glyphWidth,
                       int count,
                       int first)
        Create a new font for the specified NXT format glyph map
        Parameters:
        glyphs - the actual bytes of the glyph.
        width - The cell width.
        height - The cell height.
        glyphWidth - The width of the glyph bits.
    • Method Detail

      • getDefaultFont

        public static Font getDefaultFont()
        Return the system font.
        Returns:
        current system font object
      • getHeight

        public int getHeight()
        return the height of the font in pixels.
        Returns:
        pixel height
      • getBaselinePosition

        public int getBaselinePosition()
        Return the base line position in pixels. This is the offset from the top of the font.
        Returns:
        base position.
      • stringWidth

        public int stringWidth​(java.lang.String str)
        Return the width of the specified string in pixels
        Parameters:
        str -
        Returns:
        width of the string
      • getFont

        public static Font getFont​(int face,
                                   int style,
                                   int size)
        Request a particular type and size of font. Currently only the size parameter is used and it should be one of SIZE_SMALL, SIZE_MEDIUM or SIZE_LARGE.
        Parameters:
        face -
        style -
        size -
        Returns:
        The requested Font
      • getSmallFont

        public static Font getSmallFont()
        Return the small font.
        Returns:
        the small font
      • getLargeFont

        public static Font getLargeFont()
        Return the large font.
        Returns:
        the large font