Package org.faceless.pdf2
Class OutputProfiler.AutoEmbeddingFontAction
- java.lang.Object
-
- org.faceless.pdf2.OutputProfiler.AutoEmbeddingFontAction
-
- All Implemented Interfaces:
OutputProfiler.FontAction
- Enclosing class:
- OutputProfiler
public static class OutputProfiler.AutoEmbeddingFontAction extends Object implements OutputProfiler.FontAction
The
AutoEmbeddingFontActionclass is an implementation ofOutputProfiler.FontActionthat 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 theZapfDingbatsandSymbolfonts, as copies of these fonts are distributed with the PDF library.
-
-
Constructor Summary
Constructors Constructor Description AutoEmbeddingFontAction()Create a new AutoEmbeddingFontAction
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(PDFFont font)Add a new PDFFont to the set of fonts that could be substituted into the PDF.List<PDFFont>getFont(OutputProfiler profiler, String name, boolean embedded, PDFFont font)Returns the font(s) to use instead of the specified font, ornullto make no changesvoidsetMultipleSubstitutions(boolean multi)Set whether it is permissible to substitute multiple fonts for a single font.
-
-
-
Method Detail
-
add
public void add(PDFFont font)
Add a new PDFFont to the set of fonts that could be substituted into the PDF.- Parameters:
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- Parameters:
multi- whether to use multi-font substitutions or not.- Since:
- 2.27
-
getFont
public List<PDFFont> getFont(OutputProfiler profiler, String name, boolean embedded, PDFFont font)
Description copied from interface:OutputProfiler.FontActionReturns the font(s) to use instead of the specified font, ornullto make no changes- Specified by:
getFontin interfaceOutputProfiler.FontAction- Parameters:
profiler- the OutputProfiler this action is being run onname- the font name, which may be nullembedded- 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.- Returns:
- either null to make no changes, or a list of one or more fonts that can be used to substitute.
-
-