You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ga...@apache.org on 2012/07/05 22:29:58 UTC

svn commit: r1357883 [5/5] - in /xmlgraphics/fop/branches/fop-1_1: ./ examples/fo/ examples/fo/advanced/ examples/fo/basic/ examples/fo/svg/ examples/fo/tables/ lib/ src/documentation/content/xdocs/ src/documentation/content/xdocs/fo/ src/documentation...

Modified: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSDocumentHandler.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSDocumentHandler.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSDocumentHandler.java Thu Jul  5 20:29:53 2012
@@ -26,6 +26,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
@@ -49,6 +50,7 @@ import org.apache.xmlgraphics.ps.dsc.Res
 import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBoundingBox;
 import org.apache.xmlgraphics.ps.dsc.events.DSCCommentHiResBoundingBox;
 
+import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.render.intermediate.AbstractBinaryWritingIFDocumentHandler;
 import org.apache.fop.render.intermediate.IFContext;
@@ -57,11 +59,13 @@ import org.apache.fop.render.intermediat
 import org.apache.fop.render.intermediate.IFPainter;
 import org.apache.fop.render.ps.extensions.PSCommentAfter;
 import org.apache.fop.render.ps.extensions.PSCommentBefore;
+import org.apache.fop.render.ps.extensions.PSPageTrailerCodeBefore;
 import org.apache.fop.render.ps.extensions.PSSetPageDevice;
 import org.apache.fop.render.ps.extensions.PSSetupCode;
 
 /**
- * {@link IFDocumentHandler} implementation that produces PostScript.
+ * {@link org.apache.fop.render.intermediate.IFDocumentHandler} implementation
+ * that produces PostScript.
  */
 public class PSDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
 
@@ -98,10 +102,13 @@ public class PSDocumentHandler extends A
     private PSPageDeviceDictionary pageDeviceDictionary;
 
     /** This is a collection holding all document header comments */
-    private Collection[] comments = new Collection[3];
+    private Collection[] comments = new Collection[4];
     private static final int COMMENT_DOCUMENT_HEADER = 0;
     private static final int COMMENT_DOCUMENT_TRAILER = 1;
     private static final int COMMENT_PAGE_TRAILER = 2;
+    private static final int PAGE_TRAILER_CODE_BEFORE = 3;
+
+    private PSEventProducer eventProducer;
 
     /**
      * Default constructor.
@@ -122,7 +129,9 @@ public class PSDocumentHandler extends A
     /** {@inheritDoc} */
     public void setContext(IFContext context) {
         super.setContext(context);
-        this.psUtil = new PSRenderingUtil(context.getUserAgent());
+        FOUserAgent userAgent = context.getUserAgent();
+        this.psUtil = new PSRenderingUtil(userAgent);
+        eventProducer = PSEventProducer.Provider.get(userAgent.getEventBroadcaster());
     }
 
     /** {@inheritDoc} */
@@ -141,7 +150,7 @@ public class PSDocumentHandler extends A
         try {
             OutputStream out;
             if (psUtil.isOptimizeResources()) {
-                this.tempFile = File.createTempFile("fop", null);
+                this.tempFile = File.createTempFile("fop", ".ps");
                 out = new java.io.FileOutputStream(this.tempFile);
                 out = new java.io.BufferedOutputStream(out);
             } else {
@@ -199,7 +208,7 @@ public class PSDocumentHandler extends A
         gen.writeDSCComment(DSCConstants.BEGIN_SETUP);
         PSRenderingUtil.writeSetupCodeList(gen, setupCodeList, "SetupCode");
         if (!psUtil.isOptimizeResources()) {
-            this.fontResources.addAll(PSFontUtils.writeFontDict(gen, fontInfo));
+            this.fontResources.addAll(PSFontUtils.writeFontDict(gen, fontInfo, eventProducer));
         } else {
             gen.commentln("%FOPFontSetup"); //Place-holder, will be replaced in the second pass
         }
@@ -254,8 +263,8 @@ public class PSDocumentHandler extends A
         in = new java.io.BufferedInputStream(in);
         try {
             try {
-                ResourceHandler handler = new ResourceHandler(getUserAgent(), this.fontInfo,
-                        resTracker, this.formResources);
+                ResourceHandler handler = new ResourceHandler(getUserAgent(), eventProducer,
+                        this.fontInfo, resTracker, this.formResources);
                 handler.process(in, this.outputStream,
                         this.currentPageNumber, this.documentBoundingBox);
                 this.outputStream.flush();
@@ -443,8 +452,9 @@ public class PSDocumentHandler extends A
 
     /** {@inheritDoc} */
     public void startPageTrailer() throws IFException {
-        super.startPageTrailer();
         try {
+            writeExtensions(PAGE_TRAILER_CODE_BEFORE);
+            super.startPageTrailer();
             gen.writeDSCComment(DSCConstants.PAGE_TRAILER);
         } catch (IOException ioe) {
             throw new IFException("I/O error in startPageTrailer()", ioe);
@@ -526,6 +536,11 @@ public class PSDocumentHandler extends A
                     comments[targetCollection] = new java.util.ArrayList();
                 }
                 comments[targetCollection].add(extension);
+            } else if (extension instanceof PSPageTrailerCodeBefore) {
+                if (comments[PAGE_TRAILER_CODE_BEFORE] == null) {
+                    comments[PAGE_TRAILER_CODE_BEFORE] = new ArrayList();
+                }
+                comments[PAGE_TRAILER_CODE_BEFORE].add(extension);
             }
         } catch (IOException ioe) {
             throw new IFException("I/O error in handleExtensionObject()", ioe);
@@ -537,8 +552,8 @@ public class PSDocumentHandler extends A
      * @param key the font key ("F*")
      * @return the matching PSResource
      */
-    protected PSResource getPSResourceForFontKey(String key) {
-        return this.fontResources.getPSResourceForFontKey(key);
+    protected PSFontResource getPSResourceForFontKey(String key) {
+        return this.fontResources.getFontResourceForFontKey(key);
     }
 
     /**

Modified: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSEventProducer.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSEventProducer.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSEventProducer.java Thu Jul  5 20:29:53 2012
@@ -53,4 +53,11 @@ public interface PSEventProducer extends
      */
     void postscriptDictionaryParseError(Object source, String content, Exception e);
 
+    /**
+     * PostScript Level 3 features are necessary.
+     *
+     * @param source the event source
+     * @event.severity FATAL
+     */
+    void postscriptLevel3Needed(Object source);
 }

Modified: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSEventProducer.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSEventProducer.xml?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSEventProducer.xml (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSEventProducer.xml Thu Jul  5 20:29:53 2012
@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <catalogue xml:lang="en">
   <message key="postscriptDictionaryParseError">Failed to parse dictionary string. Reason: {e}, content = "{content}"</message>
+  <message key="postscriptLevel3Needed">PostScript Level 3 features are needed to handle this document.</message>
 </catalogue>

Modified: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSFontUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSFontUtils.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSFontUtils.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSFontUtils.java Thu Jul  5 20:29:53 2012
@@ -23,7 +23,11 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Locale;
 import java.util.Map;
+import java.util.Set;
 
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
@@ -38,14 +42,26 @@ import org.apache.xmlgraphics.ps.PSResou
 import org.apache.xmlgraphics.ps.dsc.ResourceTracker;
 
 import org.apache.fop.fonts.Base14Font;
+import org.apache.fop.fonts.CIDFontType;
+import org.apache.fop.fonts.CIDSubset;
+import org.apache.fop.fonts.CMapSegment;
 import org.apache.fop.fonts.CustomFont;
+import org.apache.fop.fonts.EmbeddingMode;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontType;
 import org.apache.fop.fonts.LazyFont;
+import org.apache.fop.fonts.MultiByteFont;
 import org.apache.fop.fonts.SingleByteEncoding;
 import org.apache.fop.fonts.SingleByteFont;
 import org.apache.fop.fonts.Typeface;
+import org.apache.fop.fonts.truetype.FontFileReader;
+import org.apache.fop.fonts.truetype.TTFFile;
+import org.apache.fop.fonts.truetype.TTFFile.PostScriptVersion;
+import org.apache.fop.fonts.truetype.TTFOutputStream;
+import org.apache.fop.fonts.truetype.TTFSubSetFile;
+import org.apache.fop.render.ps.fonts.PSTTFOutputStream;
+import org.apache.fop.util.HexEncoder;
 
 /**
  * Utility code for font handling in PostScript.
@@ -54,7 +70,6 @@ public class PSFontUtils extends org.apa
 
     /** logging instance */
     protected static final Log log = LogFactory.getLog(PSFontUtils.class);
-
     /**
      * Generates the PostScript code for the font dictionary. This method should only be
      * used if no "resource optimization" is performed, i.e. when the fonts are not embedded
@@ -66,7 +81,22 @@ public class PSFontUtils extends org.apa
      */
     public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo)
                 throws IOException {
-        return writeFontDict(gen, fontInfo, fontInfo.getFonts(), true);
+        return writeFontDict(gen, fontInfo, null);
+    }
+
+    /**
+     * Generates the PostScript code for the font dictionary. This method should only be
+     * used if no "resource optimization" is performed, i.e. when the fonts are not embedded
+     * in a second pass.
+     * @param gen PostScript generator to use for output
+     * @param fontInfo available fonts
+     * @param eventProducer to report events
+     * @return a Map of PSResource instances representing all defined fonts (key: font key)
+     * @throws IOException in case of an I/O problem
+     */
+    public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo,
+            PSEventProducer eventProducer) throws IOException {
+        return writeFontDict(gen, fontInfo, fontInfo.getFonts(), true, eventProducer);
     }
 
     /**
@@ -76,13 +106,13 @@ public class PSFontUtils extends org.apa
      * @param gen PostScript generator to use for output
      * @param fontInfo available fonts
      * @param fonts the set of fonts to work with
+     * @param eventProducer the event producer
      * @return a Map of PSResource instances representing all defined fonts (key: font key)
      * @throws IOException in case of an I/O problem
      */
-    public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo,
-            Map<String, Typeface> fonts)
-                throws IOException {
-        return writeFontDict(gen, fontInfo, fonts, false);
+    public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo, Map<String, Typeface> fonts,
+            PSEventProducer eventProducer) throws IOException {
+        return writeFontDict(gen, fontInfo, fonts, false, eventProducer);
     }
 
     /**
@@ -96,15 +126,16 @@ public class PSFontUtils extends org.apa
      * @throws IOException in case of an I/O problem
      */
     private static Map writeFontDict(PSGenerator gen, FontInfo fontInfo,
-            Map<String, Typeface> fonts, boolean encodeAllCharacters) throws IOException {
+            Map<String, Typeface> fonts, boolean encodeAllCharacters, PSEventProducer eventProducer)
+            throws IOException {
         gen.commentln("%FOPBeginFontDict");
 
-        Map fontResources = new java.util.HashMap();
+        Map fontResources = new HashMap();
         for (String key : fonts.keySet()) {
             Typeface tf = getTypeFace(fontInfo, fonts, key);
-            PSResource fontRes = new PSResource(PSResource.TYPE_FONT, tf.getFontName());
-            fontResources.put(key, fontRes);
-            embedFont(gen, tf, fontRes);
+            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;
@@ -117,9 +148,18 @@ public class PSFontUtils extends org.apa
                     SingleByteEncoding encoding = sbf.getAdditionalEncoding(i);
                     defineEncoding(gen, encoding);
                     String postFix = "_" + (i + 1);
-                    PSResource derivedFontRes = defineDerivedFont(gen, tf.getFontName(),
-                            tf.getFontName() + postFix, encoding.getName());
-                    fontResources.put(key + postFix, derivedFontRes);
+                    PSResource derivedFontRes;
+                    if (tf.getFontType() == FontType.TRUETYPE
+                            && sbf.getTrueTypePostScriptVersion() != PostScriptVersion.V2) {
+                        derivedFontRes = defineDerivedTrueTypeFont(gen, eventProducer,
+                                tf.getEmbedFontName(), tf.getEmbedFontName() + postFix, encoding,
+                                sbf.getCMap());
+                    } else {
+                        derivedFontRes = defineDerivedFont(gen, tf.getEmbedFontName(),
+                                tf.getEmbedFontName() + postFix, encoding.getName());
+                    }
+                    fontResources.put(key + postFix,
+                            PSFontResource.createFontResource(derivedFontRes));
                 }
             }
         }
@@ -156,12 +196,12 @@ public class PSFontUtils extends org.apa
             } else {
                 if (tf instanceof Base14Font) {
                     //Our Base 14 fonts don't use the default encoding
-                    redefineFontEncoding(gen, tf.getFontName(), tf.getEncodingName());
+                    redefineFontEncoding(gen, tf.getEmbedFontName(), tf.getEncodingName());
                 } else if (tf instanceof SingleByteFont) {
                     SingleByteFont sbf = (SingleByteFont)tf;
                     if (!sbf.isUsingNativeEncoding()) {
                         //Font has been configured to use an encoding other than the default one
-                        redefineFontEncoding(gen, tf.getFontName(), tf.getEncodingName());
+                        redefineFontEncoding(gen, tf.getEmbedFontName(), tf.getEncodingName());
                     }
                 }
             }
