Package org.apache.pdfbox.pdmodel.font
Class FileSystemFontProvider
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.font.FontProvider
-
- org.apache.pdfbox.pdmodel.font.FileSystemFontProvider
-
final class FileSystemFontProvider extends FontProvider
A FontProvider which searches for fonts on the local filesystem.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classFileSystemFontProvider.FSFontInfo
-
Field Summary
Fields Modifier and Type Field Description private FontCachecacheprivate static java.lang.StringCHECKSUM_PLACEHOLDERprivate java.util.List<FileSystemFontProvider.FSFontInfo>fontInfoListprivate static org.apache.commons.logging.LogLOGprivate static booleanSKIP_CHECKSUMSThis option changes publicly visible behaviour: ".pdfbox.cache" file will have hash="-" for all files.
-
Constructor Summary
Constructors Constructor Description FileSystemFontProvider(FontCache cache)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddTrueTypeCollection(java.io.File ttcFile)Adds a TTC or OTC to the file cache.private voidaddTrueTypeFont(java.io.File ttfFile)Adds an OTF or TTF font to the file cache.private voidaddTrueTypeFontImpl(FontHeaders fontHeaders, java.io.File file, java.lang.String hash)Adds an OTF or TTF font to the file cache.private voidaddType1Font(java.io.File pfbFile)Adds a Type 1 font to the file cache.private static java.lang.StringcomputeHash(java.io.InputStream is)private FileSystemFontProvider.FSFontInfocreateFSIgnored(java.io.File file, FontFormat format, java.lang.String postScriptName)private java.io.FilegetDiskCacheFile()java.util.List<? extends FontInfo>getFontInfo()Returns a list of information about fonts on the system.private static booleanisBadPath(java.lang.String path)private java.util.List<FileSystemFontProvider.FSFontInfo>loadDiskCache(java.util.List<java.io.File> files)Loads the font metadata cache from disk.private voidsaveDiskCache()Saves the font metadata cache to disk.private voidscanFonts(java.util.List<java.io.File> files)java.lang.StringtoDebugString()Returns a string containing debugging information.private voidwriteFontInfo(java.io.BufferedWriter writer, FileSystemFontProvider.FSFontInfo fontInfo)
-
-
-
Field Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
-
SKIP_CHECKSUMS
private static final boolean SKIP_CHECKSUMS
This option changes publicly visible behaviour: ".pdfbox.cache" file will have hash="-" for all files. After implementingFontHeaders, parsing font headers is faster than checksumming anyway.
-
CHECKSUM_PLACEHOLDER
private static final java.lang.String CHECKSUM_PLACEHOLDER
- See Also:
- Constant Field Values
-
fontInfoList
private final java.util.List<FileSystemFontProvider.FSFontInfo> fontInfoList
-
cache
private final FontCache cache
-
-
Constructor Detail
-
FileSystemFontProvider
FileSystemFontProvider(FontCache cache)
Constructor.
-
-
Method Detail
-
createFSIgnored
private FileSystemFontProvider.FSFontInfo createFSIgnored(java.io.File file, FontFormat format, java.lang.String postScriptName)
-
scanFonts
private void scanFonts(java.util.List<java.io.File> files)
-
getDiskCacheFile
private java.io.File getDiskCacheFile()
-
isBadPath
private static boolean isBadPath(java.lang.String path)
-
saveDiskCache
private void saveDiskCache()
Saves the font metadata cache to disk.
-
writeFontInfo
private void writeFontInfo(java.io.BufferedWriter writer, FileSystemFontProvider.FSFontInfo fontInfo) throws java.io.IOException- Throws:
java.io.IOException
-
loadDiskCache
private java.util.List<FileSystemFontProvider.FSFontInfo> loadDiskCache(java.util.List<java.io.File> files)
Loads the font metadata cache from disk.
-
addTrueTypeCollection
private void addTrueTypeCollection(java.io.File ttcFile)
Adds a TTC or OTC to the file cache. To reduce memory, the parsed font is not cached.
-
addTrueTypeFont
private void addTrueTypeFont(java.io.File ttfFile)
Adds an OTF or TTF font to the file cache. To reduce memory, the parsed font is not cached.
-
addTrueTypeFontImpl
private void addTrueTypeFontImpl(FontHeaders fontHeaders, java.io.File file, java.lang.String hash)
Adds an OTF or TTF font to the file cache. To reduce memory, the parsed font is not cached.
-
addType1Font
private void addType1Font(java.io.File pfbFile)
Adds a Type 1 font to the file cache. To reduce memory, the parsed font is not cached.
-
toDebugString
public java.lang.String toDebugString()
Description copied from class:FontProviderReturns a string containing debugging information. This will be written to the log if no suitable fonts are found and no fallback fonts are available. May be null.- Specified by:
toDebugStringin classFontProvider- Returns:
- string with debug information or null
-
getFontInfo
public java.util.List<? extends FontInfo> getFontInfo()
Description copied from class:FontProviderReturns a list of information about fonts on the system.- Specified by:
getFontInfoin classFontProvider- Returns:
- a list of FntInfo instances for all fonts on the system
-
computeHash
private static java.lang.String computeHash(java.io.InputStream is) throws java.io.IOException- Throws:
java.io.IOException
-
-