Save This Page
Home » pdfbox-1.1.0-src » org.apache.fontbox.cff » [javadoc | source]
    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.fontbox.cff;
   18   
   19   import java.io.IOException;
   20   
   21   /**
   22    * This is specialized DataInput. It's used to parse a CFFFont.
   23    * 
   24    * @author Villu Ruusmann
   25    * @version $Revision$
   26    */
   27   public class CFFDataInput extends DataInput
   28   {
   29   
   30       /**
   31        * Constructor.
   32        * @param buffer the buffer to be read 
   33        */
   34       public CFFDataInput(byte[] buffer)
   35       {
   36           super(buffer);
   37       }
   38   
   39       /**
   40        * Read one single Card8 value from the buffer. 
   41        * @return the card8 value
   42        * @throws IOException if an error occurs during reading
   43        */
   44       public int readCard8() throws IOException
   45       {
   46           return readUnsignedByte();
   47       }
   48   
   49       /**
   50        * Read one single Card16 value from the buffer.
   51        * @return the card16 value
   52        * @throws IOException if an error occurs during reading
   53        */
   54       public int readCard16() throws IOException
   55       {
   56           return readUnsignedShort();
   57       }
   58   
   59       /**
   60        * Read the offset from the buffer.
   61        * @param offSize the given offsize
   62        * @return the offset
   63        * @throws IOException if an error occurs during reading
   64        */
   65       public int readOffset(int offSize) throws IOException
   66       {
   67           int value = 0;
   68           for (int i = 0; i < offSize; i++)
   69           {
   70               value = value << 8 | readUnsignedByte();
   71           }
   72           return value;
   73       }
   74   
   75       /**
   76        * Read the offsize from the buffer.
   77        * @return the offsize
   78        * @throws IOException if an error occurs during reading
   79        */
   80       public int readOffSize() throws IOException
   81       {
   82           return readUnsignedByte();
   83       }
   84   
   85       /**
   86        * Read a SID from the buffer.
   87        * @return the SID
   88        * @throws IOException if an error occurs during reading
   89        */
   90       public int readSID() throws IOException
   91       {
   92           return readUnsignedShort();
   93       }
   94   }

Save This Page
Home » pdfbox-1.1.0-src » org.apache.fontbox.cff » [javadoc | source]