@@ -184,39 +224,299 @@ public class PSFontUtils extends org.apa
         return tf;
     }
 
-    /**
-     * Embeds a font in the PostScript file.
-     * @param gen the PostScript generator
-     * @param tf the font
-     * @param fontRes the PSResource associated with the font
-     * @throws IOException In case of an I/O error
-     */
-    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!");
+    private static PSFontResource embedFont(PSGenerator gen, Typeface tf, PSResource fontRes,
+            PSEventProducer eventProducer) throws IOException {
+        FontType fontType = tf.getFontType();
+        PSFontResource fontResource = null;
+        if (!(fontType == FontType.TYPE1 || fontType == FontType.TRUETYPE
+                || 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;
+            }
+            if (fontType == FontType.TYPE0) {
+                if (gen.embedIdentityH()) {
+                    checkPostScriptLevel3(gen, eventProducer);
+                    /*
+                     * 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);
+            }
+            gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE, fontRes);
+            if (fontType == FontType.TYPE1) {
+                embedType1Font(gen, in);
+                fontResource = PSFontResource.createFontResource(fontRes);
+            } else if (fontType == FontType.TRUETYPE) {
+                embedTrueTypeFont(gen, (SingleByteFont) tf, in);
+                fontResource = PSFontResource.createFontResource(fontRes);
+            } else {
+                composeType0Font(gen, (MultiByteFont) tf, in);
+            }
+            gen.writeDSCComment(DSCConstants.END_RESOURCE);
+            gen.getResourceTracker().registerSuppliedResource(fontRes);
+        }
+        return fontResource;
+    }
+
+    private static void checkPostScriptLevel3(PSGenerator gen, PSEventProducer eventProducer) {
+        if (gen.getPSLevel() < 3) {
+            if (eventProducer != null) {
+                eventProducer.postscriptLevel3Needed(gen);
+            } else {
+                throw new IllegalStateException("PostScript Level 3 is"
+                        + " required to use TrueType fonts,"
+                        + " configured level is "
+                        + gen.getPSLevel());
+            }
+        }
+    }
+
+    private static void embedTrueTypeFont(PSGenerator gen,
+            SingleByteFont font, InputStream fontStream) throws IOException {
+        /* See Adobe Technical Note #5012, "The Type 42 Font Format Specification" */
+        gen.commentln("%!PS-TrueTypeFont-65536-65536-1"); // TODO TrueType & font versions
+        gen.writeln("11 dict begin");
+        if (font.getEmbeddingMode() == EmbeddingMode.AUTO) {
+            font.setEmbeddingMode(EmbeddingMode.SUBSET);
+        }
+        FontFileReader reader = new FontFileReader(fontStream);
+        TTFFile ttfFile = new TTFFile();
+        ttfFile.readFont(reader, font.getFullName());
+        createType42DictionaryEntries(gen, font, font.getCMap(), ttfFile);
+        gen.writeln("FontName currentdict end definefont pop");
+    }
+
+    private static void createType42DictionaryEntries(PSGenerator gen, CustomFont font,
+            CMapSegment[] cmap, TTFFile ttfFile) throws IOException {
+        gen.write("/FontName /");
+        gen.write(font.getEmbedFontName());
+        gen.writeln(" def");
+        gen.writeln("/PaintType 0 def");
+        gen.writeln("/FontMatrix [1 0 0 1 0 0] def");
+        writeFontBBox(gen, font);
+        gen.writeln("/FontType 42 def");
+        gen.writeln("/Encoding 256 array");
+        gen.writeln("0 1 255{1 index exch/.notdef put}for");
+        boolean buildCharStrings;
+        Set<String> glyphNames = new HashSet<String>();
+        if (font.getFontType() == FontType.TYPE0 && font.getEmbeddingMode() != EmbeddingMode.FULL) {
+            //"/Encoding" is required but ignored for CID fonts
+            //so we keep it minimal to save space
+            buildCharStrings = false;
+        } else {
+            buildCharStrings = true;
+            for (int i = 0; i < Glyphs.WINANSI_ENCODING.length; i++) {
+                gen.write("dup ");
+                gen.write(i);
+                gen.write(" /");
+                String glyphName = Glyphs.charToGlyphName(Glyphs.WINANSI_ENCODING[i]);
+                if (glyphName.equals("")) {
+                    gen.write(Glyphs.NOTDEF);
+                } else {
+                    gen.write(glyphName);
+                    glyphNames.add(glyphName);
+                }
+                gen.writeln(" put");
+            }
+        }
+        gen.writeln("readonly def");
+        TTFOutputStream ttfOut = new PSTTFOutputStream(gen);
+        ttfFile.stream(ttfOut);
+
+        buildCharStrings(gen, buildCharStrings, cmap, glyphNames, font);
+    }
+
+    private static void buildCharStrings(PSGenerator gen, boolean buildCharStrings,
+            CMapSegment[] cmap, Set<String> glyphNames, CustomFont font) throws IOException {
+        gen.write("/CharStrings ");
+        if (!buildCharStrings) {
+            gen.write(1);
+        } else if (font.getEmbeddingMode() != EmbeddingMode.FULL) {
+            int charCount = 1; //1 for .notdef
+            for (CMapSegment segment : cmap) {
+                charCount += segment.getUnicodeEnd() - segment.getUnicodeStart() + 1;
+            }
+            gen.write(charCount);
+        } else {
+            gen.write(font.getCMap().length);
+        }
+        gen.writeln(" dict dup begin");
+        gen.write("/");
+        gen.write(Glyphs.NOTDEF);
+        gen.writeln(" 0 def"); // .notdef always has to be at index 0
+        if (!buildCharStrings) {
+            // If we're not building the full CharStrings we can end here
+            gen.writeln("end readonly def");
+            return;
+        }
+        if (font.getEmbeddingMode() != EmbeddingMode.FULL) {
+          //Only performed in singly-byte mode, ignored for CID fonts
+            for (CMapSegment segment : cmap) {
+                int glyphIndex = segment.getGlyphStartIndex();
+                for (int ch = segment.getUnicodeStart(); ch <= segment.getUnicodeEnd(); ch++) {
+                    char ch16 = (char)ch; //TODO Handle Unicode characters beyond 16bit
+                    String glyphName = Glyphs.charToGlyphName(ch16);
+                    if ("".equals(glyphName)) {
+                        glyphName = "u" + Integer.toHexString(ch).toUpperCase(Locale.ENGLISH);
                     }
+                    writeGlyphDefs(gen, glyphName, glyphIndex);
+
+                    glyphIndex++;
                 }
             }
+        } else {
+            for (String name : glyphNames) {
+                writeGlyphDefs(gen, name,
+                        getGlyphIndex(Glyphs.getUnicodeSequenceForGlyphName(name).charAt(0),
+                                font.getCMap()));
+            }
         }
-        if (!embeddedFont) {
-            gen.writeDSCComment(DSCConstants.INCLUDE_RESOURCE, fontRes);
+        gen.writeln("end readonly def");
+    }
+
+    private static void writeGlyphDefs(PSGenerator gen, String glyphName, int glyphIndex)
+                throws IOException {
+        gen.write("/");
+        gen.write(glyphName);
+        gen.write(" ");
+        gen.write(glyphIndex);
+        gen.writeln(" def");
+    }
+
+    private static int getGlyphIndex(char c, CMapSegment[] cmap) {
+        for (CMapSegment segment : cmap) {
+            if (segment.getUnicodeStart() <= c && c <= segment.getUnicodeEnd()) {
+                return segment.getGlyphStartIndex() + c - segment.getUnicodeStart();
+            }
         }
+        return 0;
+    }
+
+    private static void composeType0Font(PSGenerator gen, MultiByteFont font,
+            InputStream fontStream) throws IOException {
+        String psName = font.getEmbedFontName();
+        gen.write("/");
+        gen.write(psName);
+        gen.write(" /Identity-H [/");
+        gen.write(psName);
+        gen.writeln("] composefont pop");
+    }
+
+    private static PSResource embedType2CIDFont(PSGenerator gen,
+            MultiByteFont font, InputStream fontStream) throws IOException {
+        assert font.getCIDType() == CIDFontType.CIDTYPE2;
+
+        String psName = font.getEmbedFontName();
+        gen.write("%%BeginResource: CIDFont ");
+        gen.writeln(psName);
+
+        gen.write("%%Title: (");
+        gen.write(psName);
+        gen.writeln(" Adobe Identity 0)");
+
+        gen.writeln("%%Version: 1"); // TODO use font revision?
+        gen.writeln("/CIDInit /ProcSet findresource begin");
+        gen.writeln("20 dict begin");
+
+        gen.write("/CIDFontName /");
+        gen.write(psName);
+        gen.writeln(" def");
+
+        gen.writeln("/CIDFontVersion 1 def"); // TODO same as %%Version above
+
+        gen.write("/CIDFontType ");
+        gen.write(font.getCIDType().getValue());
+        gen.writeln(" def");
+
+        gen.writeln("/CIDSystemInfo 3 dict dup begin");
+        gen.writeln("  /Registry (Adobe) def");
+        gen.writeln("  /Ordering (Identity) def");
+        gen.writeln("  /Supplement 0 def");
+        gen.writeln("end def");
+
+        // TODO UIDBase (and UIDOffset in CMap) necessary if PostScript Level 1 & 2
+        // interpreters are to be supported
+        // (Level 1: with composite font extensions; Level 2: those that do not offer
+        // native mode support for CID-keyed fonts)
+
+        // TODO XUID (optional but strongly recommended)
+
+        // TODO /FontInfo
+
+        gen.write("/CIDCount ");
+        CIDSubset cidSubset = font.getCIDSubset();
+        int subsetSize = cidSubset.getSubsetSize();
+        gen.write(subsetSize);
+        gen.writeln(" def");
+        gen.writeln("/GDBytes 2 def"); // TODO always 2?
+        gen.writeln("/CIDMap [<");
+        int colCount = 0;
+        int lineCount = 1;
+        for (int cid = 0; cid < subsetSize; cid++) {
+            if (colCount++ == 20) {
+                gen.newLine();
+                colCount = 1;
+                if (lineCount++ == 800) {
+                    gen.writeln("> <");
+                    lineCount = 1;
+                }
+            }
+            String gid;
+            if (font.getEmbeddingMode() != EmbeddingMode.FULL) {
+                gid = HexEncoder.encode(cid, 4);
+            } else {
+                gid = HexEncoder.encode(cidSubset.getGlyphIndexForSubsetIndex(cid), 4);
+            }
+            gen.write(gid);
+        }
+        gen.writeln(">] def");
+        FontFileReader reader = new FontFileReader(fontStream);
+
+        TTFFile ttfFile;
+        if (font.getEmbeddingMode() != EmbeddingMode.FULL) {
+            ttfFile = new TTFSubSetFile();
+            ttfFile.readFont(reader, font.getTTCName(), font.getUsedGlyphs());
+        } else {
+            ttfFile = new TTFFile();
+            ttfFile.readFont(reader, font.getTTCName());
+        }
+
+
+        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;
+    }
+
+    private static void writeFontBBox(PSGenerator gen, CustomFont font) throws IOException {
+        int[] bbox = font.getFontBBox();
+        gen.write("/FontBBox[");
+        for (int i = 0; i < 4; i++) {
+            gen.write(" ");
+            gen.write(bbox[i]);
+        }
+        gen.writeln(" ] def");
     }
 
     private static boolean isEmbeddable(CustomFont font) {
@@ -273,12 +573,20 @@ public class PSFontUtils extends org.apa
         Map fontResources = new java.util.HashMap();
         for (String key : fonts.keySet()) {
             Typeface tf = getTypeFace(fontInfo, fonts, key);
-            PSResource fontRes = new PSResource("font", tf.getFontName());
+            PSResource fontRes = new PSResource("font", tf.getEmbedFontName());
             fontResources.put(key, fontRes);
-            if (FontType.TYPE1 == tf.getFontType()) {
+            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) {
@@ -289,7 +597,7 @@ public class PSFontUtils extends org.apa
                                     PSResource.TYPE_ENCODING, encoding.getName());
                             resTracker.registerSuppliedResource(encodingRes);
                             PSResource derivedFontRes = new PSResource(
-                                    PSResource.TYPE_FONT, tf.getFontName() + "_" + (i + 1));
+                                    PSResource.TYPE_FONT, tf.getEmbedFontName() + "_" + (i + 1));
                             resTracker.registerSuppliedResource(derivedFontRes);
                         }
                     }
@@ -366,4 +674,42 @@ public class PSFontUtils extends org.apa
         return res;
     }
 
+    private static PSResource defineDerivedTrueTypeFont(PSGenerator gen,
+            PSEventProducer eventProducer, String baseFontName, String fontName,
+            SingleByteEncoding encoding, CMapSegment[] cmap) throws IOException {
+        checkPostScriptLevel3(gen, eventProducer);
+        PSResource res = new PSResource(PSResource.TYPE_FONT, fontName);
+        gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE, res);
+        gen.commentln("%XGCDependencies: font " + baseFontName);
+        gen.commentln("%XGC+ encoding " + encoding.getName());
+        gen.writeln("/" + baseFontName + " findfont");
+        gen.writeln("dup length dict begin");
+        gen.writeln("  {1 index /FID ne {def} {pop pop} ifelse} forall");
+        gen.writeln("  /Encoding " + encoding.getName() + " def");
+
+        gen.writeln("  /CharStrings 256 dict dup begin");
+        String[] charNameMap = encoding.getCharNameMap();
+        char[] unicodeCharMap = encoding.getUnicodeCharMap();
+        assert charNameMap.length == unicodeCharMap.length;
+        for (int i = 0; i < charNameMap.length; i++) {
+            String glyphName = charNameMap[i];
+            gen.write("    /");
+            gen.write(glyphName);
+            gen.write(" ");
+            if (glyphName.equals(".notdef")) {
+                gen.write(0);
+            } else {
+                gen.write(getGlyphIndex(unicodeCharMap[i], cmap));
+            }
+            gen.writeln(" def");
+        }
+        gen.writeln("  end readonly def");
+
+        gen.writeln("  currentdict");
+        gen.writeln("end");
+        gen.writeln("/" + fontName + " exch definefont pop");
+        gen.writeDSCComment(DSCConstants.END_RESOURCE);
+        gen.getResourceTracker().registerSuppliedResource(res);
+        return res;
+    }
 }

