buf.putShort(getEntrySelector());
buf.putShort(getRangeShift());
// write the endCodes
for (Iterator<Segment> i = this.segments.keySet().iterator(); i.hasNext();) {
Segment s = i.next();
buf.putShort((short) s.endCode);
}
// write the pad
buf.putShort((short) 0);
// write the startCodes
for (Iterator<Segment> i = this.segments.keySet().iterator(); i.hasNext();) {
Segment s = i.next();
buf.putShort((short) s.startCode);
}
// write the idDeltas for segments using deltas
for (Iterator<Segment> i = this.segments.keySet().iterator(); i.hasNext();) {
Segment s = i.next();
if (!s.hasMap) {
Integer idDelta = (Integer) this.segments.get(s);
buf.putShort(idDelta.shortValue());
} else {
buf.putShort((short) 0);
}
}
// the start of the glyph array
int glyphArrayOffset = 16 + (8 * getSegmentCount());
// write the idRangeOffsets and maps for segments using maps
for (Iterator<Segment> i = this.segments.keySet().iterator(); i.hasNext();) {
Segment s = i.next();
if (s.hasMap) {
// first set the offset, which is the number of bytes from the
// current position to the current offset
buf.putShort((short) (glyphArrayOffset - buf.position()));