private long writeTableHeader(DataOutputStream out, String tag, long offset, byte[] bytes) throws IOException { long checksum = 0; for (int nup = 0, n = bytes.length; nup < n; nup++) { checksum += (bytes[nup] & 0xffL) << 24 - nup % 4 * 8; } checksum &= 0xffffffffL; byte[] tagbytes = tag.getBytes("US-ASCII"); out.write(tagbytes, 0, 4); out.writeInt((int)checksum); out.writeInt((int)offset); out.writeInt(bytes.length); // account for the checksum twice, once for the header field, once for the content itself return toUInt32(tagbytes) + checksum + checksum + offset + bytes.length; }
/** * @param out The data output stream. * @param nTables The number of table. * @return The file offset of the first TTF table to write. * @throws IOException Upon errors. */ private long writeFileHeader(DataOutputStream out, int nTables) throws IOException { out.writeInt(0x00010000); out.writeShort(nTables); int mask = Integer.highestOneBit(nTables); int searchRange = mask * 16; out.writeShort(searchRange); int entrySelector = log2(mask); out.writeShort(entrySelector); // numTables * 16 - searchRange int last = 16 * nTables - searchRange; out.writeShort(last); return 0x00010000L + toUInt32(nTables, searchRange) + toUInt32(entrySelector, last); }
private long writeTableHeader(DataOutputStream out, String tag, long offset, byte[] bytes) throws IOException { long checksum = 0; for (int nup = 0, n = bytes.length; nup < n; nup++) { checksum += (bytes[nup] & 0xffL) << 24 - nup % 4 * 8; } checksum &= 0xffffffffL; byte[] tagbytes = tag.getBytes("US-ASCII"); out.write(tagbytes, 0, 4); out.writeInt((int)checksum); out.writeInt((int)offset); out.writeInt(bytes.length); // account for the checksum twice, once for the header field, once for the content itself return toUInt32(tagbytes) + checksum + checksum + offset + bytes.length; }
private long writeTableHeader(DataOutputStream out, String tag, long offset, byte[] bytes) throws IOException { long checksum = 0; for (int nup = 0, n = bytes.length; nup < n; nup++) { checksum += (bytes[nup] & 0xffL) << 24 - nup % 4 * 8; } checksum &= 0xffffffffL; byte[] tagbytes = tag.getBytes("US-ASCII"); out.write(tagbytes, 0, 4); out.writeInt((int)checksum); out.writeInt((int)offset); out.writeInt(bytes.length); // account for the checksum twice, once for the header field, once for the content itself return toUInt32(tagbytes) + checksum + checksum + offset + bytes.length; }
/** * @param out The data output stream. * @param nTables The number of table. * @return The file offset of the first TTF table to write. * @throws IOException Upon errors. */ private long writeFileHeader(DataOutputStream out, int nTables) throws IOException { out.writeInt(0x00010000); out.writeShort(nTables); int mask = Integer.highestOneBit(nTables); int searchRange = mask * 16; out.writeShort(searchRange); int entrySelector = log2(mask); out.writeShort(entrySelector); // numTables * 16 - searchRange int last = 16 * nTables - searchRange; out.writeShort(last); return 0x00010000L + toUInt32(nTables, searchRange) + toUInt32(entrySelector, last); }
/** * @param out The data output stream. * @param nTables The number of table. * @return The file offset of the first TTF table to write. * @throws IOException Upon errors. */ private long writeFileHeader(DataOutputStream out, int nTables) throws IOException { out.writeInt(0x00010000); out.writeShort(nTables); int mask = Integer.highestOneBit(nTables); int searchRange = mask * 16; out.writeShort(searchRange); int entrySelector = log2(mask); out.writeShort(entrySelector); // numTables * 16 - searchRange int last = 16 * nTables - searchRange; out.writeShort(last); return 0x00010000L + toUInt32(nTables, searchRange) + toUInt32(entrySelector, last); }