Modified: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java Thu Jul  5 20:29:53 2012
@@ -19,7 +19,10 @@
 
 package org.apache.fop.render.ps;
 
+import java.awt.Dimension;
 import java.awt.Rectangle;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.ColorModel;
 import java.awt.image.RenderedImage;
 import java.io.IOException;
 
@@ -28,6 +31,8 @@ import org.apache.xmlgraphics.image.load
 import org.apache.xmlgraphics.image.loader.ImageInfo;
 import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
 import org.apache.xmlgraphics.ps.FormGenerator;
+import org.apache.xmlgraphics.ps.ImageEncoder;
+import org.apache.xmlgraphics.ps.ImageEncodingHelper;
 import org.apache.xmlgraphics.ps.ImageFormGenerator;
 import org.apache.xmlgraphics.ps.PSGenerator;
 import org.apache.xmlgraphics.ps.PSImageUtils;
@@ -47,17 +52,24 @@ public class PSImageHandlerRenderedImage
     /** {@inheritDoc} */
     public void handleImage(RenderingContext context, Image image, Rectangle pos)
                 throws IOException {
-        PSRenderingContext psContext = (PSRenderingContext)context;
+        PSRenderingContext psContext = (PSRenderingContext) context;
         PSGenerator gen = psContext.getGenerator();
-        ImageRendered imageRend = (ImageRendered)image;
+        ImageRendered imageRend = (ImageRendered) image;
 
-        float x = (float)pos.getX() / 1000f;
-        float y = (float)pos.getY() / 1000f;
-        float w = (float)pos.getWidth() / 1000f;
-        float h = (float)pos.getHeight() / 1000f;
+        float x = (float) pos.getX() / 1000f;
+        float y = (float) pos.getY() / 1000f;
+        float w = (float) pos.getWidth() / 1000f;
+        float h = (float) pos.getHeight() / 1000f;
+        Rectangle2D targetRect = new Rectangle2D.Double(x, y, w, h);
 
         RenderedImage ri = imageRend.getRenderedImage();
-        PSImageUtils.renderBitmapImage(ri, x, y, w, h, gen);
+        ImageEncoder encoder = ImageEncodingHelper.createRenderedImageEncoder(ri);
+        Dimension imgDim = new Dimension(ri.getWidth(), ri.getHeight());
+        String imgDescription = ri.getClass().getName();
+        ImageEncodingHelper helper = new ImageEncodingHelper(ri);
+        ColorModel cm = helper.getEncodedColorModel();
+
+        PSImageUtils.writeImage(encoder, imgDim, imgDescription, targetRect, cm, gen);
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSPainter.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSPainter.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSPainter.java Thu Jul  5 20:29:53 2012
@@ -44,6 +44,7 @@ import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontTriplet;
 import org.apache.fop.fonts.LazyFont;
+import org.apache.fop.fonts.MultiByteFont;
 import org.apache.fop.fonts.SingleByteFont;
 import org.apache.fop.fonts.Typeface;
 import org.apache.fop.render.RenderingContext;
@@ -55,6 +56,7 @@ import org.apache.fop.render.intermediat
 import org.apache.fop.traits.BorderProps;
 import org.apache.fop.traits.RuleStyle;
 import org.apache.fop.util.CharUtilities;
+import org.apache.fop.util.HexEncoder;
 
 /**
  * IFPainter implementation that produces PostScript.
@@ -392,7 +394,7 @@ public class PSPainter extends AbstractI
                     if (currentEncoding != encoding) {
                         if (i > 0) {
                             writeText(text, start, i - start,
-                                    letterSpacing, wordSpacing, dp, font, tf);
+                                    letterSpacing, wordSpacing, dp, font, tf, false);
                         }
                         if (encoding == 0) {
                             useFont(fontKey, sizeMillipoints);
@@ -404,19 +406,18 @@ public class PSPainter extends AbstractI
                     }
                 }
             } else {
-                //Simple single-font painting
                 useFont(fontKey, sizeMillipoints);
             }
-            writeText(text, start, textLen - start, letterSpacing, wordSpacing, dp, font, tf);
+            writeText(text, start, textLen - start, letterSpacing, wordSpacing, dp, font, tf,
+                    tf instanceof MultiByteFont);
         } catch (IOException ioe) {
             throw new IFException("I/O error in drawText()", ioe);
         }
     }
 
-    private void writeText(                                      // CSOK: ParameterNumber
-            String text, int start, int len,
+    private void writeText(String text, int start, int len,
             int letterSpacing, int wordSpacing, int[][] dp,
-            Font font, Typeface tf) throws IOException {
+            Font font, Typeface tf, boolean multiByte) throws IOException {
         PSGenerator generator = getGenerator();
         int end = start + len;
         int initialSize = len;
@@ -451,8 +452,12 @@ public class PSPainter extends AbstractI
             if (dx != null && i < dxl - 1) {
                 glyphAdjust -= dx[i + 1];
             }
-            char codepoint = (char)(ch % 256);
-            PSGenerator.escapeChar(codepoint, accText); //add character to accumulated text
+            if (multiByte) {
+                accText.append(HexEncoder.encode(ch));
+            } else {
+                char codepoint = (char)(ch % 256);
+                PSGenerator.escapeChar(codepoint, accText); //add character to accumulated text
+            }
             if (glyphAdjust != 0) {
                 needTJ = true;
                 if (sb.length() == 0) {
@@ -463,9 +468,8 @@ public class PSPainter extends AbstractI
                         sb.append(PSGenerator.LF);
                         lineStart = sb.length();
                     }
-                    sb.append('(');
-                    sb.append(accText);
-                    sb.append(") ");
+                    lineStart = writePostScriptString(sb, accText, multiByte, lineStart);
+                    sb.append(' ');
                     accText.setLength(0); //reset accumulated text
                 }
                 sb.append(Integer.toString(glyphAdjust)).append(' ');
@@ -473,9 +477,10 @@ public class PSPainter extends AbstractI
         }
         if (needTJ) {
             if (accText.length() > 0) {
-                sb.append('(');
-                sb.append(accText);
-                sb.append(')');
+                if ((sb.length() - lineStart + accText.length()) > 200) {
+                    sb.append(PSGenerator.LF);
+                }
+                writePostScriptString(sb, accText, multiByte);
             }
             if (hasLetterSpacing) {
                 sb.append("] " + formatMptAsPt(generator, letterSpacing) + " ATJ");
@@ -483,7 +488,7 @@ public class PSPainter extends AbstractI
                 sb.append("] TJ");
             }
         } else {
-            sb.append('(').append(accText).append(")");
+            writePostScriptString(sb, accText, multiByte);
             if (hasLetterSpacing) {
                 StringBuffer spb = new StringBuffer();
                 spb.append(formatMptAsPt(generator, letterSpacing))
@@ -497,12 +502,37 @@ public class PSPainter extends AbstractI
         generator.writeln(sb.toString());
     }
 
+    private void writePostScriptString(StringBuffer buffer, StringBuffer string,
+            boolean multiByte) {
+        writePostScriptString(buffer, string, multiByte, 0);
+    }
+
+    private int writePostScriptString(StringBuffer buffer, StringBuffer string, boolean multiByte,
+            int lineStart) {
+        buffer.append(multiByte ? '<' : '(');
+        int l = string.length();
+        int index = 0;
+        int maxCol = 200;
+        buffer.append(string.substring(index, Math.min(index + maxCol, l)));
+        index += maxCol;
+        while (index < l) {
+            if (!multiByte) {
+                buffer.append('\\');
+            }
+            buffer.append(PSGenerator.LF);
+            lineStart = buffer.length();
+            buffer.append(string.substring(index, Math.min(index + maxCol, l)));
+            index += maxCol;
+        }
+        buffer.append(multiByte ? '>' : ')');
+        return lineStart;
+    }
+
     private void useFont(String key, int size) throws IOException {
-        PSResource res = this.documentHandler.getPSResourceForFontKey(key);
+        PSFontResource res = this.documentHandler.getPSResourceForFontKey(key);
         PSGenerator generator = getGenerator();
         generator.useFont("/" + res.getName(), size / 1000f);
-        generator.getResourceTracker().notifyResourceUsageOnPage(res);
+        res.notifyResourceUsageOnPage(generator.getResourceTracker());
     }
 
-
 }

Modified: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSTextPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSTextPainter.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSTextPainter.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/PSTextPainter.java Thu Jul  5 20:29:53 2012
@@ -41,12 +41,15 @@ import org.apache.batik.gvt.text.TextSpa
 
 import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
 import org.apache.xmlgraphics.ps.PSGenerator;
-import org.apache.xmlgraphics.ps.PSResource;
 
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.fonts.FontMetrics;
+import org.apache.fop.fonts.LazyFont;
+import org.apache.fop.fonts.MultiByteFont;
 import org.apache.fop.svg.NativeTextPainter;
 import org.apache.fop.util.CharUtilities;
+import org.apache.fop.util.HexEncoder;
 
 /**
  * Renders the attributed character iterator of a text node.
@@ -240,9 +243,9 @@ public class PSTextPainter extends Nativ
         }
     }
 
-    private PSResource getResourceForFont(Font f, String postfix) {
+    private PSFontResource getResourceForFont(Font f, String postfix) {
         String key = (postfix != null ? f.getFontName() + '_' + postfix : f.getFontName());
-        return this.fontResources.getPSResourceForFontKey(key);
+        return this.fontResources.getFontResourceForFontKey(key);
     }
 
     private void clip(PSGraphics2D ps, Shape shape) throws IOException {
@@ -299,9 +302,9 @@ public class PSTextPainter extends Nativ
         public void selectFont(Font f, char mapped) throws IOException {
             int encoding = mapped / 256;
             String postfix = (encoding == 0 ? null : Integer.toString(encoding));
-            PSResource res = getResourceForFont(f, postfix);
+            PSFontResource res = getResourceForFont(f, postfix);
             gen.useFont("/" + res.getName(), f.getFontSize() / 1000f);
-            gen.getResourceTracker().notifyResourceUsageOnPage(res);
+            res.notifyResourceUsageOnPage(gen.getResourceTracker());
         }
 
         public Font getCurrentFont() {
@@ -427,15 +430,23 @@ public class PSTextPainter extends Nativ
             textUtil.setCurrentFont(f, mapped);
             applyColor(paint, gen);
 
+            FontMetrics metrics = f.getFontMetrics();
+            boolean multiByte = metrics instanceof MultiByteFont
+                    || metrics instanceof LazyFont
+                            && ((LazyFont) metrics).getRealFont() instanceof MultiByteFont;
             StringBuffer sb = new StringBuffer();
-            sb.append('(');
+            sb.append(multiByte ? '<' : '(');
             for (int i = 0, c = this.currentChars.length(); i < c; i++) {
                 char ch = this.currentChars.charAt(i);
                 mapped = f.mapChar(ch);
-                char codepoint = (char) (mapped % 256);
-                PSGenerator.escapeChar(codepoint, sb);
+                if (multiByte) {
+                    sb.append(HexEncoder.encode(mapped));
+                } else {
+                    char codepoint = (char) (mapped % 256);
+                    PSGenerator.escapeChar(codepoint, sb);
+                }
             }
-            sb.append(')');
+            sb.append(multiByte ? '>' : ')');
             if (x || y) {
                 sb.append("\n[");
                 int idx = 0;
@@ -513,10 +524,20 @@ public class PSTextPainter extends Nativ
                     textUtil.selectFont(f, mapped);
                     textUtil.setCurrentFont(f, mapped);
                 }
-                mapped = f.mapChar(this.currentChars.charAt(i));
                 //add glyph outlines to current path
-                char codepoint = (char)(mapped % 256);
-                gen.write("(" + codepoint + ")");
+                mapped = f.mapChar(this.currentChars.charAt(i));
+                FontMetrics metrics = f.getFontMetrics();
+                boolean multiByte = metrics instanceof MultiByteFont
+                        || metrics instanceof LazyFont
+                                && ((LazyFont) metrics).getRealFont() instanceof MultiByteFont;
+                if (multiByte) {
+                    gen.write('<');
+                    gen.write(HexEncoder.encode(mapped));
+                    gen.write('>');
+                } else {
+                    char codepoint = (char)(mapped % 256);
+                    gen.write("(" + codepoint + ")");
+                }
                 gen.writeln(" false charpath");
 
                 if (iter.hasNext()) {

Modified: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/ResourceHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/ResourceHandler.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/ResourceHandler.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/ResourceHandler.java Thu Jul  5 20:29:53 2012
@@ -83,6 +83,8 @@ public class ResourceHandler implements 
     private FOUserAgent userAgent;
     private FontInfo fontInfo;
 
+    private PSEventProducer eventProducer;
+
     private ResourceTracker resTracker;
 
     //key: URI, values PSImageFormResource
@@ -93,13 +95,15 @@ public class ResourceHandler implements 
     /**
      * Main constructor.
      * @param userAgent the FO user agent
+     * @param eventProducer the event producer
      * @param fontInfo the font information
      * @param resTracker the resource tracker to use
      * @param formResources Contains all forms used by this document (maintained by PSRenderer)
      */
-    public ResourceHandler(FOUserAgent userAgent, FontInfo fontInfo,
-            ResourceTracker resTracker, Map formResources) {
+    public ResourceHandler(FOUserAgent userAgent, PSEventProducer eventProducer,
+            FontInfo fontInfo, ResourceTracker resTracker, Map formResources) {
         this.userAgent = userAgent;
+        this.eventProducer = eventProducer;
         this.fontInfo = fontInfo;
         this.resTracker = resTracker;
         determineInlineForms(formResources);
@@ -222,7 +226,7 @@ public class ResourceHandler implements 
         if (fontSetupPlaceholder == null) {
             throw new DSCException("Didn't find %FOPFontSetup comment in stream");
         }
-        PSFontUtils.writeFontDict(gen, fontInfo, fontInfo.getUsedFonts());
+        PSFontUtils.writeFontDict(gen, fontInfo, fontInfo.getUsedFonts(), eventProducer);
         generateForms(globalFormResources, gen);
 
         //Skip the prolog and to the first page

Modified: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java Thu Jul  5 20:29:53 2012
@@ -41,6 +41,7 @@ public class PSExtensionElementMapping e
             foObjs = new java.util.HashMap<String, Maker>();
             foObjs.put(PSSetupCodeElement.ELEMENT, new PSSetupCodeMaker());
             foObjs.put(PSPageSetupCodeElement.ELEMENT, new PSPageSetupCodeMaker());
+            foObjs.put(PSPageTrailerCodeBefore.ELEMENT, new PSPageTrailerCodeBeforeMaker());
             foObjs.put(PSSetPageDeviceElement.ELEMENT, new PSSetPageDeviceMaker());
             foObjs.put(PSCommentBefore.ELEMENT, new PSCommentBeforeMaker());
             foObjs.put(PSCommentAfter.ELEMENT, new PSCommentAfterMaker());
@@ -59,6 +60,12 @@ public class PSExtensionElementMapping e
         }
     }
 
+    static class PSPageTrailerCodeBeforeMaker extends ElementMapping.Maker {
+        public FONode make(FONode parent) {
+            return new PSPageTrailerCodeBeforeElement(parent);
+        }
+    }
+
     static class PSSetPageDeviceMaker extends ElementMapping.Maker {
         public FONode make(FONode parent) {
             return new PSSetPageDeviceElement(parent);

Modified: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java Thu Jul  5 20:29:53 2012
@@ -53,6 +53,7 @@ public class PSExtensionHandler extends 
             lastAttributes = new AttributesImpl(attributes);
             handled = false;
             if (localName.equals(PSSetupCode.ELEMENT)
+                    || localName.equals(PSPageTrailerCodeBefore.ELEMENT)
                     || localName.equals(PSSetPageDevice.ELEMENT)
                     || localName.equals(PSCommentBefore.ELEMENT)
                     || localName.equals(PSCommentAfter.ELEMENT)) {
@@ -84,6 +85,8 @@ public class PSExtensionHandler extends 
                 this.returnedObject = new PSCommentBefore(content.toString());
             } else if (PSCommentAfter.ELEMENT.equals(localName)) {
                 this.returnedObject = new PSCommentAfter(content.toString());
+            } else if (PSPageTrailerCodeBefore.ELEMENT.equals(localName)) {
+                this.returnedObject = new PSPageTrailerCodeBefore(content.toString());
             }
         }
         content.setLength(0); //Reset text buffer (see characters())

Modified: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/xml/XMLRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/xml/XMLRenderer.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/xml/XMLRenderer.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/render/xml/XMLRenderer.java Thu Jul  5 20:29:53 2012
@@ -97,6 +97,15 @@ import org.apache.fop.util.XMLUtil;
  */
 public class XMLRenderer extends AbstractXMLRenderer {
 
+    /**
+     * Area Tree  (AT) version, used to express an @version attribute
+     * in the root element of the AT document, the initial value of which
+     * is set to '2.0' to signify that something preceded it (but didn't
+     * happen to be marked as such), and that this version is not necessarily
+     * backwards compatible with the unmarked (<2.0) version.
+     */
+    public static final String VERSION = "2.0";
+
     /** XML MIME type */
     public static final String XML_MIME_TYPE = MimeConstants.MIME_FOP_AREA_TREE;
 
@@ -365,7 +374,9 @@ public class XMLRenderer extends Abstrac
         if (userAgent.getProducer() != null) {
             comment("Produced by " + userAgent.getProducer());
         }
-        startElement("areaTree");
+        atts.clear();
+        addAttribute("version", VERSION);
+        startElement("areaTree", atts);
     }
 
     /** {@inheritDoc} */
@@ -825,11 +836,10 @@ public class XMLRenderer extends Abstrac
         }
         maybeAddLevelAttribute(word);
         maybeAddPositionAdjustAttribute(word);
-        if ( word.isReversed() ) {
-            addAttribute("reversed", "true");
-        }
+        String text = word.getWord();
+        maybeAddReversedAttribute(word, text);
         startElement("word", atts);
-        characters(word.getWord());
+        characters(text);
         endElement("word");
         super.renderWord(word);
     }
