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 Details

    • log

      private final org.apache.commons.logging.Log log
      logging instance
    • DEFAULT_DEPTH_LIMIT

      public static final int DEFAULT_DEPTH_LIMIT
      default depth limit of recursion when searching for font files
      See Also:
    • eventListener

      private final FontEventListener eventListener
  • Constructor Details

    • 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 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(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
    • walkDirectory

      private void walkDirectory(File startDirectory, Collection<URL> results) throws IOException
      Throws:
      IOException
    • walk

      private void walk(File directory, int depth, Collection<URL> results, Map<String,String> visitedSymlinks) throws IOException
      Throws:
      IOException
    • hasSymlinkBeenWalked

      private boolean hasSymlinkBeenWalked(File symlink, Map<String,String> visitedSymlinks)