Package org.apache.fop.fonts.autodetect

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


            // 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

     * @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

                        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

     * @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

                        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

                        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

TOP

Related Classes of org.apache.fop.fonts.autodetect.FontFileFinder

Copyright © 2018 www.massapicom. 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.