encoding = fontEncoding;
Encoding base = null;
if (encoding.containsKey(COSName.BASE_ENCODING))
{
COSName name = encoding.getCOSName(COSName.BASE_ENCODING);
base = Encoding.getInstance(name); // may be null
}
if (base == null)
{
if (isNonSymbolic)
{
// Otherwise, for a nonsymbolic font, it is StandardEncoding
base = StandardEncoding.INSTANCE;
}
else
{
// and for a symbolic font, it is the font's built-in encoding.
if (builtIn != null)
{
base = builtIn;
}
else
{
base = StandardEncoding.INSTANCE;
LOG.warn("Built-in encoding required for symbolic font, using standard encoding");
//FIXME, see PDFBOX-2299, happens with Type3 fonts of the isartor test suite
// throw new IllegalArgumentException("Built-in Encoding required for symbolic font");
}
}
}
baseEncoding = base;
codeToName.putAll( baseEncoding.codeToName );
names.addAll( baseEncoding.names );
// now replace with the differences
COSArray differences = (COSArray)encoding.getDictionaryObject( COSName.DIFFERENCES );
int currentIndex = -1;
for( int i=0; differences != null && i<differences.size(); i++ )
{
COSBase next = differences.getObject( i );
if( next instanceof COSNumber )
{
currentIndex = ((COSNumber)next).intValue();
}
else if( next instanceof COSName )
{
COSName name = (COSName)next;
add(currentIndex, name.getName());
this.differences.put(currentIndex, name.getName());
currentIndex++;
}
}
}