*/
public Encoding getEncoding() throws IOException
{
if( fontEncoding == null )
{
EncodingManager manager = getEncodingManager();
COSBase encoding = getEncodingObject(); //font.getDictionaryObject( COSName.ENCODING );
if( encoding == null )
{
FontMetric metric = getAFM();
if( metric != null )
{
fontEncoding = new AFMEncoding( metric );
}
if( fontEncoding == null )
{
fontEncoding = manager.getStandardEncoding();
}
}
/**
* Si la cl� /Encoding existe dans le dictionnaire fonte il y a deux possibilit�s :
* 1er cas : elle est associ� � une reference contenant un dictionnaire de type encoding.
* Ce dictionnaire PDF est repr�sent� par un DictionaryEncoding.
* If the /Encoding Key does exist in the font dictionary, there are two cases :
* case one : The value associated with /Encoding is a reference to a dictionary.
* This dictionary is represented by an instance of DictionaryEncoding class
*/
else if( encoding instanceof COSDictionary )
{
COSDictionary encodingDic = (COSDictionary)encoding;
//Let's see if the encoding dictionary has a base encoding
//If it does not then we will attempt to get it from the font
//file
COSName baseEncodingName = (COSName) encodingDic.getDictionaryObject(
COSName.BASE_ENCODING);
//on ajoute une entr�e /BaseEncoding dans /Encoding uniquement si elle en est absente
//if not find in Encoding dictinary target, we try to find it from else where
if( baseEncodingName == null)
{
COSName fontEncodingFromFile = getEncodingFromFont();
encodingDic.setItem(
COSName.BASE_ENCODING,
fontEncodingFromFile );
}
fontEncoding = new DictionaryEncoding( encodingDic );
}
else if( encoding instanceof COSName )
{
if( !encoding.equals( COSName.IDENTITY_H ) )
{
fontEncoding = manager.getEncoding( (COSName)encoding );
}
}
else
{
throw new IOException( "Unexpected encoding type:" + encoding.getClass().getName() );