Ejemplo n.º 1
0
 /**
  * Stores the next object of the XRef table. As soon as this method returns false, it makes no
  * longer sense calling it as all the objects have been stored.
  *
  * @return false if there are no objects left to check.
  */
 public boolean storeNextObject() {
   while (current < n) {
     current++;
     PdfObject object = reader.getPdfObjectRelease(current);
     if (object != null) {
       int idx = size();
       idxToRef.put(idx, current);
       refToIdx.put(current, idx);
       store(object);
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 2
0
 /**
  * Reads the kerning information from the 'kern' table.
  *
  * @throws IOException the font file could not be read
  */
 void readKerning() throws IOException {
   int table_location[];
   table_location = (int[]) positionTables.get("kern");
   if (table_location == null) return;
   rf.seek(table_location[0] + 2);
   int nTables = rf.readUnsignedShort();
   int checkpoint = table_location[0] + 4;
   int length = 0;
   for (int k = 0; k < nTables; ++k) {
     checkpoint += length;
     rf.seek(checkpoint);
     rf.skipBytes(2);
     length = rf.readUnsignedShort();
     int coverage = rf.readUnsignedShort();
     if ((coverage & 0xfff7) == 0x0001) {
       int nPairs = rf.readUnsignedShort();
       rf.skipBytes(6);
       for (int j = 0; j < nPairs; ++j) {
         int pair = rf.readInt();
         int value = ((int) rf.readShort() * 1000) / head.unitsPerEm;
         kerning.put(pair, value);
       }
     }
   }
 }
Ejemplo n.º 3
0
 /**
  * Gets the reference number in the xref table based on the index in the indirect object list.
  *
  * @param i the index of an object in the indirect object list
  * @return the corresponding reference number in the xref table
  */
 public int getRefByIndex(int i) {
   return idxToRef.get(i);
 }
Ejemplo n.º 4
0
 /**
  * Gets the index of an object based on its number in the xref table.
  *
  * @param ref a number in the xref table
  * @return the index in the list of indirect objects
  */
 public int getIndexByRef(int ref) {
   return refToIdx.get(ref);
 }