Package com.reportmill.text
Class RMFont
java.lang.Object
com.reportmill.base.RMObject
com.reportmill.text.RMFont
- All Implemented Interfaces:
RMArchiver.Archiving
,Cloneable
This class represents a font for use in rich text. Currently this is necessary because Java fonts are missing
so much basic typographic information.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionawt()
Returns the AWT font for this font.boolean
canDisplay
(char aChar) Returns if this font can display the given char.float
charAdvance
(char aChar) Returns the char advance for the given char.charBounds
(char aChar) Returns the bounds for a given character.float
charKern
(char aChar1, char aChar2) Returns the kerning for the given pair of characters (no way to do this in Java!).charPath
(char c) Returns the path for a given character.static RMFont
Returns the user's default font.deriveFont
(float aPointSize) Returns a font with the same family as the receiver but with the given size.boolean
Standard equals implementation.fromXML
(RXArchiver anArchiver, RXElement anElement) XML unarchival.static List
Returns the list of suggested alternate fonts.getBold()
Returns the bold version of this font.Returns the family name of this font.Returns the family name of this font in English.static RMFont
Returns the font for the given name and size (substitutes Arial if not found).static RMFont
Returns the font for the given name and size (with an option to substitue Arial if not found).Returns the font file for this font.Returns the name of this font.Returns the name of this font in English.float
Returns the height of this font.Returns the italic version of this font.float
Returns the default distance between lines for this font.float
Returns the height for a line of text in this font.float
Returns the max distance above the baseline that this font goes.float
Returns the max distance below the baseline that this font goes.Returns the PostScript name of this font.float
Returns the font size of this font.float
Returns the distance above the baseline that a strikethrough should be drawn.float
Returns the distance below the baseline that an underline should be drawn.float
Returns the default thickness that an underline should be drawn.initWithArchiver
(RMArchiver anArchiver) Legacy unarchival.boolean
isBold()
Returns whether this font is considered bold.boolean
isItalic()
Returns whether this font is considered italic.float
stringAdvance
(String aString) Returns the horizontal distance spanned by the given string when rendered in this font.int
style()
Returns the awt style of this font.toString()
Returns the font name, size and family for this font.toXML
(RXArchiver anArchiver) XML archival.Methods inherited from class com.reportmill.base.RMObject
clone, copy, didChange, didUndo, getAnimAttribute, getClassNameShort, undoClone, undoCopy, undoEquals
-
Field Details
-
PLAIN
public static final byte PLAIN- See Also:
-
BOLD
public static final byte BOLD- See Also:
-
ITALIC
public static final byte ITALIC- See Also:
-
Helvetica10
-
Helvetica12
-
Helvetica14
-
-
Constructor Details
-
RMFont
public RMFont()Creates an empty font (really only used for unarchival).
-
-
Method Details
-
getFont
Returns the font for the given name and size (substitutes Arial if not found). -
getFont
Returns the font for the given name and size (with an option to substitue Arial if not found). -
defaultFont
Returns the user's default font. -
awt
Returns the AWT font for this font. -
getFontName
Returns the name of this font. -
getFontNameEnglish
Returns the name of this font in English. -
getSize2D
public float getSize2D()Returns the font size of this font. -
getFamily
Returns the family name of this font. -
getFamilyEnglish
Returns the family name of this font in English. -
getPSName
Returns the PostScript name of this font. -
getFontFile
Returns the font file for this font. -
charAdvance
public float charAdvance(char aChar) Returns the char advance for the given char. -
charKern
public float charKern(char aChar1, char aChar2) Returns the kerning for the given pair of characters (no way to do this in Java!). -
charPath
Returns the path for a given character. -
charBounds
Returns the bounds for a given character. -
stringAdvance
Returns the horizontal distance spanned by the given string when rendered in this font. -
getMaxAscent
public float getMaxAscent()Returns the max distance above the baseline that this font goes. -
getMaxDescent
public float getMaxDescent()Returns the max distance below the baseline that this font goes. -
getLeading
public float getLeading()Returns the default distance between lines for this font. -
getHeight
public float getHeight()Returns the height of this font. -
getLineHeight
public float getLineHeight()Returns the height for a line of text in this font. -
getUnderlineOffset
public float getUnderlineOffset()Returns the distance below the baseline that an underline should be drawn. -
getUnderlineThickness
public float getUnderlineThickness()Returns the default thickness that an underline should be drawn. -
getStrikethroughOffset
public float getStrikethroughOffset()Returns the distance above the baseline that a strikethrough should be drawn. -
isBold
public boolean isBold()Returns whether this font is considered bold. -
isItalic
public boolean isItalic()Returns whether this font is considered italic. -
style
public int style()Returns the awt style of this font. -
canDisplay
public boolean canDisplay(char aChar) Returns if this font can display the given char. -
getBold
Returns the bold version of this font. -
getItalic
Returns the italic version of this font. -
deriveFont
Returns a font with the same family as the receiver but with the given size. -
getAltFonts
Returns the list of suggested alternate fonts. -
equals
Standard equals implementation. -
initWithArchiver
Legacy unarchival.- Specified by:
initWithArchiver
in interfaceRMArchiver.Archiving
- Overrides:
initWithArchiver
in classRMObject
-
toXML
XML archival. -
fromXML
XML unarchival. -
toString
Returns the font name, size and family for this font.
-