public abstract class AbstractFont
extends java.lang.Object
AbstractFont
class provides base class for font extensions
with some static helper methods and access to the FontHelper
and the system Ticket
to access the ContentBus to its extensions.
This class cannot be initialized if the FontHelper
and/or the
system Ticket
are not available.
Modifier and Type | Field and Description |
---|---|
static int |
ALIGN_BASE
The base line alignment constant.
|
static int |
ALIGN_BOTTOM
The bottom alignment constant.
|
static int |
ALIGN_CENTER
The center alignment constant.
|
static int |
ALIGN_FULL
The full justification alignment constant.
|
static int |
ALIGN_HBASE
The vertical alignment flags mask.
|
static int |
ALIGN_LEFT
The left alignment constant.
|
static int |
ALIGN_RIGHT
The right alignment constant.
|
static int |
ALIGN_TOP
The top alignment constant.
|
static int |
ALIGN_VBASE
The vertical alignment flags mask.
|
static int |
BOLD
Request bold font style
|
static int |
DRAW_OUTLINE
The draw the character outline constant instructs the font renderer to
draw the texts outline and not fill it.
|
static int |
DRAW_STRIKEOUT
The strikeout style constant.
|
static int |
DRAW_UNDERLINE
The underline style constant.
|
static int |
DRAWBASE
The text drawing style flags.
|
static int |
ITALIC
Request italic font style
|
static int |
PLAIN
Request plain font style (default)
|
static int |
ROT180
The 180 (clockwise) rotation constant.
|
static int |
ROT270
The 270 (clockwise) rotation constant.
|
static int |
ROT90
The 90 (clockwise) rotation constant.
|
static int |
ROTBASE
The rotation flags mask.
|
static int |
ROTODD
The odd (?) rotation constant.
|
static int |
STRIKEOUT
The strikeout style constant.
|
static int |
TTANTIALIASED
The antialiased font rendering constant.
|
static int |
TTBASE
The TrueType flags mask
|
static int |
TTFONTERLINESPACING
The old line spacing constant.
|
static int |
TTFONTERSCALE
The old fonter scaling constant.
|
static int |
TTHINTED
The hinting font rendering constant.
|
static int |
TTOVERSAMPLING
The oversampling font rendering constant.
|
static int |
TTUNHINTED
Deprecated.
since cq3
|
static int |
UNDERLINE
The underline style constant.
|
Constructor and Description |
---|
AbstractFont() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
canDisplay(char c)
Checks if this Font has a glyph for the specified character.
|
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.
|
abstract int |
canDisplayUpTo(java.text.CharacterIterator iter,
int start,
int limit)
Indicates whether or not this Font can display the specified String.
|
abstract int |
canDisplayUpTo(java.lang.String str)
Indicates whether or not this Font can display a specified String.
|
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.
|
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 the
Layer
using the attributes given. |
abstract double |
getAscent()
Returns the ascent of this
Font object, which is the maximal
value any glyph of this font ascends above the base line. |
abstract java.awt.Font |
getAwtFont() |
abstract double |
getDescent()
Returns the descent of this
Font object, which is the
maximal value any glyph of this font descends below the base line. |
abstract double |
getHeight()
Returns the calculated font height in pixels.
|
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.
|
static int |
stringToStyle(java.lang.String style)
Converts the font style code to a string.
|
static java.lang.String |
styleToDescription(int style)
Converts the numeric font style code to a descriptive string.
|
static java.lang.String |
styleToString(int style)
Converts the numeric font style code to a string usable for the
font name identification.
|
abstract java.lang.String |
toString()
Returns a
String representation of this object containing
the font name, the size and style flags. |
public static final int PLAIN
public static final int BOLD
public static final int ITALIC
public static final int UNDERLINE
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.
public static final int STRIKEOUT
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.
public static final int TTFONTERSCALE
public static final int TTFONTERLINESPACING
public static final int ALIGN_VBASE
public static final int ALIGN_TOP
public static final int ALIGN_BASE
public static final int ALIGN_BOTTOM
public static final int ALIGN_HBASE
public static final int ALIGN_LEFT
public static final int ALIGN_CENTER
public static final int ALIGN_RIGHT
public static final int ALIGN_FULL
public static final int ROTBASE
public static final int ROTODD
public static final int ROT90
public static final int ROT270
public static final int ROT180
public static final int DRAWBASE
public static final int DRAW_UNDERLINE
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.
public static final int DRAW_STRIKEOUT
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.
public static final int DRAW_OUTLINE
public static final int TTBASE
public static final int TTANTIALIASED
public static final int TTHINTED
public static final int TTOVERSAMPLING
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.
drawText(Layer, int, int, int, int, String, Paint, Stroke, int, double, int)
,
#getOversamplingFactor()
,
#setOversamplingFactor(int)
,
Constant Field Values@Deprecated public static final int TTUNHINTED
public static java.lang.String createFontFileName(java.lang.String faceName, int size, int style)
styleToString(int)
.
Example : The font Times New Romain, size 12, style bold/italic has the font file name times_new_roman12bi.
faceName
- The font face namesize
- The size of the fontstyle
- The style flags of the fonpublic static java.lang.String styleToDescription(int style)
style
- The numeric font stylepublic static java.lang.String styleToString(int style)
style
- The numeric font stylepublic static int stringToStyle(java.lang.String style)
style
- The string representation of the font stylepublic abstract java.awt.geom.Rectangle2D getTextExtent(int x, int y, int width, int height, java.lang.String text, int align, double cs, int ls)
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.
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.
Use ALIGN_LEFT
as 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.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)
Layer
using 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.
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
- The Paint
to use for the text drawing.stroke
- The Stroke
to use for the text drawing.align
- alignment, rotation and TrueType attributes for the text.
Use Font#ALIGN_LEFT
as 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.public abstract double getHeight()
public abstract double getAscent()
Font
object, which is the maximal
value any glyph of this font ascends above the base line.Font
.public abstract double getDescent()
Font
object, which is the
maximal value any glyph of this font descends below the base line.Font
.public abstract boolean canDisplay(char c)
c
- a unicode character codetrue
if this Font can display the character;
false
otherwise.public abstract int canDisplayUpTo(java.text.CharacterIterator iter, int start, int limit)
iter
- a CharacterIterator objectstart
- the specified starting offset into the specified array of
characterslimit
- the specified ending offset into the specified array of
characterspublic abstract int canDisplayUpTo(java.lang.String str)
str
- a String objectpublic abstract int canDisplayUpTo(char[] text, int start, int limit)
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
characterspublic abstract java.lang.String toString()
String
representation of this object containing
the font name, the size and style flags.toString
in class java.lang.Object
String
representation of this object.public abstract java.awt.Font getAwtFont()
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"