Examples of PSResource


Examples of org.apache.xmlgraphics.ps.PSResource

        in = new java.io.BufferedInputStream(in);
        try {
            DSCParser parser = new DSCParser(in);

            //The first form is for arrow_down_small.png (to be reused)
            PSResource form1 = new PSResource(PSResource.TYPE_FORM, "FOPForm:1");
            PSResource helvetica = new PSResource(PSResource.TYPE_FONT, "Helvetica");
            PSResource helveticaBold = new PSResource(PSResource.TYPE_FONT, "Helvetica-Bold");

            PSResource res;
            DSCCommentPages pages = (DSCCommentPages)gotoDSCComment(parser, DSCConstants.PAGES);
            assertEquals(2, pages.getPageCount());

            DSCCommentDocumentSuppliedResources supplied
                = (DSCCommentDocumentSuppliedResources)gotoDSCComment(parser,
                        DSCConstants.DOCUMENT_SUPPLIED_RESOURCES);
            Set resources = supplied.getResources();
            assertEquals(5, resources.size());
            assertTrue(resources.contains(form1));
            assertTrue("Expected barcode.eps as supplied resource",
                    resources.contains(new PSResource(PSResource.TYPE_FILE,
                            "test/resources/images/barcode.eps")));

            DSCCommentDocumentNeededResources needed
                = (DSCCommentDocumentNeededResources)gotoDSCComment(parser,
                        DSCConstants.DOCUMENT_NEEDED_RESOURCES);
            resources = needed.getResources();
            assertEquals(2, resources.size());
            assertTrue("Expected Helvetica as needed resource",
                    resources.contains(new PSResource(PSResource.TYPE_FONT, "Helvetica")));
            assertTrue("Expected Helvetica-Bold as needed resource",
                    resources.contains(new PSResource(PSResource.TYPE_FONT, "Helvetica-Bold")));

            //Some document structure checking
            assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_DEFAULTS));
            assertNotNull(gotoDSCComment(parser, DSCConstants.END_DEFAULTS));
            assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_PROLOG));
            assertNotNull(gotoDSCComment(parser, DSCConstants.END_PROLOG));
            assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_SETUP));

            //Check includes for the two referenced base 14 fonts
            DSCCommentIncludeResource include;
            Collection strings = new java.util.HashSet(
                    Arrays.asList(new String[] {"Helvetica", "Helvetica-Bold"}));
            for (int i = 0; i < 2; i++) {
                include = (DSCCommentIncludeResource)gotoDSCComment(
                        parser, DSCConstants.INCLUDE_RESOURCE);
                res = include.getResource();
                assertEquals(PSResource.TYPE_FONT, res.getType());
                strings.remove(res.getName());
            }
            assertEquals(0, strings.size());

            checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE,
                    new PSResource(PSResource.TYPE_ENCODING, "WinAnsiEncoding"));

            //Here, we encounter form 1 again
            checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, form1);

            assertNotNull(gotoDSCComment(parser, DSCConstants.END_SETUP));
            //Now the actual pages begin

            //---=== Page 1 ===---
            DSCCommentPage page = (DSCCommentPage)gotoDSCComment(parser, DSCConstants.PAGE);
            assertEquals(1, page.getPagePosition());

            assertEquals(DSCAtend.class,
                    gotoDSCComment(parser, DSCConstants.PAGE_RESOURCES).getClass());
            assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_PAGE_SETUP));
            assertNotNull(gotoDSCComment(parser, DSCConstants.END_PAGE_SETUP));

            PSResource form2 = new PSResource(PSResource.TYPE_FORM, "FOPForm:2");
            checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, form2);
            assertNotNull(gotoDSCComment(parser, DSCConstants.PAGE_TRAILER));

            AbstractResourcesDSCComment pageResources;
            pageResources = (AbstractResourcesDSCComment)gotoDSCComment(
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

            throw new IllegalArgumentException("uri must not be empty or null");
        }
        if (this.formResources == null) {
            this.formResources = new java.util.HashMap();
        }
        PSResource form = (PSResource)this.formResources.get(uri);
        if (form == null) {
            form = new PSImageFormResource(this.formResources.size() + 1, uri);
            this.formResources.put(uri, form);
        }
        return form;
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

        } else {
            this.fontResources = new java.util.HashMap();
        }
        if (res == null) {
            res = PSFontResource.createFontResource(
                    new PSResource(PSResource.TYPE_FONT, getPostScriptNameForFontKey(key)));
            this.fontResources.put(key, res);
        }
        return res;
    }
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

            return;
        }
        Iterator iter = formResources.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry entry = (Map.Entry)iter.next();
            PSResource res = (PSResource)entry.getValue();
            long count = resTracker.getUsageCount(res);
            if (count > 1) {
                //Make global form
                this.globalFormResources.put(entry.getKey(), res);
            } else {
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

        /** {@inheritDoc} */
        public void processEvent(DSCEvent event, DSCParser parser)
                    throws IOException, DSCException {
            if (event.isDSCComment() && event instanceof DSCCommentIncludeResource) {
                DSCCommentIncludeResource include = (DSCCommentIncludeResource)event;
                PSResource res = include.getResource();
                if (res.getType().equals(PSResource.TYPE_FORM)) {
                    if (inlineFormResources.containsValue(res)) {
                        PSImageFormResource form = (PSImageFormResource)
                                    inlineFormResources.get(res);
                        //Create an inline form
                        //Wrap in save/restore pair to release memory
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

        gen.commentln("%FOPBeginFontDict");

        Map fontResources = new HashMap();
        for (String key : fonts.keySet()) {
            Typeface tf = getTypeFace(fontInfo, fonts, key);
            PSResource fontRes = new PSResource(PSResource.TYPE_FONT, tf.getEmbedFontName());
            PSFontResource fontResource = embedFont(gen, tf, fontRes, eventProducer);
            fontResources.put(key, fontResource);

            if (tf instanceof SingleByteFont) {
                SingleByteFont sbf = (SingleByteFont)tf;

                if (encodeAllCharacters) {
                    sbf.encodeAllUnencodedCharacters();
                }

                for (int i = 0, c = sbf.getAdditionalEncodingCount(); i < c; i++) {
                    SingleByteEncoding encoding = sbf.getAdditionalEncoding(i);
                    defineEncoding(gen, encoding);
                    String postFix = "_" + (i + 1);
                    PSResource derivedFontRes;
                    if (tf.getFontType() == FontType.TRUETYPE
                            && sbf.getTrueTypePostScriptVersion() != PostScriptVersion.V2) {
                        derivedFontRes = defineDerivedTrueTypeFont(gen, eventProducer,
                                tf.getEmbedFontName(), tf.getEmbedFontName() + postFix, encoding,
                                sbf.getCMap());
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

                     * First CID-keyed font to be embedded; add
                     * %%IncludeResource: comment for ProcSet CIDInit.
                     */
                    gen.includeProcsetCIDInitResource();
                }
                PSResource cidFontResource = embedType2CIDFont(gen,
                        (MultiByteFont) tf, in);
                fontResource = PSFontResource.createFontResource(fontRes,
                        gen.getProcsetCIDInitResource(), gen.getIdentityHCMapResource(),
                        cidFontResource);
            }
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

        createType42DictionaryEntries(gen, font, new CMapSegment[0], ttfFile);
        gen.writeln("CIDFontName currentdict end /CIDFont defineresource pop");
        gen.writeln("end");
        gen.writeln("%%EndResource");
        PSResource cidFontResource = new PSResource(PSResource.TYPE_CIDFONT, psName);
        gen.getResourceTracker().registerSuppliedResource(cidFontResource);
        return cidFontResource;
    }
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

    public static Map determineSuppliedFonts(ResourceTracker resTracker,
            FontInfo fontInfo, Map<String, Typeface> fonts) {
        Map fontResources = new java.util.HashMap();
        for (String key : fonts.keySet()) {
            Typeface tf = getTypeFace(fontInfo, fonts, key);
            PSResource fontRes = new PSResource("font", tf.getEmbedFontName());
            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(
                                    new PSResource(PSResource.TYPE_CMAP, "Identity-H"));
                        }
                        resTracker.registerSuppliedResource(fontRes);
                    }
                    if (tf instanceof SingleByteFont) {
                        SingleByteFont sbf = (SingleByteFont)tf;
                        for (int i = 0, c = sbf.getAdditionalEncodingCount(); i < c; i++) {
                            SingleByteEncoding encoding = sbf.getAdditionalEncoding(i);
                            PSResource encodingRes = new PSResource(
                                    PSResource.TYPE_ENCODING, encoding.getName());
                            resTracker.registerSuppliedResource(encodingRes);
                            PSResource derivedFontRes = new PSResource(
                                    PSResource.TYPE_FONT, tf.getEmbedFontName() + "_" + (i + 1));
                            resTracker.registerSuppliedResource(derivedFontRes);
                        }
                    }
                }
View Full Code Here

Examples of org.apache.xmlgraphics.ps.PSResource

     * @return the PSResource instance that represents the encoding
     * @throws IOException In case of an I/O problem
     */
    public static PSResource defineEncoding(PSGenerator gen, SingleByteEncoding encoding)
            throws IOException {
        PSResource res = new PSResource(PSResource.TYPE_ENCODING, encoding.getName());
        gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE, res);
        gen.writeln("/" + encoding.getName() + " [");
        String[] charNames = encoding.getCharNameMap();
        for (int i = 0; i < 256; i++) {
            if (i > 0) {
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.