jeremias    2003/03/27 02:32:22

  Modified:    src/java/org/apache/fop/pdf PDFFontType0.java
                        PDFFontType3.java PDFFontTrueType.java
                        PDFFontDescriptor.java PDFFont.java
                        PDFFontType1.java PDFFontNonBase14.java
  Log:
  The PDF object number doesn't get passed to the constructor anymore. Adjust for that.
  Use the toPDFString() (returns String) method instead of toPDF() (returns byte[]) 
where appropriate. String to byte[] conversion is done in PDFObject in a well-defined 
location instead of scattered around the codebase.
  
  Revision  Changes    Path
  1.2       +4 -6      xml-fop/src/java/org/apache/fop/pdf/PDFFontType0.java
  
  Index: PDFFontType0.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFFontType0.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFFontType0.java 11 Mar 2003 13:05:09 -0000      1.1
  +++ PDFFontType0.java 27 Mar 2003 10:32:22 -0000      1.2
  @@ -72,17 +72,16 @@
       /**
        * Create the /Font object
        *
  -     * @param number the object's number
        * @param fontname the internal name for the font
        * @param basefont the base font name
        * @param encoding the character encoding schema used by the font
        */
  -    public PDFFontType0(int number, String fontname, 
  +    public PDFFontType0(String fontname, 
                           String basefont,
                           Object encoding) {
   
           /* generic creation of PDF object */
  -        super(number, fontname, FontType.TYPE0, basefont, encoding /* , mapping */);
  +        super(fontname, FontType.TYPE0, basefont, encoding /* , mapping */);
   
           /* set fields using paramaters */
           this.descendantFonts = null;
  @@ -92,19 +91,18 @@
       /**
        * Create the /Font object
        *
  -     * @param number the object's number
        * @param fontname the internal name for the font
        * @param basefont the base font name
        * @param encoding the character encoding schema used by the font
        * @param descendantFonts the CIDFont upon which this font is based
        */
  -    public PDFFontType0(int number, String fontname, 
  +    public PDFFontType0(String fontname, 
                           String basefont,
                           Object encoding, 
                           PDFCIDFont descendantFonts) {
   
           /* generic creation of PDF object */
  -        super(number, fontname, FontType.TYPE0, basefont, encoding /* , mapping */);
  +        super(fontname, FontType.TYPE0, basefont, encoding /* , mapping */);
   
           /* set fields using paramaters */
           this.descendantFonts = descendantFonts;
  
  
  
  1.2       +4 -6      xml-fop/src/java/org/apache/fop/pdf/PDFFontType3.java
  
  Index: PDFFontType3.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFFontType3.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFFontType3.java 11 Mar 2003 13:05:09 -0000      1.1
  +++ PDFFontType3.java 27 Mar 2003 10:32:22 -0000      1.2
  @@ -85,17 +85,16 @@
       /**
        * Create the /Font object
        *
  -     * @param number the object's number
        * @param fontname the internal name for the font
        * @param basefont the base font name
        * @param encoding the character encoding schema used by the font
        */
  -    public PDFFontType3(int number, String fontname, 
  +    public PDFFontType3(String fontname, 
                           String basefont,
                           Object encoding) {
   
           /* generic creation of PDF object */
  -        super(number, fontname, FontType.TYPE3, basefont, encoding /* , mapping */);
  +        super(fontname, FontType.TYPE3, basefont, encoding /* , mapping */);
   
           this.fontBBox = null;
           this.fontMatrix = null;
  @@ -105,7 +104,6 @@
       /**
        * Create the /Font object
        *
  -     * @param number the object's number
        * @param fontname the internal name for the font
        * @param basefont the base font name
        * @param encoding the character encoding schema used by the font
  @@ -113,14 +111,14 @@
        * @param fontMatrix the font's transformation matrix
        * @param charProcs the glyphs' definitions
        */
  -    public PDFFontType3(int number, String fontname, 
  +    public PDFFontType3(String fontname, 
                           String basefont,
                           Object encoding,
                           PDFRectangle fontBBox, PDFArray fontMatrix,
                           PDFCharProcs charProcs) {
   
           /* generic creation of PDF object */
  -        super(number, fontname, FontType.TYPE3, basefont, encoding /* , mapping */);
  +        super(fontname, FontType.TYPE3, basefont, encoding /* , mapping */);
   
           this.fontBBox = fontBBox;
           this.fontMatrix = fontMatrix;
  
  
  
  1.2       +2 -3      xml-fop/src/java/org/apache/fop/pdf/PDFFontTrueType.java
  
  Index: PDFFontTrueType.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFFontTrueType.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFFontTrueType.java      11 Mar 2003 13:05:09 -0000      1.1
  +++ PDFFontTrueType.java      27 Mar 2003 10:32:22 -0000      1.2
  @@ -63,17 +63,16 @@
       /**
        * create the /Font object
        *
  -     * @param number the object's number
        * @param fontname the internal name for the font
        * @param basefont the base font name
        * @param encoding the character encoding schema used by the font
        */
  -    public PDFFontTrueType(int number, String fontname, 
  +    public PDFFontTrueType(String fontname, 
                              String basefont,
                              Object encoding) {
   
           /* generic creation of PDF object */
  -        super(number, fontname, FontType.TRUETYPE, basefont, encoding /* , mapping 
*/);
  +        super(fontname, FontType.TRUETYPE, basefont, encoding /* , mapping */);
       }
   
   }
  
  
  
  1.2       +10 -12    xml-fop/src/java/org/apache/fop/pdf/PDFFontDescriptor.java
  
  Index: PDFFontDescriptor.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFFontDescriptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFFontDescriptor.java    11 Mar 2003 13:05:09 -0000      1.1
  +++ PDFFontDescriptor.java    27 Mar 2003 10:32:22 -0000      1.2
  @@ -83,7 +83,6 @@
       /**
        * Create the /FontDescriptor object
        *
  -     * @param number the object's number
        * @param ascent the maximum height above the baseline
        * @param descent the maximum depth below the baseline
        * @param capHeight height of the capital letters
  @@ -93,13 +92,13 @@
        * @param italicAngle the angle of the vertical dominant strokes
        * @param stemV the width of the dominant vertical stems of glyphs
        */
  -    public PDFFontDescriptor(int number, String basefont, int ascent,
  +    public PDFFontDescriptor(String basefont, int ascent,
                                int descent, int capHeight, int flags,
                                PDFRectangle fontBBox, int italicAngle,
                                int stemV) {
   
           /* generic creation of PDF object */
  -        super(number);
  +        super();
   
           /* set fields using paramaters */
           this.basefont = basefont;
  @@ -150,14 +149,13 @@
       // public void setCharSet(){}//for subset fonts
   
       /**
  -     * Produce the PDF representation for the object
  -     *
  -     * @return the PDF
  +     * @see org.apache.fop.pdf.PDFObject#toPDFString()
        */
  -    public byte[] toPDF() {
  -        StringBuffer p = new StringBuffer(this.number + " " + this.generation
  -                                          + " obj\n<< /Type /FontDescriptor"
  -                                          + "\n/FontName /" + this.basefont);
  +    public String toPDFString() {
  +        StringBuffer p = new StringBuffer(128);
  +        p.append(getObjectID() 
  +                + "<< /Type /FontDescriptor"
  +                + "\n/FontName /" + this.basefont);
   
           p.append("\n/FontBBox ");
           p.append(fontBBox.toPDFString());
  @@ -209,8 +207,8 @@
           // charSet for subset fonts // not yet implemented
           // CID optional field
           fillInPDF(p);
  -        p.append("\n >>\nendobj\n");
  -        return p.toString().getBytes();
  +        p.append(" >>\nendobj\n");
  +        return p.toString();
       }
   
       /**
  
  
  
  1.2       +18 -22    xml-fop/src/java/org/apache/fop/pdf/PDFFont.java
  
  Index: PDFFont.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFFont.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFFont.java      11 Mar 2003 13:05:09 -0000      1.1
  +++ PDFFont.java      27 Mar 2003 10:32:22 -0000      1.2
  @@ -96,18 +96,17 @@
       /**
        * create the /Font object
        *
  -     * @param number the object's number
        * @param fontname the internal name for the font
        * @param subtype the font's subtype
        * @param basefont the base font name
        * @param encoding the character encoding schema used by the font
        */
  -    public PDFFont(int number, String fontname, FontType subtype,
  +    public PDFFont(String fontname, FontType subtype,
                      String basefont,
                      Object encoding /* , PDFToUnicode mapping */) {
   
           /* generic creation of PDF object */
  -        super(number);
  +        super();
   
           /* set fields using paramaters */
           this.fontname = fontname;
  @@ -120,28 +119,27 @@
       /**
        * factory method with the basic parameters
        *
  -     * @param number the object's number
        * @param fontname the internal name for the font
        * @param subtype the font's subtype
        * @param basefont the base font name
        * @param encoding the character encoding schema used by the font
        * @return the generated PDFFont object
        */
  -    public static PDFFont createFont(int number, String fontname,
  +    public static PDFFont createFont(String fontname,
                                        FontType subtype, String basefont,
                                        Object encoding) {
           if (subtype == FontType.TYPE0) {
  -            return new PDFFontType0(number, fontname, basefont,
  +            return new PDFFontType0(fontname, basefont,
                                       encoding);
           } else if ((subtype == FontType.TYPE1)
                   || (subtype == FontType.MMTYPE1)) {
  -            return new PDFFontType1(number, fontname, basefont,
  +            return new PDFFontType1(fontname, basefont,
                                       encoding);
           } else if (subtype == FontType.TYPE3) {
               //return new PDFFontType3(number, fontname, basefont, encoding);
               return null; //NYI
           } else if (subtype == FontType.TRUETYPE) {
  -            return new PDFFontTrueType(number, fontname, basefont,
  +            return new PDFFontTrueType(fontname, basefont,
                                          encoding);
           } else {
               return null;    // should not happend
  @@ -152,7 +150,6 @@
        * factory method with the extended parameters
        * for Type1, MMType1 and TrueType
        *
  -     * @param number the object's number
        * @param fontname the internal name for the font
        * @param subtype the font's subtype
        * @param basefont the base font name
  @@ -163,7 +160,7 @@
        * @param descriptor the descriptor for other font's metrics
        * @return the generated PDFFont object
        */
  -    public static PDFFont createFont(int number, String fontname,
  +    public static PDFFont createFont(String fontname,
                                        FontType subtype, String basefont,
                                        Object encoding, int firstChar,
                                        int lastChar, PDFArray widths,
  @@ -171,13 +168,13 @@
   
           PDFFontNonBase14 font;
           if (subtype == FontType.TYPE0) {
  -            font = new PDFFontType0(number, fontname, basefont,
  +            font = new PDFFontType0(fontname, basefont,
                                       encoding);
               font.setDescriptor(descriptor);
               return font;
           } else if ((subtype == FontType.TYPE1) 
                   || (subtype == FontType.MMTYPE1)) {
  -            font = new PDFFontType1(number, fontname, basefont,
  +            font = new PDFFontType1(fontname, basefont,
                                       encoding);
               font.setWidthMetrics(firstChar, lastChar, widths);
               font.setDescriptor(descriptor);
  @@ -185,7 +182,7 @@
           } else if (subtype == FontType.TYPE3) {
               return null; //NYI, should not happend
           } else if (subtype == FontType.TRUETYPE) {
  -            font = new PDFFontTrueType(number, fontname, basefont,
  +            font = new PDFFontTrueType(fontname, basefont,
                                          encoding);
               font.setWidthMetrics(firstChar, lastChar, widths);
               font.setDescriptor(descriptor);
  @@ -225,15 +222,14 @@
       }
   
       /**
  -     * Produce the PDF representation for the object
  -     *
  -     * @return the PDF
  +     * @see org.apache.fop.pdf.PDFObject#toPDFString()
        */
  -    public byte[] toPDF() {
  -        StringBuffer p = new StringBuffer();
  -        p.append(this.number + " " + this.generation
  -                 + " obj\n<< /Type /Font\n/Subtype /"
  -                 + getPDFNameForFontType(this.subtype) + "\n/Name /" + this.fontname
  +    public String toPDFString() {
  +        StringBuffer p = new StringBuffer(128);
  +        p.append(getObjectID());
  +        p.append("<< /Type /Font\n/Subtype /"
  +                 + getPDFNameForFontType(this.subtype)
  +                 + "\n/Name /" + this.fontname
                    + "\n/BaseFont /" + this.basefont);
           if (encoding != null) {
               p.append("\n/Encoding ");
  @@ -247,7 +243,7 @@
           }
           fillInPDF(p);
           p.append(" >>\nendobj\n");
  -        return p.toString().getBytes();
  +        return p.toString();
       }
   
       /**
  
  
  
  1.2       +2 -3      xml-fop/src/java/org/apache/fop/pdf/PDFFontType1.java
  
  Index: PDFFontType1.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFFontType1.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFFontType1.java 11 Mar 2003 13:05:09 -0000      1.1
  +++ PDFFontType1.java 27 Mar 2003 10:32:22 -0000      1.2
  @@ -67,17 +67,16 @@
       /**
        * Create the /Font object
        *
  -     * @param number the object's number
        * @param fontname the internal name for the font
        * @param basefont the base font name
        * @param encoding the character encoding schema used by the font
        */
  -    public PDFFontType1(int number, String fontname, 
  +    public PDFFontType1(String fontname, 
                           String basefont,
                           Object encoding) {
   
           /* generic creation of PDF object */
  -        super(number, fontname, FontType.TYPE1, basefont, encoding);
  +        super(fontname, FontType.TYPE1, basefont, encoding);
       }
   
   }
  
  
  
  1.2       +2 -3      xml-fop/src/java/org/apache/fop/pdf/PDFFontNonBase14.java
  
  Index: PDFFontNonBase14.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFFontNonBase14.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFFontNonBase14.java     11 Mar 2003 13:05:09 -0000      1.1
  +++ PDFFontNonBase14.java     27 Mar 2003 10:32:22 -0000      1.2
  @@ -81,18 +81,17 @@
       /**
        * Create the /Font object
        *
  -     * @param number the object's number
        * @param fontname the internal name for the font
        * @param subtype the font's subtype
        * @param basefont the base font name
        * @param encoding the character encoding schema used by the font
        */
  -    public PDFFontNonBase14(int number, String fontname, FontType subtype,
  +    public PDFFontNonBase14(String fontname, FontType subtype,
                               String basefont,
                               Object encoding) {
   
           /* generic creation of PDF object */
  -        super(number, fontname, subtype, basefont, encoding);
  +        super(fontname, subtype, basefont, encoding);
   
           this.descriptor = null;
       }
  
  
  

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

Reply via email to