예제 #1
0
파일: Font.java 프로젝트: runt18/sfntly
 private void loadFont(InputStream is) throws IOException {
   if (is == null) {
     throw new IOException("No input stream for font.");
   }
   FontInputStream fontIS = null;
   try {
     fontIS = new FontInputStream(is);
     SortedSet<Header> records = readHeader(fontIS);
     this.dataBlocks = loadTableData(records, fontIS);
     this.tableBuilders = buildAllTableBuilders(this.dataBlocks);
   } finally {
     fontIS.close();
   }
 }
예제 #2
0
파일: Font.java 프로젝트: runt18/sfntly
 private Map<Header, WritableFontData> loadTableData(
     SortedSet<Header> headers, FontInputStream is) throws IOException {
   Map<Header, WritableFontData> tableData =
       new HashMap<Header, WritableFontData>(headers.size());
   logger.fine("########  Reading Table Data");
   for (Header tableHeader : headers) {
     is.skip(tableHeader.offset() - is.position());
     logger.finer("\t" + tableHeader);
     logger.finest("\t\tStream Position = " + Integer.toHexString((int) is.position()));
     // don't close this or the whole stream is gone
     FontInputStream tableIS = new FontInputStream(is, tableHeader.length());
     // TODO(stuartg): start tracking bad tables and other errors
     WritableFontData data = WritableFontData.createWritableFontData(tableHeader.length());
     data.copyFrom(tableIS, tableHeader.length());
     tableData.put(tableHeader, data);
   }
   return tableData;
 }
예제 #3
0
파일: Font.java 프로젝트: runt18/sfntly
    private SortedSet<Header> readHeader(FontInputStream is) throws IOException {
      SortedSet<Header> records = new TreeSet<Header>(Header.COMPARATOR_BY_OFFSET);

      this.sfntVersion = is.readFixed();
      this.numTables = is.readUShort();
      this.searchRange = is.readUShort();
      this.entrySelector = is.readUShort();
      this.rangeShift = is.readUShort();

      for (int tableNumber = 0; tableNumber < this.numTables; tableNumber++) {
        Header table =
            new Header(
                is.readULongAsInt(), // safe since the tag is ASCII
                is.readULong(), // checksum
                is.readULongAsInt(), // offset
                is.readULongAsInt()); // length
        records.add(table);
      }
      return records;
    }