@Override
public String toUnicode(int code, GlyphList customGlyphList) throws IOException
{
// allow the glyph list to be overridden for the purpose of extracting Unicode
// we only do this when the font's glyph list is the AGL, to avoid breaking Zapf Dingbats
GlyphList unicodeGlyphList;
if (this.glyphList == GlyphList.getAdobeGlyphList())
{
unicodeGlyphList = customGlyphList;
}
else
{
unicodeGlyphList = this.glyphList;
}
// first try to use a ToUnicode CMap
String unicode = super.toUnicode(code);
if (unicode != null)
{
return unicode;
}
// if the font is a "simple font" and uses MacRoman/MacExpert/WinAnsi[Encoding]
// or has Differences with names from only Adobe Standard and/or Symbol, then:
//
// a) Map the character codes to names
// b) Look up the name in the Adobe Glyph List to obtain the Unicode value
String name = null;
if (encoding != null)
{
name = encoding.getName(code);
unicode = unicodeGlyphList.toUnicode(name);
if (unicode != null)
{
return unicode;
}
}