Package lejos.hardware.lcd
Class Font
- java.lang.Object
-
- lejos.hardware.lcd.Font
-
- All Implemented Interfaces:
java.io.Serializable
public class Font extends java.lang.Object implements java.io.SerializableProvides 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
-
-
Field Summary
Fields Modifier and Type Field Description intbaseintfirstCharintglyphCountbyte[]glyphsintglyphWidthintheightstatic intSIZE_LARGEstatic intSIZE_MEDIUMstatic intSIZE_SMALLintwidth
-
Constructor Summary
Constructors Modifier Constructor Description protectedFont(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
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetBaselinePosition()Return the base line position in pixels.static FontgetDefaultFont()Return the system font.static FontgetFont(int face, int style, int size)Request a particular type and size of font.intgetHeight()return the height of the font in pixels.static FontgetLargeFont()Return the large font.static FontgetSmallFont()Return the small font.intstringWidth(java.lang.String str)Return the width of the specified string in pixels
-
-
-
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
-
SIZE_SMALL
public static final int SIZE_SMALL
- See Also:
- Constant Field Values
-
SIZE_MEDIUM
public static final int SIZE_MEDIUM
- See Also:
- Constant Field Values
-
SIZE_LARGE
public static final int SIZE_LARGE
- See Also:
- Constant Field Values
-
-
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
-
-