PDTrueTypeFontEmbedder(PDDocument document, COSDictionary dict, InputStream ttfStream)
throws IOException
{
dict.setItem(COSName.SUBTYPE, COSName.TRUE_TYPE);
PDStream stream = new PDStream(document, ttfStream, false);
stream.getStream().setInt(COSName.LENGTH1, stream.getByteArray().length); // todo: wrong?
stream.addCompression();
// only support winansi encoding right now, should really
// just use Identity-H with unicode mapping
Encoding encoding = new WinAnsiEncoding(); // fixme: read encoding from TTF
this.fontEncoding = encoding;
dict.setItem(COSName.ENCODING, encoding.getCOSObject());
// as the stream was close within the PDStream constructor, we have to recreate it
InputStream stream2 = null;
PDFontDescriptor fd;
try
{
stream2 = stream.createInputStream();
ttf = new TTFParser().parse(stream2);
fd = createFontDescriptor(dict, ttf);
}
finally
{