Class FontFileFinder
java.lang.Object
org.apache.commons.io.DirectoryWalker
org.docx4j.fonts.fop.fonts.autodetect.FontFileFinder
- All Implemented Interfaces:
FontFinder
public class FontFileFinder extends org.apache.commons.io.DirectoryWalker implements FontFinder
Helps to autodetect/locate available operating system fonts.
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_DEPTH_LIMITdefault depth limit of recursion when searching for font files -
Constructor Summary
Constructors Constructor Description FontFileFinder()Default constructorFontFileFinder(int depthLimit)Constructor -
Method Summary
Modifier and Type Method Description java.util.Listfind()Automagically finds a list of font files on local systemjava.util.Listfind(java.lang.String dir)Searches a given directory for font filesprotected static org.apache.commons.io.filefilter.IOFileFiltergetDirectoryFilter()Font directory filter.protected static org.apache.commons.io.filefilter.IOFileFiltergetFileFilter()Font file filter.protected booleanhandleDirectory(java.io.File directory, int depth, java.util.Collection results)protected voidhandleDirectoryEnd(java.io.File directory, int depth, java.util.Collection results)protected voidhandleFile(java.io.File file, int depth, java.util.Collection results)
-
Field Details
-
DEFAULT_DEPTH_LIMIT
public static final int DEFAULT_DEPTH_LIMITdefault depth limit of recursion when searching for font files- See Also:
- Constant Field Values
-
-
Constructor Details
-
FontFileFinder
public FontFileFinder()Default constructor -
FontFileFinder
public FontFileFinder(int depthLimit)Constructor- Parameters:
depthLimit- recursion depth limit
-
-
Method Details
-
getDirectoryFilter
protected static org.apache.commons.io.filefilter.IOFileFilter getDirectoryFilter()Font directory filter. Currently ignores hidden directories.- Returns:
- IOFileFilter font directory filter
-
getFileFilter
protected static org.apache.commons.io.filefilter.IOFileFilter getFileFilter()Font file filter. Currently searches for files with .ttf, .ttc, .otf, and .pfb extensions.- Returns:
- IOFileFilter font file filter
-
handleDirectory
protected boolean handleDirectory(java.io.File directory, int depth, java.util.Collection results)- Overrides:
handleDirectoryin classorg.apache.commons.io.DirectoryWalker- Parameters:
directory- directory to handledepth- recursion depthresults- collection- Returns:
- whether directory should be handled
-
handleFile
protected void handleFile(java.io.File file, int depth, java.util.Collection results)- Overrides:
handleFilein classorg.apache.commons.io.DirectoryWalker- Parameters:
file- file to handledepth- recursion depthresults- collection
-
handleDirectoryEnd
protected void handleDirectoryEnd(java.io.File directory, int depth, java.util.Collection results)- Overrides:
handleDirectoryEndin classorg.apache.commons.io.DirectoryWalker- Parameters:
directory- the directory being processeddepth- the current directory levelresults- the collection of results objects
-
find
public java.util.List find() throws java.io.IOExceptionAutomagically finds a list of font files on local system- Specified by:
findin interfaceFontFinder- Returns:
- List<URL> of font files
- Throws:
java.io.IOException- io exception In case of an I/O problem
-
find
public java.util.List find(java.lang.String dir) throws java.io.IOExceptionSearches a given directory for font files- Parameters:
dir- directory to search- Returns:
- list of font files
- Throws:
java.io.IOException- thrown if an I/O exception of some sort has occurred
-