input.setPosition(fontDictOffset); byte[][] fdIndex = readIndexData(input); input.setPosition(privateOffset); int privateSize = privateEntry.getNumber(0).intValue(); DictData privateDict = readDictData(input, privateSize); if (localSubrOffset > 0) input.setPosition(privateOffset + localSubrOffset); privDict.put("Subrs", readIndexData(input)); input.setPosition(fdSelectPos); FDSelect fdSelect = readFDSelect(input, nrOfcharStrings, font);
break; default: input.setPosition(encodingId); encoding = readEncoding(input, charset); break; input.setPosition(privateOffset); int privateSize = privateEntry.getNumber(0).intValue(); DictData privateDict = readDictData(input, privateSize); if (localSubrOffset > 0) input.setPosition(privateOffset + localSubrOffset); font.addToPrivateDict("Subrs", readIndexData(input));
throw new IOException("OpenType fonts containing a true type font are not supported."); default: input.setPosition(0); break;
input.setPosition(charStringsOffset); byte[][] charStringsIndex = readIndexData(input); input.setPosition(charsetId); charset = readCharset(input, charStringsIndex.length, isCIDFont);
/** * Retrieves a number of bytes from the CFF data stream * @param offset The offset of the bytes to retrieve * @param length The number of bytes to retrieve * @return Returns a byte array of requested bytes * @throws IOException Throws an IO Exception if an error occurs */ private byte[] getCFFOffsetBytes(int offset, int length) throws IOException { cffData.setPosition(offset); return cffData.readBytes(length); }
/** * Reads a CFF index object are the specified offset position * @param offset The position of the index object to read * @return Returns an object representing the index * @throws IOException Throws an IO Exception if an error occurs */ public CFFIndexData readIndex(int offset) throws IOException { cffData.setPosition(offset); return readIndex(); }
/** * Parses the char string index from the CFF byte data * @return Returns the char string index object * @throws IOException Throws an IO Exception if an error occurs */ public CFFIndexData readCharStringIndex() throws IOException { int offset = topDict.get("CharStrings").getOperands().get(0).intValue(); cffData.setPosition(offset); return readIndex(); }
/** * Retrieves data from the index data * @param index The index position of the data to retrieve * @return Returns the byte data for the given index * @throws IOException Throws an IO Exception if an error occurs */ public byte[] getValue(int index) throws IOException { int oldPos = cffData.getPosition(); try { cffData.setPosition(dataLocation.getDataPosition() + (offsets[index] - 1)); return cffData.readBytes(offsets[index + 1] - offsets[index]); } finally { cffData.setPosition(oldPos); } }
public byte[] getByteData() throws IOException { int oldPos = cffData.getPosition(); try { cffData.setPosition(dataLocation.getDataPosition()); return cffData.readBytes(dataLocation.getDataLength()); } finally { cffData.setPosition(oldPos); } } }
public byte[] getPrivateDictData() throws IOException { int origPos = cffData.getPosition(); try { cffData.setPosition(dataLocation.getDataPosition()); return cffData.readBytes(dataLocation.getDataLength()); } finally { cffData.setPosition(origPos); } }
public byte[] getData() throws IOException { int origPos = cffData.getPosition(); try { cffData.setPosition(dataLocation.getDataPosition()); return cffData.readBytes(dataLocation.getDataLength()); } finally { cffData.setPosition(origPos); } }
private CFFIndexData readLocalIndexSubrs() throws IOException { CFFIndexData localSubrs = null; DICTEntry privateEntry = topDict.get("Private"); if (privateEntry != null) { int length = privateEntry.getOperands().get(0).intValue(); int offset = privateEntry.getOperands().get(1).intValue(); cffData.setPosition(offset); byte[] privateData = cffData.readBytes(length); Map<String, DICTEntry> privateDict = parseDictData(privateData); DICTEntry localSubrsEntry = privateDict.get("Subrs"); if (localSubrsEntry != null) { int localOffset = offset + localSubrsEntry.getOperands().get(0).intValue(); cffData.setPosition(localOffset); localSubrs = readIndex(); } } return localSubrs; }
private FDSelect readFDSelect() throws IOException { FDSelect fdSelect = null; DICTEntry fdSelectEntry = topDict.get("FDSelect"); if (fdSelectEntry != null) { int fdOffset = fdSelectEntry.getOperands().get(0).intValue(); cffData.setPosition(fdOffset); int format = cffData.readCard8(); switch (format) { case 0: fdSelect = readFormat0FDSelect(); break; case 3: fdSelect = readFormat3FDSelect(); break; default: } } return fdSelect; }
/** * Retrieves the SID for the given GID object * @param charsetOffset The offset of the charset data * @param gid The GID for which to retrieve the SID * @return Returns the SID as an integer */ public int getSIDFromGID(int charsetOffset, int gid) throws IOException { if (gid == 0) { return 0; } cffData.setPosition(charsetOffset); int charsetFormat = cffData.readCard8(); switch (charsetFormat) { case 0: //Adjust for .notdef character cffData.setPosition(cffData.getPosition() + (--gid * 2)); return cffData.readSID(); case 1: return getSIDFromGIDFormat(gid, 1); case 2: return getSIDFromGIDFormat(gid, 2); default: return 0; } }
private FontDict setFDData(DICTEntry privateFDEntry, FontDict newFontDict) throws IOException { int privateFDLength = privateFDEntry.getOperands().get(0).intValue(); int privateFDOffset = privateFDEntry.getOperands().get(1).intValue(); cffData.setPosition(privateFDOffset); byte[] privateDict = cffData.readBytes(privateFDLength); newFontDict.setPrivateDictData(privateFDOffset, privateFDLength); Map<String, DICTEntry> privateEntries = parseDictData(privateDict); DICTEntry subroutines = privateEntries.get("Subrs"); if (subroutines != null) { CFFIndexData localSubrs = readIndex(privateFDOffset + subroutines.getOperands().get(0).intValue()); newFontDict.setLocalSubrData(localSubrs); } else { newFontDict.setLocalSubrData(new CFFIndexData()); } return newFontDict; }
break; default: input.setPosition(encodingId); encoding = readEncoding(input, charset); break; input.setPosition(privateOffset); int privateSize = privateEntry.getNumber(0).intValue(); DictData privateDict = readDictData(input, privateSize); if (localSubrOffset > 0) input.setPosition(privateOffset + localSubrOffset); font.addToPrivateDict("Subrs", readIndexData(input));
break; default: input.setPosition(encodingId); encoding = readEncoding(input, charset); break; input.setPosition(privateOffset); int privateSize = privateEntry.getNumber(0).intValue(); DictData privateDict = readDictData(input, privateSize); if (localSubrOffset > 0) input.setPosition(privateOffset + localSubrOffset); font.addToPrivateDict("Subrs", readIndexData(input));
throw new IOException("OpenType fonts containing a true type font are not supported."); default: input.setPosition(0); break;
int dataSize = offsets[offsets.length - 1] - offsets[0]; cffData.setPosition(cffData.getPosition() + dataSize); setData(position, dataSize);