* @throws IOException If there is an error during the encoding.
*/
public String encode( byte[] c, int offset, int length ) throws IOException
{
String retval = null;
COSName fontSubtype = (COSName)font.getDictionaryObject( COSName.SUBTYPE );
String fontSubtypeName = fontSubtype.getName();
if( fontSubtypeName.equals( "Type0" ) ||
fontSubtypeName.equals( "Type1" ) ||
fontSubtypeName.equals( "TrueType" ))
{
if( cmap == null )
{
if( font.getDictionaryObject( COSName.TO_UNICODE ) != null )
{
COSStream toUnicode = (COSStream)font.getDictionaryObject( COSName.TO_UNICODE );
if( toUnicode != null )
{
parseCmap( toUnicode.getUnfilteredStream(), null );
}
}
else
{
COSBase encoding = font.getDictionaryObject( COSName.ENCODING );
if( encoding instanceof COSStream )
{
COSStream encodingStream = (COSStream)encoding;
parseCmap( encodingStream.getUnfilteredStream(), null );
}
else if( fontSubtypeName.equals( "Type0" ) &&
encoding instanceof COSName )
{
COSName encodingName = (COSName)encoding;
cmap = (CMap)cmapObjects.get( encodingName );
if( cmap != null )
{
cmap = (CMap)cmapObjects.get( encodingName );
}
else
{
String cmapName = encodingName.getName();
cmapName = performCMAPSubstitution( cmapName );
String resourceName = "Resources/cmap/" + cmapName;
parseCmap( ResourceLoader.loadResource( resourceName ), encodingName );
if( cmap == null && !encodingName.getName().equals( COSName.IDENTITY_H.getName() ) )
{
throw new IOException( "Error: Could not find predefined " +
"CMAP file for '" + encodingName.getName() + "'" );
}
}
}
else if( encoding instanceof COSName ||
encoding instanceof COSDictionary )