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 {
            // Get file first
            if (font.getEmbedFileName() != null) {
                try {
                    in = getDocument().resolveURI(font.getEmbedFileName());
                } catch (Exception e) {
                    log.error("Failed to embed fontfile: "
                                       + font.getEmbedFileName()
                                       + "(" + e.getMessage() + ")");
                }
            }

            // Get resource
            if (in == null && font.getEmbedResourceName() != null) {
                try {
                    in = new java.io.BufferedInputStream(
                            this.getClass().getResourceAsStream(
                                font.getEmbedResourceName()));
                } catch (Exception e) {
                    log.error(
                                         "Failed to embed fontresource: "
                                       + font.getEmbedResourceName()
                                       + "(" + e.getMessage() + ")");
                }
            }

            if (in == null) {
View Full Code Here

Examples of org.docx4j.fonts.fop.fonts.CustomFont

   
    // Save to "Temporary Font Files" directory.
        FontResolver fontResolver = FontSetup.createMinimalFontResolver();

    if (log.isDebugEnabled()) {
          CustomFont customFont = null;
          try {
            log.debug("Loading from: " + path);
            String subFontName = null; // TODO set this if its a TTC
            boolean embedded = true;  
            boolean useKerning = true;
              customFont = FontLoader.loadFont("file:" + path,
                  subFontName, embedded, EncodingMode.AUTO, useKerning, fontResolver);
          } catch (Exception e) {
        e.printStackTrace();
          }
          if (customFont!=null) {
            log.info("Successfully reloaded " + customFont.getFontName());
            if (customFont.isEmbeddable()) {
              log.debug("confirmed embeddable");
            } else {
              // Sanity check
              log.error("this embedded font claims it is not embeddable!");           
            }
View Full Code Here

Examples of org.docx4j.fonts.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 embedFontInfoList = new java.util.ArrayList(); //List<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
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.