Class BasicFormatter
- java.lang.Object
-
- com.adobe.fontengine.inlineformatting.BasicFormatter
-
public final class BasicFormatter extends java.lang.Object
General purpose inline formatter.This formatter does not do any font selection or font fallback, the client must have selected fonts.
The client must first pass a run corresponding to a whole paragraph to the
preFormat(com.adobe.fontengine.inlineformatting.AttributedRun, int, int)
method. It can then pass fragments of the run to theformat(AttributedRun, int, int)
orformat(AttributedRun, int, int, boolean)
method.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
format(AttributedRun run, int start, int limit)
Format anAttributedRun
by resolving the styling constraints to actual fonts, glyphs and positions for those glyphs.int
format(AttributedRun run, int start, int limit, boolean shouldKern)
Format anAttributedRun
by resolving the styling constraints to actual fonts, glyphs and positions for those glyphs.static BasicFormatter
getFormatterInstance()
Create a BasicFormatter for formatting text.int
preFormat(AttributedRun run, int start, int limit)
Preformat anAttributedRun
.
-
-
-
Method Detail
-
getFormatterInstance
public static BasicFormatter getFormatterInstance()
Create a BasicFormatter for formatting text.Concurrency
The BasicFormatter instance that is returned from this method is not in general thread safe.- Returns:
- A BasicFormatter to be used for formatting text
-
preFormat
public int preFormat(AttributedRun run, int start, int limit) throws InvalidFontException, UnsupportedFontException, FontLoadingException
Preformat anAttributedRun
. This method should be called on a portion of an AttributedRun corresponding to a whole paragraph, before theformat(AttributedRun, int, int)
orformat(AttributedRun, int, int, boolean)
method.- Parameters:
run
- an AttributedRun that contains the text to be formattedstart
- the index in the AttributedRun to start formatting fromlimit
- the index in the AttributedRun at which formatting should cease (one more than the last position that formatting should done to)- Returns:
- The new limit of the original range in the AttributedRun after the formatting operation.
- Throws:
InvalidFontException
UnsupportedFontException
FontLoadingException
-
format
public int format(AttributedRun run, int start, int limit) throws InvalidFontException, UnsupportedFontException, FontLoadingException
Format anAttributedRun
by resolving the styling constraints to actual fonts, glyphs and positions for those glyphs.This method should be called after the
preFormat(com.adobe.fontengine.inlineformatting.AttributedRun, int, int)
method.On input:
- each element in the run can be either a character or a glyph, and
this is recorded by the
ElementAttribute.isGlyph
attribute. - each element must have
ElementAttribute.locale
set - each element must have
ElementAttribute.bidiLevel
set - each glyph element must have
ElementAttribute.joiningType
set - each element must have
ElementAttribute.font
set - each element must have
ElementAttribute.pointSize
set - each character element can have
ElementAttribute.fontStyle
set; if not set, equivalent toFontStyle.NORMAL
- each character element can have
ElementAttribute.typographicCase
set; if not set, equivalent toTypographicCase.NONE
- each character element can have
ElementAttribute.digitCase
set; if not set, equivalent toDigitCase.DEFAULT
- each character element can have
ElementAttribute.digitWidth
set; if not set, equivalent toDigitWidth.DEFAULT
- each interelement can have
InterElementAttribute.ligatureLevel
set; if not set, equivalent toLigatureLevel.COMMON
At some point during formatting,
startWorkingWithPositions
will be called on the run.On output:
- each element in the run will be a glyph
- each element will have a placement and advance vector
- Parameters:
run
- an AttributedRun that contains the text to be formattedstart
- the index in the AttributedRun to start formatting fromlimit
- the index in the AttributedRun at which formatting should cease (one more than the last position that formatting should done to)- Returns:
- The new limit of the original range in the AttributedRun after the formatting operation.
- Throws:
InvalidFontException
UnsupportedFontException
FontLoadingException
- each element in the run can be either a character or a glyph, and
this is recorded by the
-
format
public int format(AttributedRun run, int start, int limit, boolean shouldKern) throws InvalidFontException, UnsupportedFontException, FontLoadingException
Format anAttributedRun
by resolving the styling constraints to actual fonts, glyphs and positions for those glyphs.This method should be called after the
preFormat(com.adobe.fontengine.inlineformatting.AttributedRun, int, int)
method.On input:
- each element in the run can be either a character or a glyph, and
this is recorded by the
ElementAttribute.isGlyph
attribute. - each element must have
ElementAttribute.locale
set - each element must have
ElementAttribute.bidiLevel
set - each glyph element must have
ElementAttribute.joiningType
set - each element must have
ElementAttribute.font
set - each element must have
ElementAttribute.pointSize
set - each character element can have
ElementAttribute.fontStyle
set; if not set, equivalent toFontStyle.NORMAL
- each character element can have
ElementAttribute.typographicCase
set; if not set, equivalent toTypographicCase.NONE
- each character element can have
ElementAttribute.digitCase
set; if not set, equivalent toDigitCase.DEFAULT
- each character element can have
ElementAttribute.digitWidth
set; if not set, equivalent toDigitWidth.DEFAULT
- each interelement can have
InterElementAttribute.ligatureLevel
set; if not set, equivalent toLigatureLevel.COMMON
At some point during formatting,
startWorkingWithPositions
will be called on the run.On output:
- each element in the run will be a glyph
- each element will have a placement and advance vector
- Parameters:
run
- an AttributedRun that contains the text to be formattedstart
- the index in the AttributedRun to start formatting fromlimit
- the index in the AttributedRun at which formatting should cease (one more than the last position that formatting should done to)shouldKern
- whether or not kerning should be applied to the glyphs- Returns:
- The new limit of the original range in the AttributedRun after the formatting operation.
- Throws:
InvalidFontException
UnsupportedFontException
FontLoadingException
- each element in the run can be either a character or a glyph, and
this is recorded by the
-
-