Class AbstractFont
- java.lang.Object
 - 
- com.day.image.font.AbstractFont
 
 
- 
- Direct Known Subclasses:
 Font
public abstract class AbstractFont extends java.lang.ObjectTheAbstractFontclass provides base class for font extensions with some static helper methods and access to theFontHelperand the systemTicketto access the ContentBus to its extensions.This class cannot be initialized if the
FontHelperand/or the systemTicketare not available.- Since:
 - degu
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static intALIGN_BASEThe base line alignment constant.static intALIGN_BOTTOMThe bottom alignment constant.static intALIGN_CENTERThe center alignment constant.static intALIGN_FULLThe full justification alignment constant.static intALIGN_HBASEThe vertical alignment flags mask.static intALIGN_LEFTThe left alignment constant.static intALIGN_RIGHTThe right alignment constant.static intALIGN_TOPThe top alignment constant.static intALIGN_VBASEThe vertical alignment flags mask.static intBOLDRequest bold font stylestatic intDRAW_OUTLINEThe draw the character outline constant instructs the font renderer to draw the texts outline and not fill it.static intDRAW_STRIKEOUTThe strikeout style constant.static intDRAW_UNDERLINEThe underline style constant.static intDRAWBASEThe text drawing style flags.static intITALICRequest italic font stylestatic intPLAINRequest plain font style (default)static intROT180The 180� (clockwise) rotation constant.static intROT270The 270� (clockwise) rotation constant.static intROT90The 90� (clockwise) rotation constant.static intROTBASEThe rotation flags mask.static intROTODDThe odd (?) rotation constant.static intSTRIKEOUTThe strikeout style constant.static intTTANTIALIASEDThe antialiased font rendering constant.static intTTBASEThe TrueType flags maskstatic intTTFONTERLINESPACINGThe old line spacing constant.static intTTFONTERSCALEThe old fonter scaling constant.static intTTHINTEDThe hinting font rendering constant.static intTTOVERSAMPLINGThe oversampling font rendering constant.static intTTUNHINTEDDeprecated.since cq3static intUNDERLINEThe underline style constant. 
- 
Constructor Summary
Constructors Constructor Description AbstractFont() 
- 
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract booleancanDisplay(char c)Checks if this Font has a glyph for the specified character.abstract intcanDisplayUpTo(char[] text, int start, int limit)Indicates whether or not this Font can display the characters in the specified text starting at start and ending at limit.abstract intcanDisplayUpTo(java.lang.String str)Indicates whether or not this Font can display a specified String.abstract intcanDisplayUpTo(java.text.CharacterIterator iter, int start, int limit)Indicates whether or not this Font can display the specified String.static java.lang.StringcreateFontFileName(java.lang.String faceName, int size, int style)Constructs and returns a font file name from the font face name, size and style indication.abstract intdrawText(Layer layer, int x, int y, int width, int height, java.lang.String text, java.awt.Paint paint, java.awt.Stroke stroke, int align, double cs, int ls)Render the given text string in the given font to theLayerusing the attributes given.abstract doublegetAscent()Returns the ascent of thisFontobject, which is the maximal value any glyph of this font ascends above the base line.abstract java.awt.FontgetAwtFont()abstract doublegetDescent()Returns the descent of thisFontobject, which is the maximal value any glyph of this font descends below the base line.abstract doublegetHeight()Returns the calculated font height in pixels.abstract java.awt.geom.Rectangle2DgetTextExtent(int x, int y, int width, int height, java.lang.String text, int align, double cs, int ls)Calculate the bounding box of the text, if it would be rendered with the rendering attributes given.static intstringToStyle(java.lang.String style)Converts the font style code to a string.static java.lang.StringstyleToDescription(int style)Converts the numeric font style code to a descriptive string.static java.lang.StringstyleToString(int style)Converts the numeric font style code to a string usable for the font name identification.abstract java.lang.StringtoString()Returns aStringrepresentation of this object containing the font name, the size and style flags. 
 - 
 
- 
- 
Field Detail
- 
PLAIN
public static final int PLAIN
Request plain font style (default)- See Also:
 - Constant Field Values
 
 
- 
BOLD
public static final int BOLD
Request bold font style- See Also:
 - Constant Field Values
 
 
- 
ITALIC
public static final int ITALIC
Request italic font style- See Also:
 - Constant Field Values
 
 
