ReportMill 10 API

com.reportmill.text
Class RMFont

java.lang.Object
  extended by com.reportmill.base.RMObject
      extended by com.reportmill.text.RMFont
All Implemented Interfaces:
java.lang.Cloneable

public class RMFont
extends com.reportmill.base.RMObject

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
static byte BOLD
           
static RMFont Helvetica10
           
static RMFont Helvetica12
           
static RMFont Helvetica14
           
static byte ITALIC
           
static byte PLAIN
           
 
Constructor Summary
RMFont()
          Creates an empty font (really only used for unarchival).
 
Method Summary
 java.awt.Font awt()
          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.
 RMRect 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!).
 RMPath charPath(char c)
          Returns the path for a given character.
static RMFont defaultFont()
          Returns the user's default font.
 RMFont deriveFont(float aPointSize)
          Returns a font with the same family as the receiver but with the given size.
 boolean equals(java.lang.Object anObj)
          Standard equals implementation.
 java.lang.Object fromXML(com.reportmill.archiver.RXArchiver anArchiver, com.reportmill.archiver.RXElement anElement)
          XML unarchival.
static java.util.List getAltFonts()
          Returns the list of suggested alternate fonts.
 RMFont getBold()
          Returns the bold version of this font.
 java.lang.String getFamily()
          Returns the family name of this font.
 java.lang.String getFamilyEnglish()
          Returns the family name of this font in English.
static RMFont getFont(java.lang.String aName, float aSize)
          Returns the font for the given name and size (substitutes Arial if not found).
static RMFont getFont(java.lang.String aName, float aSize, boolean substitute)
          Returns the font for the given name and size (with an option to substitue Arial if not found).
 com.reportmill.text.RMFontFile getFontFile()
          Returns the font file for this font.
 java.lang.String getFontName()
          Returns the name of this font.
 java.lang.String getFontNameEnglish()
          Returns the name of this font in English.
 float getHeight()
          Returns the height of this font.
 RMFont getItalic()
          Returns the italic version of this font.
 float getLeading()
          Returns the default distance between lines for this font.
 float getLineHeight()
          Returns the height for a line of text in this font.
 float getMaxAscent()
          Returns the max distance above the baseline that this font goes.
 float getMaxDescent()
          Returns the max distance below the baseline that this font goes.
 java.lang.String getPSName()
          Returns the PostScript name of this font.
 float getSize2D()
          Returns the font size of this font.
 float getStrikethroughOffset()
          Returns the distance above the baseline that a strikethrough should be drawn.
 float getUnderlineOffset()
          Returns the distance below the baseline that an underline should be drawn.
 float getUnderlineThickness()
          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.
 RMFont scaleFont(float aScale)
          Returns a font with the same family as the receiver but with size adjusted by given scale factor.
 float stringAdvance(java.lang.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.
 java.lang.String toString()
          Returns the font name, size and family for this font.
 com.reportmill.archiver.RXElement toXML(com.reportmill.archiver.RXArchiver anArchiver)
          XML archival.
 
Methods inherited from class com.reportmill.base.RMObject
clone, copy, didChange, didUndo, getAnimAttribute, getClassNameShort, undoClone, undoCopy, undoEquals
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PLAIN

public static final byte PLAIN
See Also:
Constant Field Values

BOLD

public static final byte BOLD
See Also:
Constant Field Values

ITALIC

public static final byte ITALIC
See Also:
Constant Field Values

Helvetica10

public static RMFont Helvetica10

Helvetica12

public static RMFont Helvetica12

Helvetica14

public static RMFont Helvetica14
Constructor Detail

RMFont

public RMFont()
Creates an empty font (really only used for unarchival).

Method Detail

getFont

public static RMFont getFont(java.lang.String aName,
                             float aSize)
Returns the font for the given name and size (substitutes Arial if not found).


getFont

public static RMFont getFont(java.lang.String aName,
                             float aSize,
                             boolean substitute)
Returns the font for the given name and size (with an option to substitue Arial if not found).


defaultFont

public static RMFont defaultFont()
Returns the user's default font.


awt

public java.awt.Font awt()
Returns the AWT font for this font.


getFontName

public java.lang.String getFontName()
Returns the name of this font.


getFontNameEnglish

public java.lang.String getFontNameEnglish()
Returns the name of this font in English.


getSize2D

public float getSize2D()
Returns the font size of this font.


getFamily

public java.lang.String getFamily()
Returns the family name of this font.


getFamilyEnglish

public java.lang.String getFamilyEnglish()
Returns the family name of this font in English.


getPSName

public java.lang.String getPSName()
Returns the PostScript name of this font.


getFontFile

public com.reportmill.text.RMFontFile 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

public RMPath charPath(char c)
Returns the path for a given character.


charBounds

public RMRect charBounds(char aChar)
Returns the bounds for a given character.


stringAdvance

public float stringAdvance(java.lang.String aString)
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

public RMFont getBold()
Returns the bold version of this font.


getItalic

public RMFont getItalic()
Returns the italic version of this font.


deriveFont

public RMFont deriveFont(float aPointSize)
Returns a font with the same family as the receiver but with the given size.


scaleFont

public RMFont scaleFont(float aScale)
Returns a font with the same family as the receiver but with size adjusted by given scale factor.


getAltFonts

public static java.util.List getAltFonts()
Returns the list of suggested alternate fonts.


equals

public boolean equals(java.lang.Object anObj)
Standard equals implementation.

Overrides:
equals in class java.lang.Object

toXML

public com.reportmill.archiver.RXElement toXML(com.reportmill.archiver.RXArchiver anArchiver)
XML archival.


fromXML

public java.lang.Object fromXML(com.reportmill.archiver.RXArchiver anArchiver,
                                com.reportmill.archiver.RXElement anElement)
XML unarchival.


toString

public java.lang.String toString()
Returns the font name, size and family for this font.

Overrides:
toString in class java.lang.Object

ReportMill 10 API