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

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

    org.apache.commons.io.DirectoryWalker.CancelException
  • Field Summary

    Fields
    Modifier and Type Field Description
    static int DEFAULT_DEPTH_LIMIT
    default depth limit of recursion when searching for font files
  • Constructor Summary

    Constructors
    Constructor Description
    FontFileFinder​(int depthLimit, FontEventListener listener)
    Constructor
    FontFileFinder​(FontEventListener listener)
    Default constructor
  • Method Summary

    Modifier and Type Method Description
    java.util.List<java.net.URL> find()
    Automagically finds a list of font files on local system
    java.util.List<java.net.URL> find​(java.lang.String dir)
    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​(java.io.File directory, int depth, java.util.Collection results)  
    protected void handleDirectoryEnd​(java.io.File directory, int depth, java.util.Collection results)  
    protected void handleFile​(java.io.File file, int depth, java.util.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 Details

    • 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 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​(java.io.File directory, int depth, java.util.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​(java.io.File file, int depth, java.util.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​(java.io.File directory, int depth, java.util.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 java.util.List<java.net.URL> find() throws java.io.IOException
      Automagically finds a list of font files on local system
      Specified by:
      find in interface FontFinder
      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.IOException
      Searches 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