protected static DefaultFontMapper getMapper() {
    if (mapper == null) {
      //      long t = System.currentTimeMillis();
      mapper = new DefaultFontMapper();

      if (PApplet.platform == PApplet.MACOSX) {
        try {
          String homeLibraryFonts = System.getProperty("user.home") + "/Library/Fonts";
          mapper.insertDirectory(homeLibraryFonts);
        } catch (Exception e) {
          // might be a security issue with getProperty() and user.home
          // if this sketch is running from the web
        }
        // add the system font paths
        mapper.insertDirectory("/System/Library/Fonts");
        mapper.insertDirectory("/Library/Fonts");

      } else if (PApplet.platform == PApplet.WINDOWS) {
        // how to get the windows fonts directory?
        // could be c:\winnt\fonts or c:\windows\fonts or not even c:
        // maybe do a Runtime.exec() on echo %WINDIR% ?
        // Runtime.exec solution might be a mess on systems where the
        // the backslash/colon characters not really used (i.e. JP)

        // find the windows fonts folder
        File roots[] = File.listRoots();
        for (int i = 0; i < roots.length; i++) {
          if (roots[i].toString().startsWith("A:")) {
            // Seems to be a problem with some machines that the A:
            // drive is returned as an actual root, even if not available.
            // This won't fix the issue if the same thing happens with
            // other removable drive devices, but should fix the
            // initial/problem as cited by the bug report:
            // http://dev.processing.org/bugs/show_bug.cgi?id=478
            // If not, will need to use the other fileExists() code below.
            continue;
          }

          File folder = new File(roots[i], "WINDOWS/Fonts");
          if (folder.exists()) {
            mapper.insertDirectory(folder.getAbsolutePath());
            break;
          }
          folder = new File(roots[i], "WINNT/Fonts");
          if (folder.exists()) {
            mapper.insertDirectory(folder.getAbsolutePath());
            break;
          }
        }
      }
      //      System.out.println("mapping " + (System.currentTimeMillis() - t));
    }
    return mapper;
  }
 /**
  * Check whether the specified font can be used with the PDF library.
  *
  * @param name name of the font
  * @return true if it's ok
  */
 protected boolean checkFont(String name) {
   System.out.println("alias for " + name + " = " + mapper.getAliases().get(name));
   return mapper.getAliases().get(name) != null;
 }
 /**
  * Add a directory that should be searched for font data. <br>
  * On Mac OS X, the following directories are added by default:
  *
  * <UL>
  *   <LI>/System/Library/Fonts
  *   <LI>/Library/Fonts
  *   <LI>~/Library/Fonts
  * </UL>
  *
  * On Windows, all drive letters are searched for WINDOWS\Fonts or WINNT\Fonts, any that exists is
  * added. <br>
  * <br>
  * On Linux or any other platform, you'll need to add the directories by hand. (If there are
  * actual standards here that we can use as a starting point, please file a bug to make a note of
  * it)
  */
 public void addFonts(String directory) {
   mapper.insertDirectory(directory);
 }