Package com.inductiveautomation.rm.text
Class RMFont
java.lang.Object
com.inductiveautomation.rm.text.RMFont
- All Implemented Interfaces:
Archivable
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.double
charAdvance
(char aChar) Returns the char advance for the given char.charBounds
(char aChar) Returns the bounds for a given character.double
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.deriveFont
(double 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.getBold()
Returns the bold version of this font.static RMFont
Returns the user's default 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
Deprecated.Returns the font file for this font.Returns the name of this font.Returns the name of this font in English.int
double
Returns the height of this font.Returns the italic version of this font.double
Returns the default distance between lines for this font.double
Returns the distance from the top of a line of text to the to top of a successive line of text.double
Returns the height for a line of text in this font.double
Returns the max distance above the baseline that this font goes.double
Returns the max distance below the baseline that this font goes.Returns the PostScript name of this font.double
getSize()
Returns the font size of this font.double
Returns the distance above the baseline that a strikethrough should be drawn.double
Returns the distance below the baseline that an underline should be drawn.double
Returns the default thickness that an underline should be drawn.boolean
isBold()
Returns whether this font is considered bold.boolean
isItalic()
Returns whether this font is considered italic.boolean
Returns whether font had to substitute because name wasn't found.scaleFont
(double aScale) Returns a font with the same family as the receiver but with size adjusted by given scale factor.double
stringAdvance
(String aString) Returns the horizontal distance spanned by the given string when rendered in this font.toggleStyle
(int style) Returns a new RMFont with style toggled.toString()
Returns the font name, size and family for this font.toXML
(RXArchiver anArchiver) XML archival.
-
Field Details
-
Helvetica10
-
Helvetica12
-
Helvetica14
-
-
Constructor Details
-
RMFont
public RMFont()Creates an empty font (really only used for unarchival). -
RMFont
Deprecated.Returns the font for the given name and size. -
RMFont
-
-
Method Details
-
getFont
Deprecated.Returns the font for the given name and size (substitutes Arial if not found). -
getFont
Returns the font for the given name and size (substitutes Arial if not found). -
getDefaultFont
Returns the user's default font. -
getFontName
Returns the name of this font. -
getFontNameEnglish
Returns the name of this font in English. -
getLogicalName
-
getFontStyle
public int getFontStyle() -
getSize
public double getSize()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 double charAdvance(char aChar) Returns the char advance for the given char. -
charKern
public double 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 double getMaxAscent()Returns the max distance above the baseline that this font goes. -
getMaxDescent
public double getMaxDescent()Returns the max distance below the baseline that this font goes. -
getLeading
public double getLeading()Returns the default distance between lines for this font. -
getHeight
public double getHeight()Returns the height of this font. -
getLineHeight
public double getLineHeight()Returns the height for a line of text in this font. -
getLineAdvance
public double getLineAdvance()Returns the distance from the top of a line of text to the to top of a successive line of text. -
getUnderlineOffset
public double getUnderlineOffset()Returns the distance below the baseline that an underline should be drawn. -
getUnderlineThickness
public double getUnderlineThickness()Returns the default thickness that an underline should be drawn. -
getStrikethroughOffset
public double 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. -
isSubstitute
public boolean isSubstitute()Returns whether font had to substitute because name wasn't found. -
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. -
toggleStyle
Returns a new RMFont with style toggled. -
deriveFont
Returns a font with the same family as the receiver but with the given size. -
scaleFont
Returns a font with the same family as the receiver but with size adjusted by given scale factor. -
equals
Standard equals implementation. -
toXML
XML archival.- Specified by:
toXML
in interfaceArchivable
-
fromXML
XML unarchival.- Specified by:
fromXML
in interfaceArchivable
-
toString
Returns the font name, size and family for this font. -
awt
Returns the AWT font for this font.
-