cachedValue=new String[65536];
String CMapName=null;
/**read encoding values*/
PdfObject Encoding=pdfObject.getDictionary(PdfDictionary.Encoding);
if(Encoding!=null)
CMapName=handleCIDEncoding(Encoding);
//handle to unicode mapping
PdfObject ToUnicode=pdfObject.getDictionary(PdfDictionary.ToUnicode);
if(ToUnicode!=null)
unicodeMappings=new UnicodeReader(currentPdfFile.readStream(ToUnicode,true,true,false, false,false, ToUnicode.getCacheName(currentPdfFile.getObjectReader()))).readUnicode();
/**read widths*/
//@speed may need optimising - done as string for moment
String widths=Descendent.getName(PdfDictionary.W);
//allow for vertical
String verticalWidths=Descendent.getName(PdfDictionary.W2);
if(verticalWidths!=null){
widths=verticalWidths;
}
if(widths!=null)
setCIDFontWidths(widths);
/**set default width*/
int Width=Descendent.getInt(PdfDictionary.DW);
if(Width>=0)
defaultWidth=(Width)/1000f;
/**set CIDtoGIDMap*/
PdfObject CIDToGID=Descendent.getDictionary(PdfDictionary.CIDToGIDMap);
if(CIDToGID!=null){
byte[] stream=currentPdfFile.readStream(CIDToGID,true,true,false, false,false, null);
if(stream!=null){
int j=0,count=stream.length;
int[] CIDToGIDMap=new int[count/2];
for(int i=0;i<count;i=i+2){
CIDToGIDMap[j]= (((stream[i] & 255)<<8)+(stream[i+1] & 255));
j++;
}
glyphs.setGIDtoCID(CIDToGIDMap);
}else{ // must be identity
//only set if not also a /value
if(CIDToGID.getParameterConstant(PdfDictionary.CIDToGIDMap)==PdfDictionary.Unknown)
CMapName=handleCIDEncoding(new FontObject(PdfDictionary.Identity_H));
}
}
//@sam-fonts
//code is unfinished by MArk - I was originally going to map onto font in
//cid.jar but now think that is wrong
//
//Needs researching and doing properly
String ordering=null;
PdfObject CIDSystemInfo=Descendent.getDictionary(PdfDictionary.CIDSystemInfo);
if(CIDSystemInfo!=null)
ordering=CIDSystemInfo.getTextStreamValue(PdfDictionary.Ordering);
if(ordering!=null){
if(CIDToGID==null && ordering.contains("Identity")){
if(CMapName!=null && !CMapName.equals("Generic"))
isDoubleByte=true;
}else if(ordering.contains("Japan")){
substituteFontFile="kochi-mincho.ttf";
substituteFontName="Kochi Mincho";
this.TTstreamisCID=false;
}else if(ordering.contains("Korean")){
System.err.println("Unsupported font encoding "+ordering);
}else if(ordering.contains("Chinese")){
System.err.println("Chinese "+ordering);
}else if(ordering.equals("Identity")){
glyphs.setIsIdentity(true);
}
if(substituteFontName!=null && LogWriter.isOutput())
LogWriter.writeLog("Using font "+substituteFontName+" for "+ordering);
}
/**set other values*/
if (Descendent != null) {
PdfObject FontDescriptor = Descendent.getDictionary(PdfDictionary.FontDescriptor);
/**read other info*/
if(FontDescriptor!=null) {
setBoundsAndMatrix(FontDescriptor);
setName( FontDescriptor, fontID);