Package org.apache.fop.fonts

Examples of org.apache.fop.fonts.FontManager$MinimalFontResolver


    }

    /** {@inheritDoc} */
    public void setupFontInfo(FontInfo inFontInfo) throws FOPException {
        this.fontInfo = inFontInfo;
        FontManager fontManager = userAgent.getFactory().getFontManager();
        FontCollection[] fontCollections = new FontCollection[] {
                new Base14FontCollection(fontManager.isBase14KerningEnabled()),
                new CustomFontCollection(getFontResolver(), getFontList(),
                                         userAgent.isComplexScriptFeaturesEnabled())
        };
        fontManager.setup(getFontInfo(), fontCollections);
    }
View Full Code Here


        throws FOPException {
        FontInfo fontInfo = new FontInfo();
        final boolean strict = false;
        FontResolver fontResolver = FontManager.createMinimalFontResolver(useComplexScriptFeatures);
        //TODO The following could be optimized by retaining the FontManager somewhere
        FontManager fontManager = new FontManager();
        if (cfg != null) {
            FontManagerConfigurator fmConfigurator = new FontManagerConfigurator(cfg);
            fmConfigurator.configure(fontManager, strict);
        }

        List fontCollections = new java.util.ArrayList();
        fontCollections.add(new Base14FontCollection(fontManager.isBase14KerningEnabled()));

        if (cfg != null) {
            //TODO Wire in the FontEventListener
            FontEventListener listener = null; //new FontEventAdapter(eventBroadcaster);
            FontInfoConfigurator fontInfoConfigurator
                = new FontInfoConfigurator(cfg, fontManager, fontResolver, listener, strict);
            List/*<EmbedFontInfo>*/ fontInfoList = new java.util.ArrayList/*<EmbedFontInfo>*/();
            fontInfoConfigurator.configure(fontInfoList);
            fontCollections.add(new CustomFontCollection(fontResolver, fontInfoList,
                                fontResolver.isComplexScriptFeaturesEnabled()));
        }
        fontManager.setup(fontInfo,
                (FontCollection[])fontCollections.toArray(
                        new FontCollection[fontCollections.size()]));
        return fontInfo;
    }
