/** Creates a new instance of CMapFormat0 */ protected CMapFormat4(short language) { super((short) 4, language); segments = Collections.synchronizedSortedMap(new TreeMap<Segment,Object>()); char[] map = new char[1]; map[0] = (char) 0; addSegment((short) 0xffff, (short) 0xffff, map); }
/** * Get the rangeShift() */ public short getRangeShift() { return (short) ((2 * getSegmentCount()) - getSearchRange()); }
/** * Cannot map from a byte */ public byte map(byte src) { char c = map((char) src); if (c < Byte.MIN_VALUE || c > Byte.MAX_VALUE) { // out of range return 0; } return (byte) c; }
ByteBuffer buf = ByteBuffer.allocate(getLength()); buf.putShort(getFormat()); buf.putShort((short) getLength()); buf.putShort(getLanguage()); buf.putShort((short) (getSegmentCount() * 2)); buf.putShort(getSearchRange()); buf.putShort(getEntrySelector()); buf.putShort(getRangeShift()); int glyphArrayOffset = 16 + (8 * getSegmentCount());
/** Get a pretty string */ @Override public String toString() { StringBuffer buf = new StringBuffer(); String indent = " "; buf.append(super.toString()); buf.append(indent + "SegmentCount : " + getSegmentCount() + "\n"); buf.append(indent + "SearchRange : " + getSearchRange() + "\n"); buf.append(indent + "EntrySelector: " + getEntrySelector() + "\n"); buf.append(indent + "RangeShift : " + getRangeShift() + "\n"); for (Iterator i = segments.keySet().iterator(); i.hasNext();) { Segment s = (Segment) i.next(); buf.append(indent); buf.append("Segment: " + Integer.toHexString(s.startCode)); buf.append("-" + Integer.toHexString(s.endCode) + " "); buf.append("hasMap: " + s.hasMap + " "); if (!s.hasMap) { buf.append("delta: " + segments.get(s)); } buf.append("\n"); } return buf.toString(); }
fourMap.addSegment ((short) getFirstChar (), (short) getLastChar (), (short) 0); fourMap.addSegment ((short) 0, (short) 1, (short) 0); fourMap.addSegment ((short) i, (short) i, (short) (value - i)); short value = (short) fourMap.map (controlChars[i]); fourMap.addSegment (idx, idx, (short) (value - idx));
/** * Get the entry selector */ public short getEntrySelector() { int sr2 = getSearchRange() / 2; return (short) (Math.log(sr2) / Math.log(2)); }
/** * Get the search range */ public short getSearchRange() { double pow = Math.floor(Math.log(getSegmentCount()) / Math.log(2)); double pow2 = Math.pow(2, pow); return (short) (2 * pow2); }
break; case 4: // CMap format 4 - two byte encoding outMap = new CMapFormat4 (language); break; case 6: // CMap format 6 - 16-bit, two byte encoding
ByteBuffer buf = ByteBuffer.allocate(getLength()); buf.putShort(getFormat()); buf.putShort((short) getLength()); buf.putShort(getLanguage()); buf.putShort((short) (getSegmentCount() * 2)); buf.putShort(getSearchRange()); buf.putShort(getEntrySelector()); buf.putShort(getRangeShift()); int glyphArrayOffset = 16 + (8 * getSegmentCount());
/** Get a pretty string */ @Override public String toString() { StringBuffer buf = new StringBuffer(); String indent = " "; buf.append(super.toString()); buf.append(indent + "SegmentCount : " + getSegmentCount() + "\n"); buf.append(indent + "SearchRange : " + getSearchRange() + "\n"); buf.append(indent + "EntrySelector: " + getEntrySelector() + "\n"); buf.append(indent + "RangeShift : " + getRangeShift() + "\n"); for (Iterator i = segments.keySet().iterator(); i.hasNext();) { Segment s = (Segment) i.next(); buf.append(indent); buf.append("Segment: " + Integer.toHexString(s.startCode)); buf.append("-" + Integer.toHexString(s.endCode) + " "); buf.append("hasMap: " + s.hasMap + " "); if (!s.hasMap) { buf.append("delta: " + segments.get(s)); } buf.append("\n"); } return buf.toString(); }
fourMap.addSegment ((short) getFirstChar (), (short) getLastChar (), (short) 0); fourMap.addSegment ((short) 0, (short) 1, (short) 0); fourMap.addSegment ((short) i, (short) i, (short) (value - i)); short value = (short) fourMap.map (controlChars[i]); fourMap.addSegment (idx, idx, (short) (value - idx));
/** * Get the entry selector */ public short getEntrySelector() { int sr2 = getSearchRange() / 2; return (short) (Math.log(sr2) / Math.log(2)); }
/** * Get the search range */ public short getSearchRange() { double pow = Math.floor(Math.log(getSegmentCount()) / Math.log(2)); double pow2 = Math.pow(2, pow); return (short) (2 * pow2); }
break; case 4: // CMap format 4 - two byte encoding outMap = new CMapFormat4 (language); break; case 6: // CMap format 6 - 16-bit, two byte encoding
ByteBuffer buf = ByteBuffer.allocate(getLength()); buf.putShort(getFormat()); buf.putShort((short) getLength()); buf.putShort(getLanguage()); buf.putShort((short) (getSegmentCount() * 2)); buf.putShort(getSearchRange()); buf.putShort(getEntrySelector()); buf.putShort(getRangeShift()); int glyphArrayOffset = 16 + (8 * getSegmentCount());
/** Get a pretty string */ @Override public String toString() { StringBuffer buf = new StringBuffer(); String indent = " "; buf.append(super.toString()); buf.append(indent + "SegmentCount : " + getSegmentCount() + "\n"); buf.append(indent + "SearchRange : " + getSearchRange() + "\n"); buf.append(indent + "EntrySelector: " + getEntrySelector() + "\n"); buf.append(indent + "RangeShift : " + getRangeShift() + "\n"); for (Iterator i = segments.keySet().iterator(); i.hasNext();) { Segment s = (Segment) i.next(); buf.append(indent); buf.append("Segment: " + Integer.toHexString(s.startCode)); buf.append("-" + Integer.toHexString(s.endCode) + " "); buf.append("hasMap: " + s.hasMap + " "); if (!s.hasMap) { buf.append("delta: " + segments.get(s)); } buf.append("\n"); } return buf.toString(); }
/** * Get the rangeShift() */ public short getRangeShift() { return (short) ((2 * getSegmentCount()) - getSearchRange()); }
fourMap.addSegment ((short) getFirstChar (), (short) getLastChar (), (short) 0); fourMap.addSegment ((short) 0, (short) 1, (short) 0); fourMap.addSegment ((short) i, (short) i, (short) (value - i)); short value = (short) fourMap.map (controlChars[i]); fourMap.addSegment (idx, idx, (short) (value - idx));
/** Creates a new instance of CMapFormat0 */ protected CMapFormat4(short language) { super((short) 4, language); segments = Collections.synchronizedSortedMap(new TreeMap<Segment,Object>()); char[] map = new char[1]; map[0] = (char) 0; addSegment((short) 0xffff, (short) 0xffff, map); }