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 je...@apache.org on 2002/12/02 15:04:16 UTC

cvs commit: xml-fop/src/org/apache/fop/fonts/type1 PFBParser.java PFBData.java

jeremias    2002/12/02 06:04:16

  Modified:    src/org/apache/fop/fonts/type1 Tag: fop-0_20_2-maintain
                        PFBParser.java PFBData.java
  Log:
  Added missing APL header
  Improved style
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +40 -18    xml-fop/src/org/apache/fop/fonts/type1/Attic/PFBParser.java
  
  Index: PFBParser.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fonts/type1/Attic/PFBParser.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- PFBParser.java	29 Nov 2002 08:40:54 -0000	1.1.2.1
  +++ PFBParser.java	2 Dec 2002 14:04:16 -0000	1.1.2.2
  @@ -1,3 +1,9 @@
  +/*
  + * $Id$
  + * Copyright (C) 2002 The Apache Software Foundation. All rights reserved.
  + * For details on use and redistribution please refer to the
  + * LICENSE file included with these sources.
  + */
   package org.apache.fop.fonts.type1;
   
   import java.io.IOException;
  @@ -10,7 +16,7 @@
   
   /**
    * This class represents a parser for Adobe Type 1 PFB files.
  - * 
  + *
    * @see PFBData
    */
   public class PFBParser {
  @@ -85,11 +91,10 @@
   
   
       private static int swapInteger(final int value) {
  -        return
  -            (((value >> 0) & 0xff ) << 24) +
  -            (((value >> 8) & 0xff ) << 16) +
  -            (((value >> 16) & 0xff ) << 8) +
  -            (((value >> 24) & 0xff ) << 0);
  +        return (((value >> 0) & 0xff) << 24)
  +             + (((value >> 8) & 0xff) << 16)
  +             + (((value >> 16) & 0xff) << 8)
  +             + (((value >> 24) & 0xff) << 0);
       }
   
   
  @@ -100,45 +105,61 @@
   
           //Read first segment
           segmentHead = din.readUnsignedByte();
  -        if (segmentHead != 128) throw new IOException("Invalid file format. Expected ASCII 80hex");
  +        if (segmentHead != 128) {
  +            throw new IOException("Invalid file format. Expected ASCII 80hex");
  +        }
           segmentType = din.readUnsignedByte(); //Read
           int len1 = swapInteger(din.readInt());
           byte[] headerSegment = new byte[len1];
           bytesRead = din.read(headerSegment);
  -        if (bytesRead != len1) throw new IOException("Could not load the whole segment");
  +        if (bytesRead != len1) {
  +            throw new IOException("Could not load the whole segment");
  +        }
           pfb.setHeaderSegment(headerSegment);
   
           //Read second segment
           segmentHead = din.readUnsignedByte();
  -        if (segmentHead != 128) throw new IOException("Invalid file format. Expected ASCII 80hex");
  +        if (segmentHead != 128) {
  +            throw new IOException("Invalid file format. Expected ASCII 80hex");
  +        }
           segmentType = din.readUnsignedByte();
           int len2 = swapInteger(din.readInt());
           byte[] encryptedSegment = new byte[len2];
           bytesRead = din.read(encryptedSegment);
  -        if (bytesRead != len2) throw new IOException("Could not load the whole segment");
  +        if (bytesRead != len2) {
  +            throw new IOException("Could not load the whole segment");
  +        }
           pfb.setEncryptedSegment(encryptedSegment);
   
           //Read third segment
           segmentHead = din.readUnsignedByte();
  -        if (segmentHead != 128) throw new IOException("Invalid file format. Expected ASCII 80hex");
  +        if (segmentHead != 128) {
  +            throw new IOException("Invalid file format. Expected ASCII 80hex");
  +        }
           segmentType = din.readUnsignedByte();
           int len3 = swapInteger(din.readInt());
           byte[] trailerSegment = new byte[len3];
           bytesRead = din.read(trailerSegment);
  -        if (bytesRead != len3) throw new IOException("Could not load the whole segment");
  +        if (bytesRead != len3) {
  +            throw new IOException("Could not load the whole segment");
  +        }
           pfb.setTrailerSegment(trailerSegment);
   
           //Read EOF indicator
           segmentHead = din.readUnsignedByte();
  -        if (segmentHead != 128) throw new IOException("Invalid file format. Expected ASCII 80hex");
  +        if (segmentHead != 128) {
  +            throw new IOException("Invalid file format. Expected ASCII 80hex");
  +        }
           segmentType = din.readUnsignedByte();
  -        if (segmentType != 3) throw new IOException("Expected segment type 3, but found: "+segmentType);
  +        if (segmentType != 3) {
  +            throw new IOException("Expected segment type 3, but found: " + segmentType);
  +        }
       }
   
   
  -    private final static boolean byteCmp(byte[] src, int srcOffset, byte[] cmp) {
  +    private static final boolean byteCmp(byte[] src, int srcOffset, byte[] cmp) {
           for (int i = 0; i < cmp.length; i++) {
  -            // System.out.println("Compare: "+src[srcOffset+i]+" "+cmp[i]);
  +            // System.out.println("Compare: " + src[srcOffset + i] + " " + cmp[i]);
               if (src[srcOffset + i] != cmp[i]) {
                   return false;
               }
  @@ -199,11 +220,12 @@
           pfb.setEncryptedSegment(buffer);
   
           buffer = new byte[len3];
  -        System.arraycopy(originalData, len1+len2, buffer, 0, len3);
  +        System.arraycopy(originalData, len1 + len2, buffer, 0, len3);
           pfb.setTrailerSegment(buffer);
       }
   
  -    private void parseRAWFormat(PFBData pfb, BufferedInputStream bin) throws IOException {
  +    private void parseRAWFormat(PFBData pfb, BufferedInputStream bin)
  +            throws IOException {
           calcLengths(pfb, IOUtil.toByteArray(bin, 32768));
       }
   
  
  
  
  1.1.2.2   +7 -1      xml-fop/src/org/apache/fop/fonts/type1/Attic/PFBData.java
  
  Index: PFBData.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fonts/type1/Attic/PFBData.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- PFBData.java	29 Nov 2002 08:40:54 -0000	1.1.2.1
  +++ PFBData.java	2 Dec 2002 14:04:16 -0000	1.1.2.2
  @@ -1,3 +1,9 @@
  +/*
  + * $Id$
  + * Copyright (C) 2002 The Apache Software Foundation. All rights reserved.
  + * For details on use and redistribution please refer to the
  + * LICENSE file included with these sources.
  + */
   package org.apache.fop.fonts.type1;
   
   import java.io.OutputStream;
  @@ -44,7 +50,7 @@
               case PFB_MAC:
                   throw new UnsupportedOperationException("Mac format is not yet implemented");
               default:
  -                throw new IllegalArgumentException("Invalid value for PFB format: "+format);
  +                throw new IllegalArgumentException("Invalid value for PFB format: " + format);
           }
       }
   
  
  
  

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