View Full Code Here

        eventProducer = AFPEventProducer.Provider.get(userAgent.getEventBroadcaster());
    }

    private AFPFontInfo buildFont(Configuration fontCfg, String fontPath)
    throws ConfigurationException {
        FontManager fontManager = this.userAgent.getFactory().getFontManager();

        Configuration[] triple = fontCfg.getChildren("font-triplet");
        List<FontTriplet> tripletList = new ArrayList<FontTriplet>();
        if (triple.length == 0) {
            eventProducer.fontConfigMissing(this, "<font-triplet...", fontCfg.getLocation());
            return null;
        }
        for (Configuration config : triple) {
            int weight = FontUtil.parseCSS2FontWeight(config.getAttribute("weight"));
            FontTriplet triplet = new FontTriplet(config.getAttribute("name"),
                    config.getAttribute("style"),
                    weight);
            tripletList.add(triplet);
        }

        //build the fonts
        Configuration[] config = fontCfg.getChildren("afp-font");
        if (config.length == 0) {
            eventProducer.fontConfigMissing(this, "<afp-font...", fontCfg.getLocation());
            return null;
        }
        Configuration afpFontCfg = config[0];

        URI baseURI = null;
        String uri = afpFontCfg.getAttribute("base-uri", fontPath);
        if (uri == null) {
            //Fallback for old attribute which only supports local filenames
            String path = afpFontCfg.getAttribute("path", fontPath);
            if (path != null) {
                File f = new File(path);
                baseURI = f.toURI();
            }
        } else {
            try {
                baseURI = new URI(uri);
            } catch (URISyntaxException e) {
                eventProducer.invalidConfiguration(this, e);
                return null;
            }
        }
        ResourceAccessor accessor = new DefaultFOPResourceAccessor(
                this.userAgent,
                fontManager.getFontBaseURL(),
                baseURI);

        AFPFont font = null;
        try {
            String type = afpFontCfg.getAttribute("type");
View Full Code Here

     */
    private List<AFPFontInfo> buildFontListFromConfiguration(Configuration cfg,
            AFPEventProducer eventProducer) throws FOPException, ConfigurationException {

        Configuration fonts = cfg.getChild("fonts");
        FontManager fontManager = this.userAgent.getFactory().getFontManager();

        // General matcher
        FontTriplet.Matcher referencedFontsMatcher = fontManager.getReferencedFontsMatcher();
        // Renderer-specific matcher
        FontTriplet.Matcher localMatcher = null;

        // Renderer-specific referenced fonts
        Configuration referencedFontsCfg = fonts.getChild("referenced-fonts", false);
View Full Code Here

    /** {@inheritDoc} */
    @Override
    public void setupFontInfo(IFDocumentHandler documentHandler, FontInfo fontInfo)
            throws FOPException {
        FontManager fontManager = userAgent.getFactory().getFontManager();
        List<AFPFontCollection> fontCollections = new ArrayList<AFPFontCollection>();

        Configuration cfg = super.getRendererConfig(documentHandler.getMimeType());
        if (cfg != null) {
            try {
                List<AFPFontInfo> fontList = buildFontListFromConfiguration(cfg, eventProducer);
                fontCollections.add(new AFPFontCollection(
                        userAgent.getEventBroadcaster(), fontList));
            } catch (ConfigurationException e) {
                eventProducer.invalidConfiguration(this, e);
                LogUtil.handleException(log, e,
                        userAgent.getFactory().validateUserConfigStrictly());
            }
        } else {
            fontCollections.add(new AFPFontCollection(userAgent.getEventBroadcaster(), null));
        }

        fontManager.setup(fontInfo,
                fontCollections.toArray(
                        new FontCollection[fontCollections.size()]));
        documentHandler.setFontInfo(fontInfo);
    }
View Full Code Here

    }

    /** {@inheritDoc} */
    @Override
    public void setDefaultFontInfo(FontInfo fontInfo) {
        FontManager fontManager = getUserAgent().getFactory().getFontManager();
        FontCollection[] fontCollections = new FontCollection[] {
            new AFPFontCollection(getUserAgent().getEventBroadcaster(), null)
        };

        FontInfo fi = (fontInfo != null ? fontInfo : new FontInfo());
        fi.setEventListener(new FontEventAdapter(getUserAgent().getEventBroadcaster()));
        fontManager.setup(fi, fontCollections);
        setFontInfo(fi);
    }
View Full Code Here

    public static FontInfo createFontInfo(Configuration cfg) throws FOPException {
        FontInfo fontInfo = new FontInfo();
        if (cfg != null) {
            FontResolver fontResolver = FontManager.createMinimalFontResolver();
            //TODO The following could be optimized by retaining the FontManager somewhere
            FontManager fontManager = new FontManager();

            //TODO Make use of fontBaseURL, font substitution and referencing configuration
            //Requires a change to the expected configuration layout

            //TODO Wire in the FontEventListener
            final FontEventListener listener = null;
            final boolean strict = false;
            FontInfoConfigurator fontInfoConfigurator
                = new FontInfoConfigurator(cfg, fontManager, fontResolver, listener, strict);
            List/*<EmbedFontInfo>*/ fontInfoList = new java.util.ArrayList/*<EmbedFontInfo>*/();
            fontInfoConfigurator.configure(fontInfoList);

            if (fontManager.useCache()) {
                fontManager.getFontCache().save();
            }
            FontSetup.setup(fontInfo, fontInfoList, fontResolver);
        } else {
            FontSetup.setup(fontInfo);
        }
View Full Code Here

    }

    /** {@inheritDoc} */
    public void setupFontInfo(IFDocumentHandler documentHandler, FontInfo fontInfo)
                throws FOPException {
        FontManager fontManager = userAgent.getFactory().getFontManager();

        Graphics2D graphics2D = Java2DFontMetrics.createFontMetricsGraphics2D();

        List fontCollections = new java.util.ArrayList();
        fontCollections.add(new Base14FontCollection(graphics2D));
        fontCollections.add(new InstalledFontCollection(graphics2D));

        Configuration cfg = super.getRendererConfig(documentHandler.getMimeType());
        if (cfg != null) {
            FontResolver fontResolver = new DefaultFontResolver(userAgent);
            FontEventListener listener = new FontEventAdapter(
                    userAgent.getEventBroadcaster());
            List fontList = buildFontList(cfg, fontResolver, listener);
            fontCollections.add(new ConfiguredFontCollection(fontResolver, fontList));
        }

        fontManager.setup(fontInfo,
                (FontCollection[])fontCollections.toArray(
                        new FontCollection[fontCollections.size()]));
        documentHandler.setFontInfo(fontInfo);
    }
View Full Code Here

        this.fontInfo = fontInfo;
    }

    /** {@inheritDoc} */
    public void setDefaultFontInfo(FontInfo fontInfo) {
        FontManager fontManager = getUserAgent().getFactory().getFontManager();
        FontCollection[] fontCollections = new FontCollection[] {
                new Base14FontCollection(fontManager.isBase14KerningEnabled())
        };

        FontInfo fi = (fontInfo != null ? fontInfo : new FontInfo());
        fi.setEventListener(new FontEventAdapter(getUserAgent().getEventBroadcaster()));
        fontManager.setup(fi, fontCollections);
        setFontInfo(fi);
    }
View Full Code Here

        return new AFPRendererConfigurator(getUserAgent());
    }

    /** {@inheritDoc} */
    public void setDefaultFontInfo(FontInfo fontInfo) {
        FontManager fontManager = getUserAgent().getFactory().getFontManager();
        FontCollection[] fontCollections = new FontCollection[] {
            new AFPFontCollection(getUserAgent().getEventBroadcaster(), null)
        };

        FontInfo fi = (fontInfo != null ? fontInfo : new FontInfo());
        fi.setEventListener(new FontEventAdapter(getUserAgent().getEventBroadcaster()));
        fontManager.setup(fi, fontCollections);
        setFontInfo(fi);
    }
View Full Code Here

TOP

Related Classes of org.apache.fop.fonts.FontManager$MinimalFontResolver

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.