Class PDF16RichTextFormatter

java.lang.Object
com.adobe.fontengine.inlineformatting.PDF16RichTextFormatter

public final class PDF16RichTextFormatter extends 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 the format(AttributedRun, int, int) or format(AttributedRun, int, int, boolean) method.

  • Method Details

    • 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 - A CSS20FontSet 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 the CSS20FontSet interface that is returned from this method offers some tighter thread safety guarantees than that guaranteed by the CSS20FontSet interface. It is safe to use the CSS20FontSet object for font resolution from multiple threads at one time as long as the methods which change the state of the CSS20FontSet object are not called at any time that the PDF16RichTextFormatter objects to which it has been given may be using it for font resolution. There is no mechanism within CSSPPDF16Formatter or CSS20FontSet to guarantee that this doesn't occur. A client program can guarantee this by modifying the CSS20FontSet object fully before giving it to one or more PDF16RichTextFormatter objects in one or more threads. A client program could also use some synchronization constructs of its own to guarantee this. This means that the addFont(), setFallbackFonts(), setGenericFont(), and setResolutionPriority() methods can not be called while there is any chance that the CSS20FontSet object may be being used for font resolution. It is also safe to copy this CSS20FontSet 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 a FamilyNameNormalizer object that is used to modify the font family name of every Font object added to the CSS20FontSet. It is also used to modify the font names inside of any search request.

      Concurrency

      The instance implementing the CSS20FontSet interface that is returned from this method offers some tighter thread safety guarantees than that guaranteed by the CSS20FontSet interface. It is safe to use the CSS20FontSet object for font resolution from multiple threads at one time as long as the methods which change the state of the CSS20FontSet object are not called at any time that the PDF16RichTextFormatter objects to which it has been given may be using it for font resolution. There is no mechanism within CSSPPDF16Formatter or CSS20FontSet to guarantee that this doesn't occur. A client program can guarantee this by modifying the CSS20FontSet object fully before giving it to one or more PDF16RichTextFormatter objects in one or more threads. A client program could also use some synchronization constructs of its own to guarantee this. This means that the addFont(), setFallbackFonts(), setGenericFont(), and setResolutionPriority() methods can not be called while there is any chance that the CSS20FontSet object may be being used for font resolution. It is also safe to copy this CSS20FontSet 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 - A FamilyNameNormalizer 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 the CSS20FontSet interface that is returned from this method offers some tighter thread safety guarantees than that guaranteed by the CSS20FontSet interface. It is safe to use the CSS20FontSet object for font resolution from multiple threads at one time as long as the methods which change the state of the CSS20FontSet object are not called at any time that the PDF16RichTextFormatter objects to which it has been given may be using it for font resolution. There is no mechanism within CSSPPDF16Formatter or CSS20FontSet to guarantee that this doesn't occur. A client program can guarantee this by modifying the CSS20FontSet object fully before giving it to one or more PDF16RichTextFormatter objects in one or more threads. A client program could also use some synchronization constructs of its own to guarantee this. This means that the addFont(), setFallbackFonts(), setGenericFont(), and setResolutionPriority() methods can not be called while there is any chance that the CSS20FontSet object may be being used for font resolution. It is also safe to copy this CSS20FontSet 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 an AttributedRun. This method should be called on a portion of an AttributedRun corresponding to a whole paragraph, before the format(AttributedRun, int, int) or format(AttributedRun, int, int, boolean) method.
      Parameters:
      run - an AttributedRun that contains the text to be formatted
      start - the index in the AttributedRun to start formatting from
      limit - 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 an AttributedRun 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:

      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 formatted
      start - the index in the AttributedRun to start formatting from
      limit - 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
    • format

      public int format(AttributedRun run, int start, int limit, boolean shouldKern) throws FontException, FormattingException
      Format an AttributedRun 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:

      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 formatted
      start - the index in the AttributedRun to start formatting from
      limit - 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