Examples of CustomFont


Examples of org.apache.fop.fonts.CustomFont

                ((PDFFontType0)font).setDescendantFonts(cidFont);
            } else {
                int firstChar = 0;
                int lastChar = 255;
                if (metrics instanceof CustomFont) {
                    CustomFont cf = (CustomFont)metrics;
                    firstChar = cf.getFirstChar();
                    lastChar = cf.getLastChar();
                }
                font.setWidthMetrics(firstChar,
                                     lastChar,
                                     makeArray(metrics.getWidths()));
            }
View Full Code Here

Examples of org.apache.fop.fonts.CustomFont

        if (!(tempFont instanceof CustomFont)) {
            throw new IllegalArgumentException(
                      "FontDescriptor must be instance of CustomFont, but is a "
                       + desc.getClass().getName());
        }
        CustomFont font = (CustomFont)tempFont;

        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

            PSResource fontRes = new PSResource("font", tf.getFontName());
            fontResources.put(key, fontRes);
            boolean embeddedFont = false;
            if (FontType.TYPE1 == tf.getFontType()) {
                if (tf instanceof CustomFont) {
                    CustomFont cf = (CustomFont)tf;
                    InputStream in = getInputStreamOnFont(gen, cf);
                    if (in != null) {
                        gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE,
                                fontRes);
                        embedType1Font(gen, in);
View Full Code Here

Examples of org.apache.fop.fonts.CustomFont

            PSResource fontRes = new PSResource("font", tf.getFontName());
            fontResources.put(key, fontRes);
            boolean embeddedFont = false;
            if (FontType.TYPE1 == tf.getFontType()) {
                if (tf instanceof CustomFont) {
                    CustomFont cf = (CustomFont)tf;
                    InputStream in = getInputStreamOnFont(gen, cf);
                    if (in != null) {
                        gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE,
                                fontRes);
                        embedType1Font(gen, in);
View Full Code Here

Examples of org.apache.fop.fonts.CustomFont

                || fontType == FontType.TYPE0) || !(tf instanceof CustomFont)) {
            gen.writeDSCComment(DSCConstants.INCLUDE_RESOURCE, fontRes);
            fontResource = PSFontResource.createFontResource(fontRes);
            return fontResource;
        }
        CustomFont cf = (CustomFont)tf;
        if (isEmbeddable(cf)) {
            InputStream in = getInputStreamOnFont(gen, cf);
            if (in == null) {
                gen.commentln("%WARNING: Could not embed font: " + cf.getEmbedFontName());
                log.warn("Font " + cf.getEmbedFontName() + " is marked as supplied in the"
                        + " PostScript file but could not be embedded!");
                gen.writeDSCComment(DSCConstants.INCLUDE_RESOURCE, fontRes);
                fontResource = PSFontResource.createFontResource(fontRes);
                return fontResource;
            }
View Full Code Here

Examples of org.apache.fop.fonts.CustomFont

            fontResources.put(key, fontRes);
            FontType fontType = tf.getFontType();
            if (fontType == FontType.TYPE1 || fontType == FontType.TRUETYPE
                    || fontType == FontType.TYPE0) {
                if (tf instanceof CustomFont) {
                    CustomFont cf = (CustomFont)tf;
                    if (isEmbeddable(cf)) {
                        if (fontType == FontType.TYPE0) {
                            resTracker.registerSuppliedResource(
                                    new PSResource(PSResource.TYPE_CIDFONT, tf.getEmbedFontName()));
                            resTracker.registerSuppliedResource(
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().toLowerCase().endsWith(".ttc")) {
            // Get a list of the TTC Font names
            List<String> ttcNames = null;
            String fontFileURL = fontURL.toExternalForm().trim();
            InputStream in = null;
            try {
                in = FontLoader.openFontUri(resolver, fontFileURL);
                TTFFile ttf = new TTFFile(false, false);
                FontFileReader reader = new FontFileReader(in);
                ttcNames = ttf.getTTCnames(reader);
            } catch (Exception e) {
                if (this.eventListener != null) {
                    this.eventListener.fontLoadingErrorAtAutoDetection(this, fontFileURL, e);
                }
                return null;
            } finally {
                IOUtils.closeQuietly(in);
            }

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

            // For each font name ...
            for (String fontName : ttcNames) {
                if (log.isDebugEnabled()) {
                    log.debug("Loading " + fontName);
                }
                try {
                    TTFFontLoader ttfLoader = new TTFFontLoader(
                            fontFileURL, fontName, true, EmbeddingMode.AUTO, EncodingMode.AUTO,
                            useKerning, useAdvanced, 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 embedFontInfoList.toArray(
                    new EmbedFontInfo[embedFontInfoList.size()]);
        } else {
            // The normal case
            try {
                customFont = FontLoader.loadFont(fontURL, null, true, EmbeddingMode.AUTO,
                        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, 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

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