Package greenfoot
Class Font
java.lang.Object
greenfoot.Font
A representation of a Font. The Font can be used to write text on the screen.
-
Constructor Summary
ConstructorsConstructorDescriptionFont(boolean bold, boolean italic, int size) Creates a sans serif font with the specified size and style.Font(int size) Creates a sans serif font of a given size.Creates a font from the specified font name, size and style.Creates a font from the specified font name and size. -
Method Summary
Modifier and TypeMethodDescriptionderiveFont(float size) Creates a newFontobject by cloning the current one and then applying a new size to it.boolean* Determines whether another object is equal to this font.getName()Returns the logical name of this font.intgetSize()Returns the point size of this font, rounded to an integer.inthashCode()Returns a hashcode for this font.booleanisBold()Indicates whether or not this Font style is bold.booleanisItalic()Indicates whether or not this Font style is italic.booleanisPlain()Indicates whether or not this Font style is plain.toString()Return a text representation of the font.
-
Constructor Details
-
Font
Creates a font from the specified font name, size and style.- Parameters:
name- The font namebold- True if the font is meant to be bolditalic- True if the font is meant to be italicsize- The size of the font
-
Font
public Font(boolean bold, boolean italic, int size) Creates a sans serif font with the specified size and style.- Parameters:
bold- True if the font is meant to be bolditalic- True if the font is meant to be italicsize- The size of the font
-
Font
Creates a font from the specified font name and size.- Parameters:
name- The font namesize- The size of the font
-
Font
public Font(int size) Creates a sans serif font of a given size.- Parameters:
size- The size of the font
-
-
Method Details
-
isPlain
public boolean isPlain()Indicates whether or not this Font style is plain.- Returns:
- true if this font style is plain; false otherwise
-
isBold
public boolean isBold()Indicates whether or not this Font style is bold.- Returns:
- true if this font style is bold; false otherwise
-
isItalic
public boolean isItalic()Indicates whether or not this Font style is italic.- Returns:
- true if this font style is italic; false otherwise
-
getName
Returns the logical name of this font.- Returns:
- a
Stringrepresenting the logical name of this font.
-
getSize
public int getSize()Returns the point size of this font, rounded to an integer.- Returns:
- the point size of this font in 1/72 of an inch units.
-
deriveFont
Creates a newFontobject by cloning the current one and then applying a new size to it.- Parameters:
size- the size for the newFont.- Returns:
- a new
Fontobject.
-
equals
* Determines whether another object is equal to this font. -
hashCode
public int hashCode()Returns a hashcode for this font. -
toString
Return a text representation of the font.
-