jeremias    2003/03/27 02:59:06

  Modified:    src/java/org/apache/fop/pdf PDFT1Stream.java
  Log:
  The Type1 font stream is now an AbstractPDFStream to bypass the need for an 
additional buffer.
  
  Revision  Changes    Path
  1.2       +34 -36    xml-fop/src/java/org/apache/fop/pdf/PDFT1Stream.java
  
  Index: PDFT1Stream.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFT1Stream.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFT1Stream.java  11 Mar 2003 13:05:09 -0000      1.1
  +++ PDFT1Stream.java  27 Mar 2003 10:59:05 -0000      1.2
  @@ -52,7 +52,7 @@
   
   // Java
   import java.io.IOException;
  -import java.io.UnsupportedEncodingException;
  +import java.io.OutputStream;
   
   // FOP
   import org.apache.fop.fonts.type1.PFBData;
  @@ -60,18 +60,21 @@
   /**
    * Special PDFStream for embedding Type 1 fonts.
    */
  -public class PDFT1Stream extends PDFStream {
  +public class PDFT1Stream extends AbstractPDFStream {
       
       private PFBData pfb;
   
       /**
  -     * @see org.apache.fop.pdf.PDFObject#PDFObject(int)
  +     * @see org.apache.fop.pdf.AbstractPDFStream#getSizeHint()
        */
  -    public PDFT1Stream(int num) {
  -        super(num);
  +    protected int getSizeHint() throws IOException {
  +        if (this.pfb != null) {
  +            return pfb.getLength();
  +        } else {
  +            return 0; //no hint available
  +        }
       }
   
  -
       /**
        * Overload the base object method so we don't have to copy
        * byte arrays around so much
  @@ -82,48 +85,43 @@
           if (pfb == null) {
               throw new IllegalStateException("pfb must not be null at this point");
           }
  -        int length = 0;
  -        String filterEntry = applyFilters();
  -        String preData = this.number + " " + this.generation
  -                + " obj\n<< /Length " + pfb.getLength() + " " 
  -                + filterEntry  
  -                + " /Length1 " + pfb.getLength1()
  -                + " /Length2 " + pfb.getLength2()
  -                + " /Length3 " + pfb.getLength3() + " >>\n";
  +        getDocumentSafely().getLogger().debug("Writing " 
  +                + pfb.getLength() + " bytes of Type 1 font data");
   
  -        byte[] p;
  -        try {
  -            p = preData.getBytes(PDFDocument.ENCODING);
  -        } catch (UnsupportedEncodingException ue) {
  -            p = preData.getBytes();
  -        }       
  -
  -        stream.write(p);
  -        length += p.length;
  -
  -        length += outputStreamData(stream);
  -        try {
  -            p = "endobj\n".getBytes(PDFDocument.ENCODING);
  -        } catch (UnsupportedEncodingException ue) {
  -            p = "endobj\n".getBytes();
  -        }       
  -        stream.write(p);
  -        length += p.length;
  -        //System.out.println("Embedded Type1 font");
  +        int length = super.output(stream);
  +        getDocumentSafely().getLogger().debug("Embedded Type1 font");
           return length;
       }
   
       /**
  +     * @see org.apache.fop.pdf.AbstractPDFStream#buildStreamDict(String)
  +     */
  +    protected String buildStreamDict(String lengthEntry) {
  +        final String filterEntry = getFilterList().buildFilterDictEntries();
  +        return (getObjectID() 
  +                + "<< /Length " + lengthEntry 
  +                + " /Length1 " + pfb.getLength1()
  +                + " /Length2 " + pfb.getLength2()
  +                + " /Length3 " + pfb.getLength3() 
  +                + "\n" + filterEntry  
  +                + "\n>>\n");
  +    }
  +
  +    /**
  +     * @see org.apache.fop.pdf.PDFStream#outputRawStreamData(OutputStream)
  +     */
  +    protected void outputRawStreamData(OutputStream out) throws IOException {
  +        this.pfb.outputAllParts(out);
  +    }
  +    
  +    /**
        * Used to set the PFBData object that represents the embeddable Type 1 
        * font.
        * @param pfb The PFB file
        * @throws IOException in case of an I/O problem
        */
       public void setData(PFBData pfb) throws IOException {
  -        data.reset();
  -        // System.out.println("Writing " + size + " bytes of font data");
           this.pfb = pfb;
  -        pfb.outputAllParts(data.getOutputStream());
       }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to