/** * Is the font ready to build? * * @return true if ready to build; false otherwise */ public boolean readyToBuild() { // just read in data with no manipulation if (this.tableBuilders == null && this.dataBlocks != null && this.dataBlocks.size() > 0) { return true; } for (Table.Builder<? extends Table> tableBuilder : this.tableBuilders.values()) { if (tableBuilder.readyToBuild() == false) { return false; } } return true; }
private static Map<Integer, Table> buildTablesFromBuilders( Font font, Map<Integer, Table.Builder<? extends Table>> builderMap) { Map<Integer, Table> tableMap = new TreeMap<Integer, Table>(); interRelateBuilders(builderMap); long fontChecksum = 0; boolean tablesChanged = false; FontHeaderTable.Builder headerTableBuilder = null; // now build all the tables for (Table.Builder<? extends Table> builder : builderMap.values()) { Table table = null; if (Tag.isHeaderTable(builder.header().tag())) { headerTableBuilder = (FontHeaderTable.Builder) builder; continue; } if (builder.readyToBuild()) { tablesChanged |= builder.changed(); table = builder.build(); } if (table == null) { throw new RuntimeException("Unable to build table - " + builder); } long tableChecksum = table.calculatedChecksum(); fontChecksum += tableChecksum; tableMap.put(table.header().tag(), table); } // now fix up the header table Table headerTable = null; if (headerTableBuilder != null) { if (tablesChanged) { headerTableBuilder.setFontChecksum(fontChecksum); } if (headerTableBuilder.readyToBuild()) { tablesChanged |= headerTableBuilder.changed(); headerTable = headerTableBuilder.build(); } if (headerTable == null) { throw new RuntimeException("Unable to build table - " + headerTableBuilder); } fontChecksum += headerTable.calculatedChecksum(); tableMap.put(headerTable.header().tag(), headerTable); } font.checksum = fontChecksum & 0xffffffffL; return tableMap; }