Class PDF16RichTextFormatter
- java.lang.Object
-
- com.adobe.fontengine.inlineformatting.PDF16RichTextFormatter
-
public final class PDF16RichTextFormatter extends java.lang.ObjectInline 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 intformat(AttributedRun run, int start, int limit)Format anAttributedRunby resolving the styling constraints to actual fonts, glyphs and positions for those glyphs.intformat(AttributedRun run, int start, int limit, boolean shouldKern)Format anAttributedRunby resolving the styling constraints to actual fonts, glyphs and positions for those glyphs.static CSS20FontSetgetFontSetInstance()Create a CSS20FontSet for use with a PDF16RichTextFormatter.static CSS20FontSetgetFontSetInstance(CSS20FontSet original)Create a copy of a CSS20FontSet for use with a PDF16RichTextFormatter.static CSS20FontSetgetFontSetInstance(FamilyNameNormalizer normalizer)Create a CSS20FontSet for use with a PDF16RichTextFormatter.static PDF16RichTextFormattergetFormatterInstance(CSS20FontSet fontSet)Create a PDF16RichTextFormatter for formatting text.intpreFormat(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- ACSS20FontSetthat 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 theCSS20FontSetinterface that is returned from this method offers some tighter thread safety guarantees than that guaranteed by theCSS20FontSetinterface. It is safe to use theCSS20FontSetobject for font resolution from multiple threads at one time as long as the methods which change the state of theCSS20FontSetobject are not called at any time that thePDF16RichTextFormatterobjects to which it has been given may be using it for font resolution. There is no mechanism withinCSSPPDF16FormatterorCSS20FontSetto guarantee that this doesn't occur. A client program can guarantee this by modifying theCSS20FontSetobject fully before giving it to one or morePDF16RichTextFormatterobjects 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 theCSS20FontSetobject may be being used for font resolution. It is also safe to copy thisCSS20FontSetobject 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 aFamilyNameNormalizerobject that is used to modify the font family name of everyFontobject added to the CSS20FontSet. It is also used to modify the font names inside of any search request.Concurrency
The instance implementing theCSS20FontSetinterface that is returned from this method offers some tighter thread safety guarantees than that guaranteed by theCSS20FontSetinterface. It is safe to use theCSS20FontSetobject for font resolution from multiple threads at one time as long as the methods which change the state of theCSS20FontSetobject are not called at any time that thePDF16RichTextFormatterobjects to which it has been given may be using it for font resolution. There is no mechanism withinCSSPPDF16FormatterorCSS20FontSetto guarantee that this doesn't occur. A client program can guarantee this by modifying theCSS20FontSetobject fully before giving it to one or morePDF16RichTextFormatterobjects 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 theCSS20FontSetobject may be being used for font resolution. It is also safe to copy thisCSS20FontSetobject 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- AFamilyNameNormalizerused 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 theCSS20FontSetinterface that is returned from this method offers some tighter thread safety guarantees than that guaranteed by theCSS20FontSetinterface. It is safe to use theCSS20FontSetobject for font resolution from multiple threads at one time as long as the methods which change the state of theCSS20FontSetobject are not called at any time that thePDF16RichTextFormatterobjects to which it has been given may be using it for font resolution. There is no mechanism withinCSSPPDF16FormatterorCSS20FontSetto guarantee that this doesn't occur. A client program can guarantee this by modifying theCSS20FontSetobject fully before giving it to one or morePDF16RichTextFormatterobjects 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 theCSS20FontSetobject may be being used for font resolution. It is also safe to copy thisCSS20FontSetobject 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:
FontExceptionFormattingException
-
format
public int format(AttributedRun run, int start, int limit) throws FontException, FormattingException
Format anAttributedRunby 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.isGlyphattribute. - each element must have
ElementAttribute.localeset - each element must have
ElementAttribute.bidiLevelset - each glyph element must have
ElementAttribute.joiningTypeset - each element must have
ElementAttribute.CSS20Attributeset - each character element can have
ElementAttribute.digitCaseset; if not set, equivalent toDigitCase.DEFAULT - each character element can have
ElementAttribute.digitWidthset; if not set, equivalent toDigitWidth.DEFAULT - each interelement can have
InterElementAttribute.ligatureLevelset; if not set, equivalent toLigatureLevel.COMMON
At some point during formatting,
startWorkingWithPositionswill 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.fontset to the actual font to use - each element will have
ElementAttribute.pointSizeset 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:
UnsupportedFontExceptionInvalidFontExceptionFormattingExceptionFontLoadingExceptionFontException
- 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 anAttributedRunby 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.isGlyphattribute. - each element must have
ElementAttribute.localeset - each element must have
ElementAttribute.bidiLevelset - each glyph element must have
ElementAttribute.joiningTypeset - each element must have
ElementAttribute.CSS20Attributeset - each character element can have
ElementAttribute.digitCaseset; if not set, equivalent toDigitCase.DEFAULT - each character element can have
ElementAttribute.digitWidthset; if not set, equivalent toDigitWidth.DEFAULT - each interelement can have
InterElementAttribute.ligatureLevelset; if not set, equivalent toLigatureLevel.COMMON
At some point during formatting,
startWorkingWithPositionswill 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.fontset to the actual font to use - each element will have
ElementAttribute.pointSizeset 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:
UnsupportedFontExceptionInvalidFontExceptionFormattingExceptionFontLoadingExceptionFontException
- each element in the run can be either a character or a glyph, and
this is recorded by the
-
-