Package org.apache.fop.fonts.autodetect
Class FontFileFinder
- java.lang.Object
-
- org.apache.commons.io.DirectoryWalker
-
- org.apache.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.
-
-
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(int depthLimit, FontEventListener listener)ConstructorFontFileFinder(FontEventListener listener)Default constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.net.URL>find()Automagically finds a list of font files on local systemjava.util.List<java.net.URL>find(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 Detail
-
DEFAULT_DEPTH_LIMIT
public static final int DEFAULT_DEPTH_LIMIT
default depth limit of recursion when searching for font files- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FontFileFinder
public FontFileFinder(FontEventListener listener)
Default constructor- Parameters:
listener- for throwing font related events
-
FontFileFinder
public FontFileFinder(int depthLimit, FontEventListener listener)Constructor- Parameters:
depthLimit- recursion depth limitlistener- for throwing font related events
-
-
Method Detail
-
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<java.net.URL> 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<java.net.URL> 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
-
-