Package com.openhtmltopdf.pdfboxout
Class PdfBoxFontResolver
java.lang.Object
com.openhtmltopdf.pdfboxout.PdfBoxFontResolver
- All Implemented Interfaces:
FontResolver
This class handles all font resolving for the PDF generation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Loads a Type0 font on demandstatic class
AFontDescription
can exist in multiple states.static enum
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AbstractFontStore
private final org.apache.pdfbox.pdmodel.PDDocument
private final FallbackFontStore
private final FallbackFontStore
private final MainFontStore
-
Constructor Summary
ConstructorsConstructorDescriptionPdfBoxFontResolver
(SharedContext sharedContext, org.apache.pdfbox.pdmodel.PDDocument doc, FSCacheEx<String, FSCacheValue> pdfMetricsCache, PdfRendererBuilder.PdfAConformance pdfAConformance, boolean pdfUaConform) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFont
(FSSupplier<InputStream> supplier, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset) Deprecated.void
addFont
(FSSupplier<InputStream> supplier, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup) Adds a font specified by an input stream (truetype) to a specific font group.void
addFont
(PDFontSupplier supplier, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset) void
addFont
(PDFontSupplier supplier, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup) Add a font specified by a PDFontSupplier to a specific font group.void
addFont
(File fontFile, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset) Deprecated.void
addFont
(File fontFile, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup) Add a font file (truetype) to a specific font group.void
addFontCollection
(FSSupplier<InputStream> supplier, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset) void
addFontCollection
(FSSupplier<InputStream> supplier, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup) Adds a font collection (.ttc in an input stream) to a specific font group.void
addFontCollection
(File file, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset) void
addFontCollection
(File file, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup) Adds a font collection (.ttc file) to a specific group.void
addFontDirectory
(String dir, boolean embedded) Deprecated.void
addFontDirectory
(String dir, boolean embedded, PdfBoxFontResolver.FontGroup fontGroup) Add all fonts in the given directoryvoid
close()
Free all font resources (i.e.private FallbackFontStore
getFallbackFontStore
(PdfBoxFontResolver.FontGroup fontGroup) void
importFontFaces
(List<FontFaceRule> fontFaces) private void
resolveFamilyFont
(SharedContext ctx, String[] families, float size, IdentValue weight, IdentValue style, IdentValue variant, List<PdfBoxFontResolver.FontDescription> fonts, AbstractFontStore store) resolveFont
(SharedContext renderingContext, FontSpecification spec) private FSFont
resolveFont
(SharedContext ctx, String[] families, float size, IdentValue weight, IdentValue style, IdentValue variant)
-
Field Details
-
_doc
private final org.apache.pdfbox.pdmodel.PDDocument _doc -
_suppliedFonts
-
_preBuiltinFallbackFonts
-
_builtinFonts
-
_finalFallbackFonts
-
-
Constructor Details
-
Method Details
-
close
public void close()Free all font resources (i.e. open files), the document should already be closed. -
importFontFaces
-
addFontDirectory
Deprecated.- Throws:
IOException
-
addFontDirectory
public void addFontDirectory(String dir, boolean embedded, PdfBoxFontResolver.FontGroup fontGroup) throws IOException Add all fonts in the given directory- Throws:
IOException
-
addFontCollection
public void addFontCollection(FSSupplier<InputStream> supplier, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup) throws IOException Adds a font collection (.ttc in an input stream) to a specific font group.- Throws:
IOException
-
addFontCollection
@Deprecated public void addFontCollection(FSSupplier<InputStream> supplier, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset) throws IOException Add fonts using a .ttc TrueTypeCollection- Throws:
IOException
-
addFontCollection
public void addFontCollection(File file, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup) throws IOException Adds a font collection (.ttc file) to a specific group.- Throws:
IOException
-
addFontCollection
@Deprecated public void addFontCollection(File file, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset) throws IOException Add fonts using a .ttc TrueTypeCollection- Throws:
IOException
-
addFont
public void addFont(File fontFile, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup) throws IOException Add a font file (truetype) to a specific font group.- Throws:
IOException
-
getFallbackFontStore
-
addFont
@Deprecated public void addFont(File fontFile, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset) throws IOException Deprecated.Add a font using a existing file. If the file is a TrueTypeCollection, it will be handled as such.- Throws:
IOException
-
addFont
public void addFont(FSSupplier<InputStream> supplier, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup) Adds a font specified by an input stream (truetype) to a specific font group. -
addFont
@Deprecated public void addFont(FSSupplier<InputStream> supplier, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset) Add a font using a InputStream. The given file must be a TrueType Font (.ttf). If you know the underlying stream is a .ttc file you should useaddFontCollection(FSSupplier, String, Integer, IdentValue, boolean)
-
addFont
public void addFont(PDFontSupplier supplier, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup) Add a font specified by a PDFontSupplier to a specific font group. -
addFont
@Deprecated public void addFont(PDFontSupplier supplier, String fontFamilyNameOverride, Integer fontWeightOverride, IdentValue fontStyleOverride, boolean subset) Add a font using a PDFontSupplier. Use this method if you need special rules for font-loading (like using a font-cache) and subclass thePDFontSupplier
.
addFont(FSSupplier, String, Integer, IdentValue, boolean, FontGroup)