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.

### Nested Class Summary

### Nested classes/interfaces inherited from class org.apache.commons.io.DirectoryWalker

`org.apache.commons.io.DirectoryWalker.CancelException`

### Field Summary

Fields
`static int` `DEFAULT_DEPTH_LIMIT` default depth limit of recursion when searching for font files

### Constructor Summary

Constructors
Constructor and Description
`FontFileFinder(FontEventListener listener)` Default constructor
`FontFileFinder(int depthLimit, FontEventListener listener)` Constructor

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`List<URL>` `find()` Automagically finds a list of font files on local system
`List<URL>` `find(File directory)` Searches a given directory for font files
`protected static org.apache.commons.io.filefilter.IOFileFilter` `getDirectoryFilter()` Font directory filter.
`protected static org.apache.commons.io.filefilter.IOFileFilter` `getFileFilter()` Font file filter.
`protected boolean` `handleDirectory(File directory, int depth, Collection results)`
`protected void` `handleDirectoryEnd(File directory, int depth, Collection results)`
`protected void` `handleFile(File file, int depth, Collection results)`

### Methods inherited from class org.apache.commons.io.DirectoryWalker

`checkIfCancelled, filterDirectoryContents, handleCancelled, handleDirectoryStart, handleEnd, handleIsCancelled, handleRestricted, handleStart, walk`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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 limit
  `listener` - 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(File directory,
                                      int depth,
                                      Collection results)

Overrides:
  `handleDirectory` in class `org.apache.commons.io.DirectoryWalker`
Parameters:
  `directory` - directory to handle
  `depth` - recursion depth
  `results` - collection
Returns:
  whether directory should be handled

#### handleFile

    protected void handleFile(File file,
                              int depth,
                              Collection results)

Overrides:
  `handleFile` in class `org.apache.commons.io.DirectoryWalker`
Parameters:
  `file` - file to handle
  `depth` - recursion depth
  `results` - collection

#### handleDirectoryEnd

    protected void handleDirectoryEnd(File directory,
                                      int depth,
                                      Collection results)

Overrides:
  `handleDirectoryEnd` in class `org.apache.commons.io.DirectoryWalker`
Parameters:
  `directory` - the directory being processed
  `depth` - the current directory level
  `results` - the collection of results objects

#### find

    public List<URL> find()
                   throws IOException

Automagically finds a list of font files on local system

Specified by:
  `find` in interface `FontFinder`
Returns:
  List<URL> of font files
Throws:
  `IOException` - io exception In case of an I/O problem

#### find

    public List<URL> find(File directory)
                   throws IOException

Searches a given directory for font files

Parameters:
  `directory` - directory to search
Returns:
  list of font files
Throws:
  `IOException` - thrown if an I/O exception of some sort has occurred