示例#1
0
文件: Font.java 项目: runt18/sfntly
    /**
     * Creates a new table builder for the table type given by the table id tag. It makes a copy of
     * the data provided and uses that copy for the table.
     *
     * <p>This new table has been added to the font and will replace any existing builder for that
     * table.
     *
     * @param tag
     * @param srcData
     * @return new empty table of the type specified by tag; if tag is not known then a generic
     *     OpenTypeTable is returned
     */
    public Table.Builder<? extends Table> newTableBuilder(int tag, ReadableFontData srcData) {
      WritableFontData data;
      data = WritableFontData.createWritableFontData(srcData.length());
      // TODO(stuartg): take over original data instead?
      srcData.copyTo(data);

      Header header = new Header(tag, data.length());
      Table.Builder<? extends Table> builder = Table.Builder.getBuilder(header, data);

      this.tableBuilders.put(tag, builder);

      return builder;
    }
示例#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;
 }