Examples of FontFileFinder


Examples of org.apache.fontbox.util.autodetect.FontFileFinder

        {
            LOG.trace("Will search the local system for fonts");
        }

        int count = 0;
        FontFileFinder fontFileFinder = new FontFileFinder();
        List<URI> fonts = fontFileFinder.find();
        for (URI font : fonts)
        {
            count++;
            File fontFile = new File(font);
            try
View Full Code Here

Examples of org.apache.fontbox.util.autodetect.FontFileFinder

     */
    private static void loadFonts()
    {
        try
        {
            FontFileFinder fontfinder = new FontFileFinder();
            List<URI> fonts = fontfinder.find();
            for (URI font : fonts)
            {
                try
                {
                    // the URL may contain some escaped characters like spaces
                    // use the URI to decode such escape sequences
                    String fontfilename = new File(font).getPath();
                    if (fontfilename.toLowerCase().endsWith(".ttf"))
                    {
                        analyzeTTF(fontfilename);
                    }
                    else
                    {
                        LOG.debug("Unsupported font format for external font: " + fontfilename);
                    }
                }
                catch (IOException exception)
                {
                    LOG.debug("Can't read external font: " + font.getPath(), exception);
                }
            }
            addFontMapping(fontfinder.getCommonTTFMapping(), fontMappingTTF);
            createFontmapping();
        }
        catch (IOException exception)
        {
            LOG.error("An error occured when collecting external fonts.", exception);
View Full Code Here

Examples of org.apache.fop.fonts.autodetect.FontFileFinder

            // native o/s search (autodetect) configuration
            boolean autodetectFonts = (fonts.getChild("auto-detect", false) != null);
            if (!autodetectedFonts && autodetectFonts) {
                // search in font base if it is defined and
                // is a directory but don't recurse
                FontFileFinder fontFileFinder = new FontFileFinder();
                if (fontBaseURL != null) {
                    try {
                        File fontBase = FileUtils.toFile(new URL(fontBaseURL));
                        if (fontBase != null) {
                            //Can only use the font base URL if it's a file URL
                            addFontInfoListFromFileList(
                                    fontFileFinder.find(fontBase.getAbsolutePath()),
                                    fontInfoList,
                                    fontResolver,
                                    fontCache
                            );
                        }
                    } catch (IOException e) {
                        LogUtil.handleException(log, e, strict);
                    }
                }

                // native o/s font directory finder
                try {
                    addFontInfoListFromFileList(
                            fontFileFinder.find(),
                            fontInfoList,
                            fontResolver,
                            fontCache
                    );
                } catch (IOException e) {
                    LogUtil.handleException(log, e, strict);
                }
                autodetectedFonts = true;
            }

            // directory (multiple font) configuration
            Configuration[] directories = fonts.getChildren("directory");
            for (int i = 0; i < directories.length; i++) {
                boolean recursive = directories[i].getAttributeAsBoolean("recursive", false);
                String directory = null;
                try {
                    directory = directories[i].getValue();
                } catch (ConfigurationException e) {
                    LogUtil.handleException(log, e, strict);
                    continue;
                }
                if (directory == null) {
                    LogUtil.handleException(log,
                            new FOPException("directory defined without value"), strict);
                    continue;
                }
                FontFileFinder fontFileFinder = new FontFileFinder(recursive ? -1 : 1);
                try {
                    addFontInfoListFromFileList(
                            fontFileFinder.find(directory),
                            fontInfoList,
                            fontResolver,
                            fontCache
                    );
                } catch (IOException e) {
View Full Code Here

Examples of org.apache.fop.fonts.autodetect.FontFileFinder

            // native o/s search (autodetect) configuration
            boolean autodetectFonts = (fonts.getChild("auto-detect", false) != null);
            if (autodetectFonts) {
                // search in font base if it is defined and
                // is a directory but don't recurse
                FontFileFinder fontFileFinder = new FontFileFinder();
                if (fontBaseURL != null) {
                    try {
                        File fontBase = FileUtils.toFile(new URL(fontBaseURL));
                        if (fontBase != null) {
                            //Can only use the font base URL if it's a file URL
                            addFontInfoListFromFileList(
                                    fontFileFinder.find(fontBase.getAbsolutePath()),
                                    fontInfoList,
                                    fontResolver,
                                    fontCache
                            );
                        }
                    } catch (IOException e) {
                        LogUtil.handleException(log, e, strict);
                    }
                }

                // native o/s font directory finder
                try {
                    addFontInfoListFromFileList(
                            fontFileFinder.find(),
                            fontInfoList,
                            fontResolver,
                            fontCache
                    );
                } catch (IOException e) {
                    LogUtil.handleException(log, e, strict);
                }

                // load fonts from classpath
                addFontInfoListFromFileList(ClasspathResource.getInstance()
                        .listResourcesOfMimeType("application/x-font"),
                        fontInfoList, fontResolver, fontCache);
                addFontInfoListFromFileList(
                        ClasspathResource.getInstance()
                                .listResourcesOfMimeType(
                                        "application/x-font-truetype"),
                        fontInfoList, fontResolver, fontCache);
            }

            // directory (multiple font) configuration
            Configuration[] directories = fonts.getChildren("directory");
            for (int i = 0; i < directories.length; i++) {
                boolean recursive = directories[i].getAttributeAsBoolean("recursive", false);
                String directory = null;
                try {
                    directory = directories[i].getValue();
                } catch (ConfigurationException e) {
                    LogUtil.handleException(log, e, strict);
                    continue;
                }
                if (directory == null) {
                    LogUtil.handleException(log,
                            new FOPException("directory defined without value"), strict);
                    continue;
                }
                FontFileFinder fontFileFinder = new FontFileFinder(recursive ? -1 : 1);
                try {
                    addFontInfoListFromFileList(
                            fontFileFinder.find(directory),
                            fontInfoList,
                            fontResolver,
                            fontCache
                    );
                } catch (IOException e) {
View Full Code Here

Examples of org.apache.fop.fonts.autodetect.FontFileFinder

     * @throws FOPException thrown if a problem occurred during detection
     */
    public void detect(List/*<EmbedFontInfo>*/ fontInfoList) throws FOPException {
        // search in font base if it is defined and
        // is a directory but don't recurse
        FontFileFinder fontFileFinder = new FontFileFinder();
        String fontBaseURL = fontManager.getFontBaseURL();
        if (fontBaseURL != null) {
            try {
                File fontBase = FileUtils.toFile(new URL(fontBaseURL));
                if (fontBase != null) {
                    List/*<URL>*/ fontURLList = fontFileFinder.find(
                            fontBase.getAbsolutePath());
                    fontAdder.add(fontURLList, fontInfoList);
                   
                    //Can only use the font base URL if it's a file URL
                }
            } catch (IOException e) {
                LogUtil.handleException(log, e, strict);
            }
        }

        // native o/s font directory finding
        List/*<URL>*/ systemFontList;
        try {
            systemFontList = fontFileFinder.find();
            fontAdder.add(systemFontList, fontInfoList);
        } catch (IOException e) {
            LogUtil.handleException(log, e, strict);
        }

View Full Code Here

Examples of org.apache.fop.fonts.autodetect.FontFileFinder

                        new FOPException("directory defined without value"), strict);
                continue;
            }

            // add fonts found in directory
            FontFileFinder fontFileFinder = new FontFileFinder(recursive ? -1 : 1, listener);
            List<URL> fontURLList;
            try {
                fontURLList = fontFileFinder.find(directory);
                fontAdder.add(fontURLList, fontInfoList);
            } catch (IOException e) {
                LogUtil.handleException(log, e, strict);
            }
        }
View Full Code Here

Examples of org.apache.fop.fonts.autodetect.FontFileFinder

     * @throws FOPException thrown if a problem occurred during detection
     */
    public void detect(List<EmbedFontInfo> fontInfoList) throws FOPException {
        // search in font base if it is defined and
        // is a directory but don't recurse
        FontFileFinder fontFileFinder = new FontFileFinder(eventListener);
        String fontBaseURL = fontManager.getFontBaseURL();
        if (fontBaseURL != null) {
            try {
                File fontBase = FileUtils.toFile(new URL(fontBaseURL));
                if (fontBase != null) {
                    List<URL> fontURLList = fontFileFinder.find(fontBase.getAbsolutePath());
                    fontAdder.add(fontURLList, fontInfoList);

                    //Can only use the font base URL if it's a file URL
                }
            } catch (IOException e) {
                LogUtil.handleException(log, e, strict);
            }
        }

        // native o/s font directory finding
        List<URL> systemFontList;
        try {
            systemFontList = fontFileFinder.find();
            fontAdder.add(systemFontList, fontInfoList);
        } catch (IOException e) {
            LogUtil.handleException(log, e, strict);
        }

View Full Code Here

Examples of org.apache.fop.fonts.autodetect.FontFileFinder

                        new FOPException("directory defined without value"), strict);
                continue;
            }

            // add fonts found in directory
            FontFileFinder fontFileFinder = new FontFileFinder(recursive ? -1 : 1);
            List/*<URL>*/ fontURLList;
            try {
                fontURLList = fontFileFinder.find(directory);
                fontAdder.add(fontURLList, fontInfoList);
            } catch (IOException e) {
                LogUtil.handleException(log, e, strict);
            }
        }
View Full Code Here

Examples of org.apache.fop.fonts.autodetect.FontFileFinder

                        new FOPException("directory defined without value"), strict);
                continue;
            }

            // add fonts found in directory
            FontFileFinder fontFileFinder = new FontFileFinder(recursive ? -1 : 1, listener);
            List<URL> fontURLList;
            try {
                fontURLList = fontFileFinder.find(directory);
                fontAdder.add(fontURLList, fontInfoList);
            } catch (IOException e) {
                LogUtil.handleException(log, e, strict);
            }
        }
