Class PDF16RichTextFormatter
- java.lang.Object
-
- com.adobe.fontengine.inlineformatting.PDF16RichTextFormatter
-
public final class PDF16RichTextFormatter extends java.lang.Object
Inline formatter for PDF 1.6 rich text form fields.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 CSS20FontSet
getFontSetInstance()
Create a CSS20FontSet for use with a PDF16RichTextFormatter.static CSS20FontSet
getFontSetInstance(CSS20FontSet original)
Create a copy of a CSS20FontSet for use with a PDF16RichTextFormatter.static CSS20FontSet
getFontSetInstance(FamilyNameNormalizer normalizer)
Create a CSS20FontSet for use with a PDF16RichTextFormatter.static PDF16RichTextFormatter
getFormatterInstance(CSS20FontSet fontSet)
Create a PDF16RichTextFormatter for formatting text.int
preFormat(AttributedRun run, int start, int limit)
Preformat anAttributedRun
.
-
-
-
Method Detail
-
getFormatterInstance
public static PDF16RichTextFormatter getFormatterInstance(CSS20FontSet fontSet)
Create a PDF16RichTextFormatter for formatting text.Concurrency
The PDF16RichTextFormatter instance that is returned from this method is not in general thread safe.- Parameters:
fontSet
- ACSS20FontSet
that has had all fonts and fallbacks fonts that are relevant to the caller added.- Returns:
- A PDF16RichTextFormatter to be used for formatting text
-
getFontSetInstance
public static CSS20FontSet getFontSetInstance()
Create a CSS20FontSet for use with a PDF16RichTextFormatter. The returned CSS20FontSet is intended to be shared among thread and documents. Optimal performance will be achieved by sharing them in this way.Concurrency
The instance implementing theCSS20FontSet
interface that is returned from this method offers some tighter thread safety guarantees than that guaranteed by theCSS20FontSet
interface. It is safe to use theCSS20FontSet
object for font resolution from multiple threads at one time as long as the methods which change the state of theCSS20FontSet
object are not called at any time that thePDF16RichTextFormatter
objects to which it has been given may be using it for font resolution. There is no mechanism withinCSSPPDF16Formatter
orCSS20FontSet
to guarantee that this doesn't occur. A client program can guarantee this by modifying theCSS20FontSet
object fully before giving it to one or morePDF16RichTextFormatter
objects in one or more threads. A client program could also use some synchronization constructs of its own to guarantee this. This means that theaddFont()
,setFallbackFonts()
,setGenericFont()
, andsetResolutionPriority()
methods can not be called while there is any chance that theCSS20FontSet
object may be being used for font resolution. It is also safe to copy thisCSS20FontSet
object except when it is possible that it may be being modified. It is again the responsibility of the client to ensure that this doesn't happen.- Returns:
- An empty CSS20FontSet that can be used with a PDF16RichTextFormatter
-
getFontSetInstance
public static CSS20FontSet getFontSetInstance(FamilyNameNormalizer normalizer)
Create a CSS20FontSet for use with a PDF16RichTextFormatter. This method allows a client to specify aFamilyNameNormalizer
object that is used to modify the font family name of everyFont
object added to the CSS20FontSet. It is also used to modify the font names inside of any search request.Concurrency
The instance implementing theCSS20FontSet
interface that is returned from this method offers some tighter thread safety guarantees than that guaranteed by theCSS20FontSet
interface. It is safe to use theCSS20FontSet
object for font resolution from multiple threads at one time as long as the methods which change the state of theCSS20FontSet
object are not called at any time that thePDF16RichTextFormatter
objects to which it has been given may be using it for font resolution. There is no mechanism withinCSSPPDF16Formatter
orCSS20FontSet
to guarantee that this doesn't occur. A client program can guarantee this by modifying theCSS20FontSet
object fully before giving it to one or morePDF16RichTextFormatter
objects in one or more threads. A client program could also use some synchronization constructs of its own to guarantee this. This means that theaddFont()
,setFallbackFonts()
,setGenericFont()
, andsetResolutionPriority()
methods can not be called while there is any chance that theCSS20FontSet
object may be being used for font resolution. It is also safe to copy thisCSS20FontSet
object except when it is possible that it may be being modified. It is again the responsibility of the client to ensure that this doesn't happen.- Parameters:
normalizer
- AFamilyNameNormalizer
used for adjusting font family names.- Returns:
- An empty CSS20FontSet that can be used with a PDF16RichTextFormatter
-
getFontSetInstance
public static CSS20FontSet getFontSetInstance(CSS20FontSet original)
Create a copy of a CSS20FontSet for use with a PDF16RichTextFormatter.Concurrency
The instance implementing theCSS20FontSet
interface that is returned from this method offers some tighter thread safety guarantees than that guaranteed by theCSS20FontSet
interface. It is safe to use theCSS20FontSet
object for font resolution from multiple threads at one time as long as the methods which change the state of theCSS20FontSet
object are not called at any time that thePDF16RichTextFormatter
objects to which it has been given may be using it for font resolution. There is no mechanism withinCSSPPDF16Formatter
orCSS20FontSet
to guarantee that this doesn't occur. A client program can guarantee this by modifying theCSS20FontSet
object fully before giving it to one or morePDF16RichTextFormatter
objects in one or more threads. A client program could also use some synchronization constructs of its own to guarantee this. This means that theaddFont()
,setFallbackFonts()
,setGenericFont()
, andsetResolutionPriority()
methods can not be called while there is any chance that theCSS20FontSet
object may be being used for font resolution. It is also safe to copy thisCSS20FontSet
object except when it is possible that it may be being modified. It is again the responsibility of the client to ensure that this doesn't happen.- Parameters:
original
- the CSS20FontSet to copy- Returns:
- A copy of a CSS20FontSet that can be used with a PDF16RichTextFormatter
-
preFormat
public int preFormat(AttributedRun run, int start, int limit) throws FontException, FormattingException
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:
FontException
FormattingException
-
format
public int format(AttributedRun run, int start, int limit) throws FontException, FormattingException
Format anAttributedRun
by resolving the styling constraints to actual fonts, glyphs and positions for those glyphs. This method should be called after thepreFormat(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.CSS20Attribute
set - 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
- each element will have
ElementAttribute.font
set to the actual font to use - each element will have
ElementAttribute.pointSize
set to the actual point size to use
- 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:
UnsupportedFontException
InvalidFontException
FormattingException
FontLoadingException
FontException
- 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 FontException, FormattingException
Format anAttributedRun
by resolving the styling constraints to actual fonts, glyphs and positions for those glyphs. This method should be called after thepreFormat(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.CSS20Attribute
set - 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
- each element will have
ElementAttribute.font
set to the actual font to use - each element will have
ElementAttribute.pointSize
set to the actual point size to use
- 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 to apply kerning to the glyphs- Returns:
- The new limit of the original range in the AttributedRun after the formatting operation.
- Throws:
UnsupportedFontException
InvalidFontException
FormattingException
FontLoadingException
FontException
- each element in the run can be either a character or a glyph, and
this is recorded by the
-
-