- 
UNDERLINE
public static final int UNDERLINE
The underline style constant. This can be combined with the other style constants (except PLAIN) for mixed styles.Underlining in Java2D is a property of drawing text and not a font style. Thus this constant is valid for any font you choose and takes effect when drawing text - and it works.
- See Also:
 - Constant Field Values
 
 
- 
STRIKEOUT
public static final int STRIKEOUT
The strikeout style constant. This can be combined with the other style constants (except PLAIN) for mixed styles.Striekout in Java2D is a property of drawing text and not a font style. Thus this constant is valid for any font you choose and takes effect when drawing text - and it works.
- See Also:
 - Constant Field Values
 
 
- 
TTFONTERSCALE
public static final int TTFONTERSCALE
The old fonter scaling constant. Set this constant to change the scaling of fonts from the old 72dpi to the default 96dpi.- See Also:
 - Constant Field Values
 
 
- 
TTFONTERLINESPACING
public static final int TTFONTERLINESPACING
The old line spacing constant. Set this constant to use the new line spacing values instead of the old line spacing values, which tend to be somewhat bigger, than what is intended in the TrueType standard.- See Also:
 - Constant Field Values
 
 
- 
ALIGN_VBASE
public static final int ALIGN_VBASE
The vertical alignment flags mask.- See Also:
 - Constant Field Values
 
 
- 
ALIGN_TOP
public static final int ALIGN_TOP
The top alignment constant. This can be combined with any one of the horizontal alignment and rotation constants to get mixed alignment/rotation style.- See Also:
 - Constant Field Values
 
 
- 
ALIGN_BASE
public static final int ALIGN_BASE
The base line alignment constant. This can be combined with any one of the horizontal alignment and rotation constants to get mixed alignment/rotation style.- See Also:
 - Constant Field Values
 
 
- 
ALIGN_BOTTOM
public static final int ALIGN_BOTTOM
The bottom alignment constant. This can be combined with any one of the horizontal alignment and rotation constants to get mixed alignment/rotation style.- See Also:
 - Constant Field Values
 
 
- 
ALIGN_HBASE
public static final int ALIGN_HBASE
The vertical alignment flags mask.- See Also:
 - Constant Field Values
 
 
- 
ALIGN_LEFT
public static final int ALIGN_LEFT
The left alignment constant. This can be combined with any one of the vertical alignment and rotation constants to get mixed alignment/rotation style.- See Also:
 - Constant Field Values
 
 
- 
ALIGN_CENTER
public static final int ALIGN_CENTER
The center alignment constant. This can be combined with any one of the vertical alignment and rotation constants to get mixed alignment/rotation style.- See Also:
 - Constant Field Values
 
 
- 
ALIGN_RIGHT
public static final int ALIGN_RIGHT
The right alignment constant. This can be combined with any one of the vertical alignment and rotation constants to get mixed alignment/rotation style.- See Also:
 - Constant Field Values
 
 
- 
ALIGN_FULL
public static final int ALIGN_FULL
The full justification alignment constant. This can be combined with any one of the vertical alignment and rotation constants to get mixed alignment/rotation style.- See Also:
 - Constant Field Values
 
 
- 
ROTBASE
public static final int ROTBASE
The rotation flags mask.- See Also:
 - Constant Field Values
 
 
- 
ROTODD
public static final int ROTODD
The odd (?) rotation constant. This can be combined with any one of the vertical and horizontal alignment constants to get mixed alignment/rotation style.- See Also:
 - Constant Field Values
 
 
- 
ROT90
public static final int ROT90
The 90� (clockwise) rotation constant. This can be combined with any one of the vertical and horizontal alignment constants to get mixed alignment/rotation style.- See Also:
 - Constant Field Values
 
 
- 
ROT270
public static final int ROT270
The 270� (clockwise) rotation constant. This can be combined with any one of the vertical and horizontal alignment constants to get mixed alignment/rotation style.- See Also:
 - Constant Field Values
 
 
- 
ROT180
public static final int ROT180
The 180� (clockwise) rotation constant. This can be combined with any one of the vertical and horizontal alignment constants to get mixed alignment/rotation style.- See Also:
 - Constant Field Values
 
 
- 
DRAWBASE
public static final int DRAWBASE
The text drawing style flags.- See Also:
 - Constant Field Values
 
 
- 
DRAW_UNDERLINE
public static final int DRAW_UNDERLINE
The underline style constant. This can be combined with the other style constants (except PLAIN) for mixed styles.Underlining in Java2D is a property of drawing text and not a font style. Thus this constant is valid for any font you choose and takes effect when drawing text - and it works.
- See Also:
 - Constant Field Values
 
 
