Properties loadEmbeddedFontDefinitions() {
    Properties map = new Properties();
    // locate the META-INF directory and search for a fonts.mf
    // located there
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    URL u = loader.getResource("META-INF/fonts.mf");
    if (u == null) return map;

    // read in the contents of the file
    try (InputStream in = u.openStream()) {
      map.load(in);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return map;
  }
 private void loadEmbeddedFonts() {
   if (!embeddedFontsLoaded) {
     FontFactory fontFactory = getFontFactoryFromPipeline();
     if (!fontFactory.hasPermission()) {
       embeddedFontsLoaded = true;
       return;
     }
     Properties map = loadEmbeddedFontDefinitions();
     Enumeration<?> names = map.keys();
     ClassLoader loader = Thread.currentThread().getContextClassLoader();
     while (names.hasMoreElements()) {
       String n = (String) names.nextElement();
       String p = map.getProperty(n);
       if (p.startsWith("/")) {
         p = p.substring(1);
         try (InputStream in = loader.getResourceAsStream(p)) {
           fontFactory.loadEmbeddedFont(n, in, 0, true);
         } catch (Exception e) {
         }
       }
     }
     embeddedFontsLoaded = true;
   }
 }