@@ -917,5 +927,11 @@ public class XMLRenderer extends Abstrac
         }
     }
 
+    private void maybeAddReversedAttribute ( WordArea w, String text ) {
+        if ( w.isReversed() && ( text.length() > 1 )  ) {
+            addAttribute("reversed", "true");
+        }
+    }
+
 
 }

Modified: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/svg/PDFAElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/svg/PDFAElementBridge.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/svg/PDFAElementBridge.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/svg/PDFAElementBridge.java Thu Jul  5 20:29:53 2012
@@ -64,7 +64,7 @@ public class PDFAElementBridge extends A
     }
 
     /**
-     * Creates a {@link CompositeGraphicsNode}.
+     * Creates a {@link org.apache.batik.gvt.CompositeGraphicsNode}.
      * @return a new PDFANode
      */
     protected GraphicsNode instantiateGraphicsNode() {

Modified: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/svg/PDFGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/svg/PDFGraphics2D.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/svg/PDFGraphics2D.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/svg/PDFGraphics2D.java Thu Jul  5 20:29:53 2012
@@ -1201,6 +1201,8 @@ public class PDFGraphics2D extends Abstr
                 currentStream.write("] ");
                 float offset = bs.getDashPhase();
                 currentStream.write(PDFNumber.doubleOut(offset) + " d\n");
+            } else {
+                currentStream.write("[] 0 d\n");
             }
             int ec = bs.getEndCap();
             switch (ec) {

Modified: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/traits/MinOptMax.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/traits/MinOptMax.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/traits/MinOptMax.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/traits/MinOptMax.java Thu Jul  5 20:29:53 2012
@@ -22,8 +22,9 @@ package org.apache.fop.traits;
 import java.io.Serializable;
 
 /**
- * This class holds the resolved (as mpoints) form of a {@link LengthRangeProperty LengthRange} or
- * {@link SpaceProperty Space} type property value.
+ * This class holds the resolved (as mpoints) form of a
+ * {@link org.apache.fop.fo.properties.LengthRangeProperty} or
+ * {@link org.apache.fop.fo.properties.SpaceProperty} type property value.
  * <p/>
  * Instances of this class are immutable. All arithmetic methods like {@link #plus(MinOptMax) plus},
  * {@link #minus(MinOptMax) minus} or {@link #mult(int) mult} return a different instance. So it is

Modified: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/traits/TraitEnum.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/traits/TraitEnum.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/traits/TraitEnum.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/traits/TraitEnum.java Thu Jul  5 20:29:53 2012
@@ -30,7 +30,7 @@ public abstract class TraitEnum implemen
     /**
      * Constructor to add a new named item.
      * @param name Name of the item.
-     * @param enumValue the {@link Constants}.EN_* value
+     * @param enumValue the {@link org.apache.fop.fo.Constants}.EN_* value
      */
     protected TraitEnum(String name, int enumValue) {
         this.name = name;
@@ -46,7 +46,7 @@ public abstract class TraitEnum implemen
     }
 
     /**
-     * Returns the enumeration value (one of {@link Constants}.EN_*).
+     * Returns the enumeration value (one of {@link org.apache.fop.fo.Constants}.EN_*).
      * @return the enumeration value
      */
     public int getEnumValue() {

Modified: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/util/ColorExt.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/util/ColorExt.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/util/ColorExt.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/util/ColorExt.java Thu Jul  5 20:29:53 2012
@@ -28,7 +28,7 @@ import java.util.Arrays;
  * <p>
  * This class extends java.awt.Color class keeping track of the original color
  * property values specified by the fo user in a rgb-icc call.
- * @deprecated Replaced by {@link ColorWithAlternatives}
+ * @deprecated Replaced by {@link org.apache.xmlgraphics.java2d.color.ColorWithAlternatives}
  */
 @Deprecated
 public final class ColorExt extends Color {

Propchange: xmlgraphics/fop/branches/fop-1_1/src/java/org/apache/fop/util/ColorExt.java
            ('svn:mergeinfo' removed)

Modified: xmlgraphics/fop/branches/fop-1_1/src/sandbox/org/apache/fop/render/mif/MIFHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/sandbox/org/apache/fop/render/mif/MIFHandler.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/sandbox/org/apache/fop/render/mif/MIFHandler.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/sandbox/org/apache/fop/render/mif/MIFHandler.java Thu Jul  5 20:29:53 2012
@@ -29,8 +29,10 @@ import org.apache.commons.logging.LogFac
 
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.fo.FOEventHandler;
+import org.apache.fop.fo.FOText;
 import org.apache.fop.fo.flow.BasicLink;
 import org.apache.fop.fo.flow.Block;
+import org.apache.fop.fo.flow.Character;
 import org.apache.fop.fo.flow.ExternalGraphic;
 import org.apache.fop.fo.flow.Footnote;
 import org.apache.fop.fo.flow.FootnoteBody;
@@ -39,6 +41,8 @@ import org.apache.fop.fo.flow.InstreamFo
 import org.apache.fop.fo.flow.Leader;
 import org.apache.fop.fo.flow.ListBlock;
 import org.apache.fop.fo.flow.ListItem;
+import org.apache.fop.fo.flow.ListItemBody;
+import org.apache.fop.fo.flow.ListItemLabel;
 import org.apache.fop.fo.flow.PageNumber;
 import org.apache.fop.fo.flow.table.Table;
 import org.apache.fop.fo.flow.table.TableBody;
@@ -51,6 +55,7 @@ import org.apache.fop.fo.pagination.Flow
 import org.apache.fop.fo.pagination.PageSequence;
 import org.apache.fop.fo.pagination.PageSequenceMaster;
 import org.apache.fop.fo.pagination.SimplePageMaster;
+import org.apache.fop.fo.pagination.StaticContent;
 import org.apache.fop.fonts.FontSetup;
 import org.apache.fop.render.DefaultFontResolver;
 
@@ -267,27 +272,27 @@ public class MIFHandler extends FOEventH
     }
 
     /** {@inheritDoc} */
-    public void startListLabel() {
+    public void startListLabel(ListItemLabel listItemLabel) {
     }
 
     /** {@inheritDoc} */
-    public void endListLabel() {
+    public void endListLabel(ListItemLabel listItemLabel) {
     }
 
     /** {@inheritDoc} */
-    public void startListBody() {
+    public void startListBody(ListItemBody listItemBody) {
     }
 
     /** {@inheritDoc} */
-    public void endListBody() {
+    public void endListBody(ListItemBody listItemBody) {
     }
 
     /** {@inheritDoc} */
-    public void startStatic() {
+    public void startStatic(StaticContent staticContent) {
     }
 
     /** {@inheritDoc} */
-    public void endStatic() {
+    public void endStatic(StaticContent staticContent) {
     }
 
     /** {@inheritDoc} */
@@ -303,7 +308,7 @@ public class MIFHandler extends FOEventH
     }
 
     /** {@inheritDoc} */
-    public void endLink() {
+    public void endLink(BasicLink basicLink) {
     }
 
     /** {@inheritDoc} */
@@ -315,7 +320,11 @@ public class MIFHandler extends FOEventH
     }
 
     /** {@inheritDoc} */
-    public void foreignObject(InstreamForeignObject ifo) {
+    public void startInstreamForeignObject(InstreamForeignObject ifo) {
+    }
+
+    /** {@inheritDoc} */
+    public void endInstreamForeignObject(InstreamForeignObject ifo) {
     }
 
     /** {@inheritDoc} */
@@ -335,19 +344,37 @@ public class MIFHandler extends FOEventH
     }
 
     /** {@inheritDoc} */
-    public void leader(Leader l) {
+    public void startLeader(Leader l) {
+    }
+
+    /** {@inheritDoc} */
+    public void endLeader(Leader l) {
+    }
+
+    public void character(Character c) {
+        appendCharacters ( new String ( new char[] {c.getCharacter()} ) );
+    }
+
+    /** {@inheritDoc} */
+    public void characters(FOText foText) {
+        appendCharacters ( foText.getCharSequence().toString() );
+    }
+
+    /** {@inheritDoc} */
+    public void startPageNumber(PageNumber pagenum) {
     }
 
     /** {@inheritDoc} */
-    public void characters(char[] data, int start, int length) {
+    public void endPageNumber(PageNumber pagenum) {
+    }
+
+    private void appendCharacters ( String str ) {
         if (para != null) {
-            String str = new String(data, start, length);
             str = str.trim();
             // break into nice length chunks
             if (str.length() == 0) {
                 return;
             }
-
             MIFElement line = new MIFElement("ParaLine");
             MIFElement prop = new MIFElement("TextRectID");
             prop.setValue("2");
@@ -355,17 +382,8 @@ public class MIFHandler extends FOEventH
             prop = new MIFElement("String");
             prop.setValue("\"" + str + "\"");
             line.addElement(prop);
-
             para.addElement(line);
         }
     }
-
-    /** {@inheritDoc} */
-    public void startPageNumber(PageNumber pagenum) {
-    }
-
-    /** {@inheritDoc} */
-    public void endPageNumber(PageNumber pagenum) {
-    }
 }
 

Modified: xmlgraphics/fop/branches/fop-1_1/src/sandbox/org/apache/fop/render/svg/SVGDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/sandbox/org/apache/fop/render/svg/SVGDocumentHandler.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/sandbox/org/apache/fop/render/svg/SVGDocumentHandler.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/sandbox/org/apache/fop/render/svg/SVGDocumentHandler.java Thu Jul  5 20:29:53 2012
@@ -54,7 +54,8 @@ import org.apache.fop.util.GenerationHel
 import org.apache.fop.util.XMLUtil;
 
 /**
- * {@link IFDocumentHandler} implementation that writes SVG 1.1.
+ * {@link org.apache.fop.render.intermediate.IFDocumentHandler} implementation
+ * that writes SVG 1.1.
  */
 public class SVGDocumentHandler extends AbstractSVGDocumentHandler {
 

Modified: xmlgraphics/fop/branches/fop-1_1/src/sandbox/org/apache/fop/render/svg/SVGPrintDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/src/sandbox/org/apache/fop/render/svg/SVGPrintDocumentHandler.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/src/sandbox/org/apache/fop/render/svg/SVGPrintDocumentHandler.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/src/sandbox/org/apache/fop/render/svg/SVGPrintDocumentHandler.java Thu Jul  5 20:29:53 2012
@@ -32,7 +32,8 @@ import org.apache.fop.render.intermediat
 import org.apache.fop.util.XMLUtil;
 
 /**
- * {@link IFDocumentHandler} implementation that writes SVG Print.
+ * {@link org.apache.fop.render.intermediate.IFDocumentHandler} implementation
+ * that writes SVG Print.
  */
 public class SVGPrintDocumentHandler extends AbstractSVGDocumentHandler {
 

Modified: xmlgraphics/fop/branches/fop-1_1/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/status.xml?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/status.xml (original)
+++ xmlgraphics/fop/branches/fop-1_1/status.xml Thu Jul  5 20:29:53 2012
@@ -62,6 +62,51 @@
       documents. Example: the fix of marks layering will be such a case when it's done.
     -->
     <release version="1.1rc1" date="02 July 2012">
+      <action context="Test" dev="GA" type="fix">
+        Fix errors and warnings in example files. Add build.xml for documentation examples.
+      </action>
+      <action context="Code" dev="GA" type="fix" fixes-bug="53458" due-to="Dieter von Holten">
+        Fix incorrect language and country code key generation in hyphenation tree cache.
+      </action>
+      <action context="Images" dev="GA" type="fix" fixes-bug="53431" due-to="Luis Bernardo">
+        Fix incorrect SVG line dash pattern with PDF output format.
+      </action>
+      <action context="Images" dev="GA" type="update" fixes-bug="40676" due-to="Luis Bernardo">
+        Fix interoperability issue with Adobe reader regarding use of multiple filters.
+      </action>
+      <action context="Code" dev="GA" type="fix">
+        Eliminate javadocs warnings.
+      </action>
+      <action context="Renderers" dev="VH" type="add" fixes-bug="52338" importance="high">
+        Added possibility to embed TrueType fonts in PostScript.
+      </action>
+      <action context="Images" dev="GA" type="update" fixes-bug="40676" due-to="Luis Bernardo">
+        Update site documentation about PNG image loading configuration and support.
+      </action>
+      <action context="Images" dev="GA" type="update" fixes-bug="40676" due-to="Luis Bernardo">
+        Fix newly introduced findbugs warnings.
+      </action>
+      <action context="Images" dev="GA" type="fix" fixes-bug="40676" due-to="Luis Bernardo, Matthias Reischenbacher">
+        Support use of ImageLoaderRawPNG decoder in order to prevent re-encoding of PNG images (and unnecssary output file bloat).
+      </action>
+      <action context="Code" dev="GA" type="fix" fixes-bug="53412" due-to="Alexios Giotis">
+        Eliminate incorrect use of object identity which produces excessive property cache collisions.
+      </action>
+      <action context="Code" dev="GA" type="fix">
+        Eliminate javadocs warnings.
+      </action>
+      <action context="Code" dev="GA" type="update" fixes-bug="53055">
+        Update xmlgraphics common jar to reflect recent fixes in XGC.
+      </action>
+      <action context="Code" dev="GA" type="update" fixes-bug="43940" due-to="Julien Aymé">
+        Fix handling of NaN, {+,-}Infinity, and other edge cases. Submitted by Julien Aymé.
+      </action>
+      <action context="Renderers" dev="GA" type="fix" fixes-bug="53304,53306">
+        Add version attribute to AT and IF intermediate formats. Also eliminate redundant use of reversed attribute in AT format.
+      </action>
+      <action context="Renderers" dev="GA" type="fix" fixes-bug="53295" due-to="Luis Bernardo">
+        Add extension to place code just before PostScript %PageTrailer.
+      </action>
       <action context="Renderers" dev="GA" type="fix" fixes-bug="53294" due-to="Robert Meyer">
         Fix invalid PostScript file being created when font-size is 0.
       </action>

Modified: xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/UtilityCodeTestSuite.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/UtilityCodeTestSuite.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/UtilityCodeTestSuite.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/UtilityCodeTestSuite.java Thu Jul  5 20:29:53 2012
@@ -28,10 +28,13 @@ import org.apache.fop.pdf.FileIDGenerato
 import org.apache.fop.pdf.PDFDocumentGraphics2DTestCase;
 import org.apache.fop.pdf.PDFEncryptionJCETestCase;
 import org.apache.fop.pdf.PDFFactoryTestCase;
+import org.apache.fop.pdf.PDFNumberTestCase;
+import org.apache.fop.pdf.PDFObjectTestCase;
 import org.apache.fop.traits.BorderPropsTestCase;
 import org.apache.fop.util.BitmapImageUtilTestCase;
 import org.apache.fop.util.ColorUtilTestCase;
 import org.apache.fop.util.ElementListUtilsTestCase;
+import org.apache.fop.util.HexEncoderTestCase;
 import org.apache.fop.util.XMLResourceBundleTestCase;
 
 /**
@@ -49,7 +52,10 @@ import org.apache.fop.util.XMLResourceBu
     PDFFactoryTestCase.class,
     PDFEncryptionJCETestCase.class,
     BitmapImageUtilTestCase.class,
-    PDFDocumentGraphics2DTestCase.class
+    PDFDocumentGraphics2DTestCase.class,
+    PDFNumberTestCase.class,
+    PDFObjectTestCase.class,
+    HexEncoderTestCase.class
 })
 public class UtilityCodeTestSuite {
 }

Modified: xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java Thu Jul  5 20:29:53 2012
@@ -19,8 +19,6 @@
 
 package org.apache.fop.accessibility.fo;
 
-import static org.junit.Assert.assertTrue;
-
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -45,6 +43,8 @@ import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.AttributesImpl;
 
+import static org.junit.Assert.assertTrue;
+
 import org.apache.fop.accessibility.StructureTree2SAXEventAdapter;
 import org.apache.fop.accessibility.StructureTreeEventHandler;
 import org.apache.fop.apps.FOPException;
@@ -102,6 +102,17 @@ public class FO2StructureTreeConverterTe
         testConverter();
     }
 
+    @Test
+    public void testArtifact() throws Exception {
+        foLoader = new FOLoader() {
+
+            public InputStream getFoInputStream() {
+                return getResource("artifact.fo");
+            }
+        };
+        testConverter();
+    }
+
     private Transformer createTransformer(Source xslt) throws TransformerFactoryConfigurationError,
             TransformerConfigurationException {
         TransformerFactory transformerFactory = TransformerFactory.newInstance();

Modified: xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl (original)
+++ xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl Thu Jul  5 20:29:53 2012
@@ -105,6 +105,8 @@
     <xsl:call-template name="copy"/>
   </xsl:template>
 
+  <xsl:template match="fo:wrapper[translate(normalize-space(@role), 'ARTIFCT', 'artifct') = 'artifact']"/>
+
 
   <!-- Discard descendants of fo:leader -->
   <xsl:template match="fo:leader"/>

Modified: xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/fonts/DejaVuLGCSerifTestCase.java Thu Jul  5 20:29:53 2012
@@ -43,7 +43,8 @@ public class DejaVuLGCSerifTestCase {
     @Before
     public void setUp() throws Exception {
         File file = new File("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
-        font = FontLoader.loadFont(file, "", true, EncodingMode.AUTO, fontResolver);
+        font = FontLoader.loadFont(file, "", true, EmbeddingMode.AUTO, EncodingMode.AUTO,
+                fontResolver);
     }
 
     /**

Modified: xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/fonts/EncodingModeTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/fonts/EncodingModeTestCase.java?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/fonts/EncodingModeTestCase.java (original)
+++ xmlgraphics/fop/branches/fop-1_1/test/java/org/apache/fop/fonts/EncodingModeTestCase.java Thu Jul  5 20:29:53 2012
@@ -19,10 +19,13 @@
 
 package org.apache.fop.fonts;
 
-import static org.junit.Assert.assertEquals;
-
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests {@link EncodingMode}.
+ */
 public class EncodingModeTestCase {
 
     @Test
@@ -34,8 +37,13 @@ public class EncodingModeTestCase {
 
     @Test
     public void testGetValue() {
-        assertEquals(EncodingMode.AUTO, EncodingMode.getEncodingMode("auto"));
-        assertEquals(EncodingMode.SINGLE_BYTE, EncodingMode.getEncodingMode("single-byte"));
-        assertEquals(EncodingMode.CID, EncodingMode.getEncodingMode("cid"));
+        assertEquals(EncodingMode.AUTO, EncodingMode.getValue("auto"));
+        assertEquals(EncodingMode.SINGLE_BYTE, EncodingMode.getValue("single-byte"));
+        assertEquals(EncodingMode.CID, EncodingMode.getValue("cid"));
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void getValueMustCheckForIllegalArguments() {
+        EncodingMode.getValue("fail");
     }
 }

Modified: xmlgraphics/fop/branches/fop-1_1/test/layoutengine/standard-testcases/bidi_propagation_1.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/test/layoutengine/standard-testcases/bidi_propagation_1.xml?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/test/layoutengine/standard-testcases/bidi_propagation_1.xml (original)
+++ xmlgraphics/fop/branches/fop-1_1/test/layoutengine/standard-testcases/bidi_propagation_1.xml Thu Jul  5 20:29:53 2012
@@ -66,7 +66,7 @@
                           <fo:table-cell margin-left="0" text-align="right">
                             <fo:block>
                               <fo:inline>
-                                <fo:inline><fo:bidi-override unicode-bidi="bidi-override" direction="rtl">X</fo:bidi-override></fo:inline>
+                                <fo:inline><fo:bidi-override unicode-bidi="bidi-override" direction="rtl">XY</fo:bidi-override></fo:inline>
                               </fo:inline>
                             </fo:block>
                           </fo:table-cell>
@@ -93,7 +93,7 @@
                           <fo:table-cell margin-left="0" text-align="right">
                             <fo:block>
                               <fo:inline>
-                                <fo:inline><fo:bidi-override unicode-bidi="bidi-override" direction="rtl">X</fo:bidi-override></fo:inline>
+                                <fo:inline><fo:bidi-override unicode-bidi="bidi-override" direction="rtl">XY</fo:bidi-override></fo:inline>
                               </fo:inline>
                             </fo:block>
                           </fo:table-cell>

Modified: xmlgraphics/fop/branches/fop-1_1/test/layoutengine/standard-testcases/character_writing-mode_rl.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/test/layoutengine/standard-testcases/character_writing-mode_rl.xml?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/test/layoutengine/standard-testcases/character_writing-mode_rl.xml (original)
+++ xmlgraphics/fop/branches/fop-1_1/test/layoutengine/standard-testcases/character_writing-mode_rl.xml Thu Jul  5 20:29:53 2012
@@ -59,18 +59,18 @@
     <eval expected="6672" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/@ipd"/>
     <eval expected="4" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/word[1]"/>
     <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/word[1]/@level"/>
-    <true xpath="boolean(//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/word[1]/@reversed)"/>
+    <eval expected="" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/word[1]/@reversed"/>
     <eval expected="6672" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[2]/@ipd"/>
     <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[2]/word[1]"/>
-    <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/word[1]/@level"/>
-    <true xpath="boolean(//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/word[1]/@reversed)"/>
+    <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[2]/word[1]/@level"/>
+    <eval expected="" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[2]/word[1]/@reversed"/>
     <eval expected="6672" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[3]/@ipd"/>
     <eval expected="2" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[3]/word[1]"/>
     <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[3]/word[1]/@level"/>
-    <true xpath="boolean(//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[3]/word[1]/@reversed)"/>
+    <eval expected="" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[3]/word[1]/@reversed"/>
     <eval expected="6672" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[4]/@ipd"/>
     <eval expected="1" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[4]/word[1]"/>
     <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[4]/word[1]/@level"/>
-    <true xpath="boolean(//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[4]/word[1]/@reversed)"/>
+    <eval expected="" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[4]/word[1]/@reversed"/>
   </checks>
 </testcase>

Modified: xmlgraphics/fop/branches/fop-1_1/test/pdf/accessibility/pdf/role.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/test/pdf/accessibility/pdf/role.pdf?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
Binary files - no diff available.

Modified: xmlgraphics/fop/branches/fop-1_1/test/pdf/accessibility/role.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-1_1/test/pdf/accessibility/role.fo?rev=1357883&r1=1357882&r2=1357883&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-1_1/test/pdf/accessibility/role.fo (original)
+++ xmlgraphics/fop/branches/fop-1_1/test/pdf/accessibility/role.fo Thu Jul  5 20:29:53 2012
@@ -24,8 +24,8 @@
       <fo:region-after extent="10pt"/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" role="Art">
-    <fo:static-content flow-name="xsl-region-after" role="NonStruct" font-size="8pt">
+  <fo:page-sequence master-reference="page" language="en" country="GB" role="Art">
+    <fo:static-content flow-name="xsl-region-after" role="artifact" font-size="8pt">
       <fo:block text-align="center"><fo:page-number/></fo:block>
     </fo:static-content>
     <fo:flow flow-name="xsl-region-body" role="NonStruct"  hyphenate="true" 



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org