- 
DRAW_STRIKEOUT
public static final int DRAW_STRIKEOUT
The strikeout style constant. This can be combined with the other style constants (except PLAIN) for mixed styles.Striekout in Java2D is a property of drawing text and not a font style. Thus this constant is valid for any font you choose and takes effect when drawing text - and it works.
- See Also:
 - Constant Field Values
 
 
- 
DRAW_OUTLINE
public static final int DRAW_OUTLINE
The draw the character outline constant instructs the font renderer to draw the texts outline and not fill it. Default is filling the outline. This can be combined with any one of the vertical and horizontal alignment and rotation constants to get mixed alignment/rotation style.- See Also:
 - Constant Field Values
 
 
- 
TTBASE
public static final int TTBASE
The TrueType flags mask- See Also:
 - Constant Field Values
 
 
- 
TTANTIALIASED
public static final int TTANTIALIASED
The antialiased font rendering constant. This can be combined with any one of the vertical and horizontal alignment and rotation constants to get mixed alignment/rotation style.- See Also:
 - Constant Field Values
 
 
- 
TTHINTED
public static final int TTHINTED
The hinting font rendering constant. This can be combined with any one of the vertical and horizontal alignment and rotation constants to get mixed alignment/rotation style.- See Also:
 - Constant Field Values
 
 
- 
TTOVERSAMPLING
public static final int TTOVERSAMPLING
The oversampling font rendering constant. This can be combined with any one of the vertical and horizontal alignment and rotation constants to get mixed alignment/rotation style.By popular demand font oversampling has been added again. For this reason this flag is not deprecated any more.
The factor applied to the text being drawn is set by the
#setOversamplingFactor(int)method and has a default value of 16.- See Also:
 drawText(Layer, int, int, int, int, String, Paint, Stroke, int, double, int),#getOversamplingFactor(),#setOversamplingFactor(int), Constant Field Values
 
- 
TTUNHINTED
@Deprecated public static final int TTUNHINTED
Deprecated.since cq3The 'do-not-hint' font rendering constant. This can be combined with any one of the vertical and horizontal alignment and rotation constants to get mixed alignment/rotation style.- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Method Detail
- 
createFontFileName
public static java.lang.String createFontFileName(java.lang.String faceName, int size, int style)Constructs and returns a font file name from the font face name, size and style indication. The file name consists of the face name converted to lower case and blanks replaced by underscores appending the size and style converted to a string withstyleToString(int).Example : The font Times New Romain, size 12, style bold/italic has the font file name times_new_roman12bi.
- Parameters:
 faceName- The font face namesize- The size of the fontstyle- The style flags of the fon- Returns:
 - The valid font file name
 
 
- 
styleToDescription
public static java.lang.String styleToDescription(int style)
Converts the numeric font style code to a descriptive string.- Parameters:
 style- The numeric font style- Returns:
 - The descriptive string representation of the font style
 
 
- 
styleToString
public static java.lang.String styleToString(int style)
Converts the numeric font style code to a string usable for the font name identification.- Parameters:
 style- The numeric font style- Returns:
 - The string representation of the font style
 
 
- 
stringToStyle
public static int stringToStyle(java.lang.String style)
Converts the font style code to a string.- Parameters:
 style- The string representation of the font style- Returns:
 - The numeric font style code.
 
 
- 
getTextExtent
public abstract java.awt.geom.Rectangle2D getTextExtent(int x, int y, int width, int height, java.lang.String text, int align, double cs, int ls)Calculate the bounding box of the text, if it would be rendered with the rendering attributes given. The calculation will be done as if the text would be rendered in the current font object.If the width of the text box is set to some value other than zero, the text is broken to fit lines of the given length. The line breaking algorithm breaking algorithm breaks on whitespace (blank, tab), carriage return and linefeed (CR/LF) in any combination as well as on other characters such as hyphens.
If the text contains carriage return and/or linefeed characters, the text is broken into several lines, regardless of whether the text would be broken because of the text box width setting.
- Parameters:
 x- left edge of the text box, requiredy- top edge of the text box, requiredwidth- maximum width of the textbox. If 0 (or negative) the width of the bounding box is dependent of the rendering attributesheight- maximum height of the textbox. If 0 (or negative) the width of the bounding box is dependent of the rendering attributestext- the text string to calculate the bounding box foralign- alignment, rotation and TrueType attributes for the text. UseALIGN_LEFTas default value.cs- extra intercharacter spacing. Use 0 as default value to not add additional space.ls- extra line spacing. Use 0 as default value to not add additional space.- Returns:
 - returns a rectangle representing the bounding box, if the text would be rendered in this font using the given additional rendering attributes.
 
 
