public static SingleSubst read(RandomAccessFileEmulator raf, int offset) throws IOException {
   SingleSubst s = null;
   raf.seek(offset);
   int format = raf.readUnsignedShort();
   if (format == 1) {
     s = new SingleSubstFormat1(raf, offset);
   } else if (format == 2) {
     s = new SingleSubstFormat2(raf, offset);
   }
   return s;
 }
Esempio n. 2
0
  protected CmapFormat4(RandomAccessFileEmulator raf) throws IOException {
    super(raf);
    format = 4;
    segCountX2 = raf.readUnsignedShort();
    segCount = segCountX2 / 2;
    endCode = new int[segCount];
    startCode = new int[segCount];
    idDelta = new int[segCount];
    idRangeOffset = new int[segCount];
    searchRange = raf.readUnsignedShort();
    entrySelector = raf.readUnsignedShort();
    rangeShift = raf.readUnsignedShort();
    last = -1;
    for (int i = 0; i < segCount; i++) {
      endCode[i] = raf.readUnsignedShort();
      if (endCode[i] > last) last = endCode[i];
    }
    raf.readUnsignedShort(); // reservePad
    for (int i = 0; i < segCount; i++) {
      startCode[i] = raf.readUnsignedShort();
      if ((i == 0) || (startCode[i] < first)) first = startCode[i];
    }
    for (int i = 0; i < segCount; i++) {
      idDelta[i] = raf.readUnsignedShort();
    }
    for (int i = 0; i < segCount; i++) {
      idRangeOffset[i] = raf.readUnsignedShort();
    }

    // Whatever remains of this header belongs in glyphIdArray
    int count = (length - 16 - (segCount * 8)) / 2;
    glyphIdArray = new int[count];
    for (int i = 0; i < count; i++) {
      glyphIdArray[i] = raf.readUnsignedShort();
    }
  }