View Full Code Here

Examples of org.docx4j.fonts.fop.fonts.autodetect.FontFileFinder

    // Currently we use FOP - inspired by org.apache.fop.render.PrintRendererConfigurator
    // iText also has a font discoverer (which we could use
    // instead, but don't, since in docx4j we're settled on
    // PDF output via XSL FO)   
   
        FontFileFinder fontFileFinder = new FontFileFinder();
       
        // Automagically finds a list of font files on local system
        // based on os.name
        List fontFileList = fontFileFinder.find();     
       
       
        if (regex==null) {
            for (Iterator iter = fontFileList.iterator(); iter.hasNext();) {
             
              URL fontUrl = getURL(iter.next());
               
                // parse font to ascertain font info
              addPhysicalFont( fontUrl);
            }
        } else {
          Pattern pattern = Pattern.compile(regex);
            for (Iterator iter = fontFileList.iterator(); iter.hasNext();) {
             
              URL fontUrl = getURL(iter.next());
               
             
                // parse font to ascertain font info
              if (pattern.matcher(fontUrl.toString()).matches()){
                addPhysicalFont( fontUrl);           
              } else {
//                  log.debug("Ignoring " + fontUrl.toString() );

              }
            }
        }
       

        // Add fonts from our Temporary Embedded Fonts dir
        fontFileList = fontFileFinder.find( ObfuscatedFontPart.getTemporaryEmbeddedFontsDir() );
        for (Iterator iter = fontFileList.iterator(); iter.hasNext();) {
            URL fontUrl = getURL(iter.next());
            addPhysicalFont( fontUrl);
        }
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.