/** * @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); }
int searchRange = 2 * (int)Math.pow(2, log2(segCount)); writeUint16(out, 4); // format writeUint16(out, 8 * 2 + segCount * 4*2); // length writeUint16(out, segCount * 2); // segCountX2 writeUint16(out, log2(searchRange / 2)); // entrySelector writeUint16(out, 2 * segCount - searchRange); // rangeShift
/** * @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); }
int searchRange = 2 * (int)Math.pow(2, log2(segCount)); writeUint16(out, 4); // format writeUint16(out, 8 * 2 + segCount * 4*2); // length writeUint16(out, segCount * 2); // segCountX2 writeUint16(out, log2(searchRange / 2)); // entrySelector writeUint16(out, 2 * segCount - searchRange); // rangeShift
int searchRange = 2 * (int)Math.pow(2, log2(segCount)); writeUint16(out, 4); // format writeUint16(out, 8 * 2 + segCount * 4*2); // length writeUint16(out, segCount * 2); // segCountX2 writeUint16(out, log2(searchRange / 2)); // entrySelector writeUint16(out, 2 * segCount - searchRange); // rangeShift