Package org.apache.fop.fonts

Examples of org.apache.fop.fonts.EmbedFontInfo


            }
           
            // font file (singular) configuration
            Configuration[] font = fonts.getChildren("font");
            for (int i = 0; i < font.length; i++) {
                EmbedFontInfo fontInfo = getFontInfoFromConfiguration(
                        font[i], fontResolver, strict, fontCache);
                if (fontInfo != null) {
                    fontInfoList.add(fontInfo);
                }
            }
View Full Code Here


            List fontFileList, List fontInfoList, FontResolver resolver, FontCache fontCache) {
        for (Iterator iter = fontFileList.iterator(); iter.hasNext();) {
            File fontFile = (File)iter.next();
            // parse font to ascertain font info
            FontInfoFinder finder = new FontInfoFinder();
            EmbedFontInfo fontInfo = finder.find(fontFile, resolver, fontCache);
            if (fontInfo != null) {
                fontInfoList.add(fontInfo);               
            }
        }
    }
View Full Code Here

            }
            metricsUrl = source.getSystemId(); // absolute path/url
        }
        boolean useKerning = fontCfg.getAttributeAsBoolean("kerning", true);
                       
        EmbedFontInfo fontInfo = null;
        Configuration[] tripletCfg = fontCfg.getChildren("font-triplet");
        // no font triplet info
        if (tripletCfg.length == 0) {
            LogUtil.handleError(log, "font without font-triplet", strict);

            // if not strict try to determine font info from the embed/metrics url
            File fontFile = CachedFontInfo.getFileFromUrls(new String[] {embedUrl, metricsUrl});
            if (fontFile != null) {
                FontInfoFinder finder = new FontInfoFinder();
                return finder.find(fontFile, fontResolver, fontCache);
            } else {
                return null;
            }
        } else {
            List tripleList = new java.util.ArrayList();
            for (int j = 0; j < tripletCfg.length; j++) {
                try {
                    String name = tripletCfg[j].getAttribute("name");
                    if (name == null) {
                        LogUtil.handleError(log, "font-triplet without name", strict);
                        continue;
                    }
                    String weightStr = tripletCfg[j].getAttribute("weight");
                    if (weightStr == null) {
                        LogUtil.handleError(log, "font-triplet without weight", strict);
                        continue;
                    }
                    int weight = FontUtil.parseCSS2FontWeight(weightStr);
                    String style = tripletCfg[j].getAttribute("style");
                    if (style == null) {
                        LogUtil.handleError(log, "font-triplet without style", strict);
                        continue;
                    }
                    tripleList.add(FontInfo.createFontKey(name, style, weight));
                } catch (ConfigurationException e) {
                    LogUtil.handleException(log, e, strict);
                }
            }
           
            fontInfo = new EmbedFontInfo(metricsUrl, useKerning, tripleList, embedUrl);
           
            if (fontCache != null) {
                if (!fontCache.containsFont(fontInfo)) {
                    fontCache.addFont(fontInfo);                   
                }
            }

            if (log.isDebugEnabled()) {
                log.debug("Adding font " + fontInfo.getEmbedFile()
                        + ", metric file " + fontInfo.getMetricsFile());
                for (int j = 0; j < tripleList.size(); ++j) {
                    FontTriplet triplet = (FontTriplet) tripleList.get(j);
                    log.debug("  Font triplet "
                            + triplet.getName() + ", "
                            + triplet.getStyle() + ", "
View Full Code Here

        try {
            embedUrl = fontFile.toURL().toExternalForm();
        } catch (MalformedURLException e) {
            embedUrl = fontFile.getAbsolutePath();
        }
        EmbedFontInfo fontInfo = new EmbedFontInfo(null, customFont.isKerningEnabled(),
                fontTripletList, embedUrl);
        if (fontCache != null) {
            fontCache.addFont(fontInfo);
        }
        return fontInfo;
View Full Code Here

            }
           
            // font file (singular) configuration
            Configuration[] font = fonts.getChildren("font");
            for (int i = 0; i < font.length; i++) {
                EmbedFontInfo fontInfo = getFontInfoFromConfiguration(
                        font[i], fontResolver, strict, fontCache);
                if (fontInfo != null) {
                    fontInfoList.add(fontInfo);
                }
            }
View Full Code Here

            List fontFileList, List fontInfoList, FontResolver resolver, FontCache fontCache) {
        for (Iterator iter = fontFileList.iterator(); iter.hasNext();) {
            URL fontUrl = (URL)iter.next();
            // parse font to ascertain font info
            FontInfoFinder finder = new FontInfoFinder();
            EmbedFontInfo fontInfo = finder.find(fontUrl, resolver, fontCache);
            if (fontInfo != null) {
                fontInfoList.add(fontInfo);               
            }
        }
    }
View Full Code Here

                }
            }
        }
        boolean useKerning = fontCfg.getAttributeAsBoolean("kerning", true);
                       
        EmbedFontInfo fontInfo = null;
        Configuration[] tripletCfg = fontCfg.getChildren("font-triplet");
        // no font triplet info
        if (tripletCfg.length == 0) {
            LogUtil.handleError(log, "font without font-triplet", strict);

            // if not strict try to determine font info from the embed/metrics url
            File fontFile = CachedFontInfo.getFileFromUrls(new String[] {embedUrl, metricsUrl});
            URL fontUrl;
            try {
                fontUrl = fontFile.toURI().toURL();
            } catch (MalformedURLException e) {
                // Should never happen
                log.debug("Malformed Url: " + e.getMessage());
                return null;
            }
            if (fontFile != null) {
                FontInfoFinder finder = new FontInfoFinder();
                return finder.find(fontUrl, fontResolver, fontCache);
            } else {
                return null;
            }
        } else {
            List tripleList = new java.util.ArrayList();
            for (int j = 0; j < tripletCfg.length; j++) {
                try {
                    String name = tripletCfg[j].getAttribute("name");
                    if (name == null) {
                        LogUtil.handleError(log, "font-triplet without name", strict);
                        continue;
                    }
                    String weightStr = tripletCfg[j].getAttribute("weight");
                    if (weightStr == null) {
                        LogUtil.handleError(log, "font-triplet without weight", strict);
                        continue;
                    }
                    int weight = FontUtil.parseCSS2FontWeight(weightStr);
                    String style = tripletCfg[j].getAttribute("style");
                    if (style == null) {
                        LogUtil.handleError(log, "font-triplet without style", strict);
                        continue;
                    }
                    tripleList.add(FontInfo.createFontKey(name, style, weight));
                } catch (ConfigurationException e) {
                    LogUtil.handleException(log, e, strict);
                }
            }
           
            fontInfo = new EmbedFontInfo(metricsUrl, useKerning, tripleList, embedUrl);
           
            if (fontCache != null) {
                if (!fontCache.containsFont(fontInfo)) {
                    fontCache.addFont(fontInfo);                   
                }
            }

            if (log.isDebugEnabled()) {
                log.debug("Adding font " + fontInfo.getEmbedFile()
                        + ", metric file " + fontInfo.getMetricsFile());
                for (int j = 0; j < tripleList.size(); ++j) {
                    FontTriplet triplet = (FontTriplet) tripleList.get(j);
                    log.debug("  Font triplet "
                            + triplet.getName() + ", "
                            + triplet.getStyle() + ", "
View Full Code Here

        }
        String internalName = null;

        for (int i = 0; i < fontList.size(); i++) {

            EmbedFontInfo configFontInfo = (EmbedFontInfo) fontList.get(i);
            String fontFile = configFontInfo.getEmbedFile();
            internalName = "F" + num;
            num++;
            try {
                FontMetricsMapper font = null;
                String metricsUrl = configFontInfo.getMetricsFile();
                // If the user specified an XML-based metrics file, we'll use it
                // Otherwise, calculate metrics directly from the font file.
                if (metricsUrl != null) {
                    LazyFont fontMetrics = new LazyFont(configFontInfo, resolver);
                    Source fontSource = resolver.resolve(configFontInfo.getEmbedFile());
                    font = new CustomFontMetricsMapper(fontMetrics, fontSource);
                } else {
                    CustomFont fontMetrics = FontLoader.loadFont(fontFile, resolver);
                    font = new CustomFontMetricsMapper(fontMetrics);
                }

                fontInfo.addMetrics(internalName, font);

                List triplets = configFontInfo.getFontTriplets();
                for (int c = 0; c < triplets.size(); c++) {
                    FontTriplet triplet = (FontTriplet) triplets.get(c);

                    if (log.isDebugEnabled()) {
                        log.debug("Registering: " + triplet + " under " + internalName);
View Full Code Here

            URL fontUrl, CustomFont customFont, FontCache fontCache) {
        List fontTripletList = new java.util.ArrayList();
        generateTripletsFromFont(customFont, fontTripletList);
        String embedUrl;
        embedUrl = fontUrl.toExternalForm();
        EmbedFontInfo fontInfo = new EmbedFontInfo(null, customFont.isKerningEnabled(),
                fontTripletList, embedUrl);
        if (fontCache != null) {
            fontCache.addFont(fontInfo);
        }
        return fontInfo;
View Full Code Here

        embedUrl = fontUrl.toExternalForm();
        String subFontName = null;
        if (customFont instanceof MultiByteFont) {
            subFontName = ((MultiByteFont)customFont).getTTCName();
        }
        EmbedFontInfo fontInfo = new EmbedFontInfo(null, customFont.isKerningEnabled(),
                fontTripletList, embedUrl, subFontName);
        fontInfo.setPostScriptName(customFont.getFontName());
        if (fontCache != null) {
            fontCache.addFont(fontInfo);
        }
        return fontInfo;
    }
View Full Code Here

TOP

Related Classes of org.apache.fop.fonts.EmbedFontInfo

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.