Examples of CustomFont


Examples of org.apache.fop.fonts.CustomFont

                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);
View Full Code Here

Examples of org.apache.fop.fonts.CustomFont

            AbstractPDFStream stream = makeFontFile(desc);
            if (stream != null) {
                descriptor.setFontFile(desc.getFontType(), stream);
                getDocument().registerObject(stream);
            }
            CustomFont font = getCustomFont(desc);
            if (font instanceof CIDFont) {
                CIDFont cidFont = (CIDFont)font;
                buildCIDSet(descriptor, cidFont);
            }
        }
View Full Code Here

Examples of org.apache.fop.fonts.CustomFont

        if (desc.getFontType() == FontType.OTHER) {
            throw new IllegalArgumentException("Trying to embed unsupported font type: "
                                                + desc.getFontType());
        }

        CustomFont font = getCustomFont(desc);

        InputStream in = null;
        try {
            Source source = font.getEmbedFileSource();
            if (source == null && font.getEmbedResourceName() != null) {
                source = new StreamSource(this.getClass()
                        .getResourceAsStream(font.getEmbedResourceName()));
            }
            if (source == null) {
                return null;
            }
            if (source instanceof StreamSource) {
View Full Code Here

Examples of org.apache.fop.fonts.CustomFont

                return null;
            }
        }
       
        // try to determine triplet information from font file
        CustomFont customFont = null;
        try {
            customFont = FontLoader.loadFont(fontUrl, resolver);
        } catch (Exception e) {
            //TODO Too verbose (it's an error but we don't care if some fonts can't be loaded)
            if (log.isErrorEnabled()) {
View Full Code Here

Examples of org.apache.fop.fonts.CustomFont

            }
        }


        // try to determine triplet information from font file
        CustomFont customFont = null;
        if (fontUrl.toExternalForm().endsWith(".ttc")) {
            // Get a list of the TTC Font names
            List ttcNames = null; //List<String>
            String fontFileURI = fontUrl.toExternalForm().trim();
            InputStream in = null;
            try {
                in = FontLoader.openFontUri(resolver, fontFileURI);
                TTFFile ttf = new TTFFile();
                FontFileReader reader = new FontFileReader(in);
                ttcNames = ttf.getTTCnames(reader);
            } catch (Exception e) {
                if (this.eventListener != null) {
                    this.eventListener.fontLoadingErrorAtAutoDetection(this, fontFileURI, e);
                }
                return null;
            } finally {
                IOUtils.closeQuietly(in);
            }

            List/*<EmbedFontInfo>*/ embedFontInfoList
                = new java.util.ArrayList/*<EmbedFontInfo>*/();

            // For each font name ...
            //for (String fontName : ttcNames) {
            Iterator ttcNamesIterator = ttcNames.iterator();
            while (ttcNamesIterator.hasNext()) {
                String fontName = (String)ttcNamesIterator.next();

                if (log.isDebugEnabled()) {
                    log.debug("Loading " + fontName);
                }
                try {
                    TTFFontLoader ttfLoader = new TTFFontLoader(
                            fontFileURI, fontName, true, EncodingMode.AUTO, true, resolver);
                    customFont = ttfLoader.getFont();
                    if (this.eventListener != null) {
                        customFont.setEventListener(this.eventListener);
                    }
                } catch (Exception e) {
                    if (fontCache != null) {
                        fontCache.registerFailedFont(embedUrl, fileLastModified);
                    }
                    if (this.eventListener != null) {
                        this.eventListener.fontLoadingErrorAtAutoDetection(this, embedUrl, e);
                    }
                    continue;
                }
                EmbedFontInfo fi = getFontInfoFromCustomFont(fontUrl, customFont, fontCache);
                if (fi != null) {
                    embedFontInfoList.add(fi);
                }
            }
            return (EmbedFontInfo[])embedFontInfoList.toArray(
                    new EmbedFontInfo[embedFontInfoList.size()]);
        } else {
            // The normal case
            try {
                customFont = FontLoader.loadFont(fontUrl, null, true, EncodingMode.AUTO, resolver);
                if (this.eventListener != null) {
                    customFont.setEventListener(this.eventListener);
                }
            } catch (Exception e) {
                if (fontCache != null) {
                    fontCache.registerFailedFont(embedUrl, fileLastModified);
                }
View Full Code Here

Examples of org.apache.fop.fonts.CustomFont

                if (metricsUrl != null) {
                    LazyFont fontMetrics = new LazyFont(configFontInfo, fontResolver);
                    Source fontSource = fontResolver.resolve(configFontInfo.getEmbedFile());
                    font = new CustomFontMetricsMapper(fontMetrics, fontSource);
                } else {
                    CustomFont fontMetrics = FontLoader.loadFont(
                            fontFile, null, true, EncodingMode.AUTO,
                            configFontInfo.getKerning(), fontResolver);
                    font = new CustomFontMetricsMapper(fontMetrics);
                }
View Full Code Here

Examples of org.apache.fop.fonts.CustomFont

    public static void embedFont(PSGenerator gen, Typeface tf, PSResource fontRes)
                throws IOException {
        boolean embeddedFont = false;
        if (FontType.TYPE1 == tf.getFontType()) {
            if (tf instanceof CustomFont) {
                CustomFont cf = (CustomFont)tf;
                if (isEmbeddable(cf)) {
                    InputStream in = getInputStreamOnFont(gen, cf);
                    if (in != null) {
                        gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE,
                                fontRes);
                        embedType1Font(gen, in);
                        gen.writeDSCComment(DSCConstants.END_RESOURCE);
                        gen.getResourceTracker().registerSuppliedResource(fontRes);
                        embeddedFont = true;
                    } else {
                        gen.commentln("%WARNING: Could not embed font: " + cf.getFontName());
                        log.warn("Font " + cf.getFontName() + " is marked as supplied in the"
                                + " PostScript file but could not be embedded!");
                    }
                }
            }
        }
View Full Code Here

Examples of org.apache.fop.fonts.CustomFont

            Typeface tf = getTypeFace(fontInfo, fonts, key);
            PSResource fontRes = new PSResource("font", tf.getFontName());
            fontResources.put(key, fontRes);
            if (FontType.TYPE1 == tf.getFontType()) {
                if (tf instanceof CustomFont) {
                    CustomFont cf = (CustomFont)tf;
                    if (isEmbeddable(cf)) {
                        resTracker.registerSuppliedResource(fontRes);
                    }
                    if (tf instanceof SingleByteFont) {
                        SingleByteFont sbf = (SingleByteFont)tf;
View Full Code Here

Examples of org.apache.fop.fonts.CustomFont

                if (metricsUrl != null) {
                    LazyFont fontMetrics = new LazyFont(configFontInfo, fontResolver);
                    Source fontSource = fontResolver.resolve(configFontInfo.getEmbedFile());
                    font = new CustomFontMetricsMapper(fontMetrics, fontSource);
                } else {
                    CustomFont fontMetrics = FontLoader.loadFont(
                            fontFile, null, true, configFontInfo.getEmbeddingMode(),
                            EncodingMode.AUTO,
                            configFontInfo.getKerning(),
                            configFontInfo.getAdvanced(), fontResolver);
                    font = new CustomFontMetricsMapper(fontMetrics);
View Full Code Here

Examples of org.apache.fop.fonts.CustomFont

            AbstractPDFStream stream = makeFontFile(desc);
            if (stream != null) {
                descriptor.setFontFile(desc.getFontType(), stream);
                getDocument().registerObject(stream);
            }
            CustomFont font = getCustomFont(desc);
            if (font instanceof CIDFont) {
                CIDFont cidFont = (CIDFont)font;
                buildCIDSet(descriptor, cidFont);
            }
        }
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.