{
//This whole section of code needs to be replaced with an actual
//type1 font parser!!
COSName retvalue = null;
//recuperer le programme de fonte dans son stream qui doit se trouver
//dans le flux r�f�renc� par � la cl� FileFont lui m�me situ� dans
//le dictionnaire associ� � /FontDescriptor du dictionnaire de type /Font courrant
//get the font program in the stream which should be located in
//the /FileFont Stream object himself in the /FontDescriptior of the current
//font dictionary
COSDictionary fontDescriptor = (COSDictionary) font.getDictionaryObject(
COSName.FONT_DESC);
if( fontDescriptor != null )
{
COSStream fontFile = (COSStream) fontDescriptor.getDictionaryObject(
COSName.FONT_FILE);
if( fontFile != null )
{
BufferedReader in =
new BufferedReader(new InputStreamReader(fontFile.getUnfilteredStream()));
/**
* this section parse the FileProgram stream searching for a /Encoding entry
* the research stop if the entry "currentdict end" is reach or after 100 lignes
*/
StringTokenizer st = null;
boolean found = false;
String line = "";
String key = null;
for( int i = 0; null!=( line = in.readLine() ) &&
i < 40 &&
!line.equals("currentdict end")
&& !found; i++)
{
st = new StringTokenizer(line);
if( st.hasMoreTokens() )
{
key = st.nextToken();
if(key.equals("/Encoding") && st.hasMoreTokens() )
{
COSName value = COSName.getPDFName( st.nextToken() );
found = true;
if( value.equals( COSName.MAC_ROMAN_ENCODING ) ||
value.equals( COSName.PDF_DOC_ENCODING ) ||
value.equals( COSName.STANDARD_ENCODING ) ||
value.equals( COSName.WIN_ANSI_ENCODING ) )
{
//value is expected to be one of the encodings
//ie. StandardEncoding,WinAnsiEncoding,MacRomanEncoding,PDFDocEncoding
retvalue = value;
}