// to the pdf and consequently the StandardEncoding is used so that any special character is
// missing I've copied the code from the pdfbox-forum posted by V0JT4 and made some additions
// 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"));