- 
drawText
public abstract int drawText(Layer layer, int x, int y, int width, int height, java.lang.String text, java.awt.Paint paint, java.awt.Stroke stroke, int align, double cs, int ls)
Render the given text string in the given font to theLayerusing the attributes given. Use the default values given for unspecified values.If the width of the text box is set to some value other than zero, the text is broken to fit lines of the given length. The line breaking algorithm breaking algorithm breaks on whitespace (blank, tab), carriage return and linefeed (CR/LF) in any combination as well as on other characters such as hyphens.
If the text contains carriage return and/or linefeed characters, the text is broken into several lines, regardless of whether the text would be broken because of the text box width setting.
- Parameters:
 layer- the layer to draw the text intox- left edge of the text box, requiredy- top edge of the text box, requiredwidth- maximum width of the textbox. If 0 (or negative) the width of the bounding box is dependent of the rendering attributesheight- maximum height of the textbox. If 0 (or negative) the width of the bounding box is dependent of the rendering attributestext- the text string to calculate the bounding box forpaint- ThePaintto use for the text drawing.stroke- TheStroketo use for the text drawing.align- alignment, rotation and TrueType attributes for the text. UseFont#ALIGN_LEFTas default value.cs- extra intercharacter spacing. Use 0 as default value to not add additional space.ls- extra line spacing. Use 0 as default value to not add additional space.- Returns:
 - the number of text lines drawn to the layer
 
 
- 
getHeight
public abstract double getHeight()
Returns the calculated font height in pixels.- Returns:
 - the calculated font height in pixels.
 
 
- 
getAscent
public abstract double getAscent()
Returns the ascent of thisFontobject, which is the maximal value any glyph of this font ascends above the base line.- Returns:
 - The ascent of this 
Font. 
 
- 
getDescent
public abstract double getDescent()
Returns the descent of thisFontobject, which is the maximal value any glyph of this font descends below the base line.- Returns:
 - The ascent of this 
Font. 
 
- 
canDisplay
public abstract boolean canDisplay(char c)
Checks if this Font has a glyph for the specified character.- Parameters:
 c- a unicode character code- Returns:
 trueif this Font can display the character;falseotherwise.
 
- 
canDisplayUpTo
public abstract int canDisplayUpTo(java.text.CharacterIterator iter, int start, int limit)Indicates whether or not this Font can display the specified String. For strings with Unicode encoding, it is important to know if a particular font can display the string. This method returns an offset into the String str which is the first character this Font cannot display without using the missing glyph code . If this Font can display all characters, -1 is returned.- Parameters:
 iter- a CharacterIterator objectstart- the specified starting offset into the specified array of characterslimit- the specified ending offset into the specified array of characters- Returns:
 - an offset into the String object that can be displayed by this Font.
 
 
- 
canDisplayUpTo
public abstract int canDisplayUpTo(java.lang.String str)
Indicates whether or not this Font can display a specified String. For strings with Unicode encoding, it is important to know if a particular font can display the string. This method returns an offset into the String str which is the first character this Font cannot display without using the missing glyph code. If the Font can display all characters, -1 is returned.- Parameters:
 str- a String object- Returns:
 - an offset into str that points to the first character in str that this Font cannot display; or -1 if this Font can display all characters in str.
 
 
- 
canDisplayUpTo
public abstract int canDisplayUpTo(char[] text, int start, int limit)Indicates whether or not this Font can display the characters in the specified text starting at start and ending at limit. This method is a convenience overload.- Parameters:
 text- the specified array of charactersstart- the specified starting offset into the specified array of characterslimit- the specified ending offset into the specified array of characters- Returns:
 - an offset into text that points to the first character in text that this Font cannot display; or -1 if this Font can display all characters in text.
 
 
- 
toString
public abstract java.lang.String toString()
Returns aStringrepresentation of this object containing the font name, the size and style flags.- Overrides:
 toStringin classjava.lang.Object- Returns:
 - A 
Stringrepresentation of this object. 
 
- 
getAwtFont
public abstract java.awt.Font getAwtFont()
 
 - 
 
 -