}
public PdfFont createFont(PdfObject pdfObject, String font_id, ObjectStore objectStoreStreamRef, boolean renderPage, ErrorTracker errorTracker, boolean isPrinting) throws PdfException {
PdfFont currentFontData=null;
/**
* allow for no actual object - ie /PDFdata/baseline_screens/debug/res.pdf
**/
//found examples with no type set so cannot rely on it
//int rawType=pdfObject.getParameterConstant(PdfDictionary.Type);
//if(rawType!=PdfDictionary.Font)
// return null;
baseFont="";
rawFontName=null;
subFont=null;
int fontType= PdfDictionary.Unknown;
origfontType=PdfDictionary.Unknown;
PdfObject descendantFont=pdfObject.getDictionary(PdfDictionary.DescendantFonts);
boolean isEmbedded= isFontEmbedded(pdfObject);
boolean isFontBroken=true; //ensure enters once
while(isFontBroken){ //will try to sub font if error in embedded
isFontBroken=false;
/**
* handle any font remapping but not on CID fonts or Type3 and gets too messy
**/
if(FontMappings.fontSubstitutionTable!=null && !isEmbedded &&
pdfObject.getParameterConstant(PdfDictionary.Subtype)!= StandardFonts.TYPE3)
fontType = getFontMapping(pdfObject, font_id, fontType, descendantFont);
//get subtype if not set above
if(fontType==PdfDictionary.Unknown){
fontType=pdfObject.getParameterConstant(PdfDictionary.Subtype);
/**handle CID fonts where /Subtype stored inside sub object*/
if (fontType==StandardFonts.TYPE0) {
//get CID type and use in preference to Type0 on CID fonts
PdfObject desc=pdfObject.getDictionary(PdfDictionary.DescendantFonts);
fontType=desc.getParameterConstant(PdfDictionary.Subtype);
origfontType=fontType;
//track non-embedded, non-substituted CID fonts
if(!isEmbedded && subFont==null) {
hasNonEmbeddedCIDFonts=true;
//track list
if(nonEmbeddedCIDFonts.length()>0)
nonEmbeddedCIDFonts.append(',');
nonEmbeddedCIDFonts.append(baseFont);
}
}
}
if(fontType==PdfDictionary.Unknown){
if(LogWriter.isOutput())
LogWriter.writeLog("Font type not supported");
currentFontData=new PdfFont(currentPdfFile);
}
/**
* check for OpenType fonts and reassign type
*/
if(fontType==StandardFonts.TYPE1 || fontType==StandardFonts.CIDTYPE2)
fontType = scanForOpenType(pdfObject, currentPdfFile, fontType);
try{
currentFontData=FontFactory.createFont(fontType,currentPdfFile,subFont, isPrinting);
/**set an alternative to Lucida*/
if(FontMappings.defaultFont!=null)
currentFontData.setDefaultDisplayFont(FontMappings.defaultFont);
currentFontData.createFont(pdfObject, font_id,renderPage, objectStoreStreamRef, fontsLoaded);
//save raw version
currentFontData.setRawFontName(rawFontName);
//fix for odd file
if(fontType==StandardFonts.TYPE1 && currentFontData.is1C() && pdfObject.getInt(PdfDictionary.FirstChar)==32 &&
pdfObject.getInt(PdfDictionary.FirstChar)==pdfObject.getInt(PdfDictionary.LastChar)){
if(isEmbedded){
isFontBroken=true;
isEmbedded=false;