Class OutputProfiler.AutoEmbeddingFontAction

  • All Implemented Interfaces:
    Enclosing class:

    public static class OutputProfiler.AutoEmbeddingFontAction
    extends Object
    implements OutputProfiler.FontAction

    The AutoEmbeddingFontAction class is an implementation of OutputProfiler.FontAction that will replace unembedded fonts with embedded ones via a "best fit" algorithm. When a new unembedded font is encountered, the action will replace it with the closest match of the fonts registered with it. The match is based on all attributes of the font, including name, properties and glyph metrics.

    Fonts can be added to this class with the add(org.faceless.pdf2.PDFFont) method as possible alternatives to the fonts in the PDF. There are also two fonts added by default for the ZapfDingbats and Symbol fonts, as copies of these fonts are distributed with the PDF library.

    • Constructor Detail

      • AutoEmbeddingFontAction

        public AutoEmbeddingFontAction()
        Create a new AutoEmbeddingFontAction
    • Method Detail

      • add

        public void add​(PDFFont font)
        Add a new PDFFont to the set of fonts that could be substituted into the PDF.
        font - the font
      • setMultipleSubstitutions

        public void setMultipleSubstitutions​(boolean multi)
        Set whether it is permissible to substitute multiple fonts for a single font. This is a last resort and as the alternative it usually rasterization it's best to leave this at the default of true. However as it may, theoretically cause text to change shape in the middle of a word, it may be set to false for compatibility with releases prior to 2.27
        multi - whether to use multi-font substitutions or not.
      • getFont

        public List<PDFFont> getFont​(OutputProfiler profiler,
                                     String name,
                                     boolean embedded,
                                     PDFFont font)
        Description copied from interface: OutputProfiler.FontAction
        Returns the font(s) to use instead of the specified font, or null to make no changes
        Specified by:
        getFont in interface OutputProfiler.FontAction
        profiler - the OutputProfiler this action is being run on
        name - the font name
        embedded - whether the font is embedded in the PDF - typically embedded fonts should be left unchanged.
        font - the font that is being replaced. Note this structure is unlikely to support the full PDFFont API, and the object cannot be reused elsewhere.
        either null to make no changes, or a list of one or more fonts that can be used to substitute.