// concerning german umlauts see also https://sourceforge.net/forum/message.php?msg_id=4705274
private DictionaryEncoding encodingFromAFM(FontMetrics metrics) throws IOException
{
Type1Encoding encoding = new Type1Encoding(metrics);
COSArray differences = new COSArray();
differences.add(COSInteger.ZERO);
for (int i = 0; i < 256; i++)
{
differences.add(COSName.getPDFName(encoding.getName(i)));
}
// my AFMPFB-Fonts has no character-codes for german umlauts
// so that I've to add them here by hand
differences.set(0337 + 1, COSName.getPDFName("germandbls"));
differences.set(0344 + 1, COSName.getPDFName("adieresis"));
differences.set(0366 + 1, COSName.getPDFName("odieresis"));
differences.set(0374 + 1, COSName.getPDFName("udieresis"));
differences.set(0304 + 1, COSName.getPDFName("Adieresis"));
differences.set(0326 + 1, COSName.getPDFName("Odieresis"));
differences.set(0334 + 1, COSName.getPDFName("Udieresis"));
return new DictionaryEncoding(COSName.STANDARD_ENCODING, differences);
}