+ /* second, see if swfoutput already has this font
+ cached- if so, we are done */
+
+ if(swfoutput_queryfont(&output, fontname))
+ {
+ swfoutput_setfont(&output, fontname, -1, 0);
+ return;
+ }
+
+ // look for Type 3 font
+ if (!type3Warning && gfxFont->getType() == fontType3) {
+ type3Warning = gTrue;
+ showFontError(gfxFont, 2);
+ }
+
+ /* now either load the font, or find a substitution */
+
+ Ref embRef;
+ GBool embedded = gfxFont->getEmbeddedFontID(&embRef);
+ if(embedded) {
+ if (!gfxFont->isCIDFont() &&
+ (gfxFont->getType() == fontType1 ||
+ gfxFont->getType() == fontType1C ||
+ gfxFont->getType() == fontTrueType)) {
+
+ fileName = writeEmbeddedFontToFile(xref, gfxFont);
+ if(!fileName) {
+ logf("<error> Couldn't write font to file");
+ showFontError(gfxFont,0);
+ return ;
+ }
+ this->t1id = T1_AddFont(fileName);
+ if(this->t1id<0) {
+ logf("<error> Couldn't load font from file");
+ showFontError(gfxFont,0);
+ unlinkfont(fileName);
+ return ;
+ }
+ }
+ else {
+ showFontError(gfxFont,0);
+ fontname = substituteFont(gfxFont, fontname);
+ }
+ } else {
+ if(fontname) {
+ int newt1id = searchT1Font(fontname);
+ if(newt1id<0) {
+ fontname = substituteFont(gfxFont, fontname);
+ } else
+ this->t1id = newt1id;
+ }
+ else
+ fontname = substituteFont(gfxFont, fontname);
+ }
+
+ if(t1id<0) {
+ showFontError(gfxFont,0);
+ return;
+ }
+
+ /* we may have done some substitutions here, so check
+ again if this font is cached. */
+ if(swfoutput_queryfont(&output, fontname))
+ {
+ swfoutput_setfont(&output, fontname, -1, 0);
+ return;
+ }
+
+ logf("<verbose> Creating new SWF font: t1id: %d, filename: %s name:%s", this->t1id, FIXNULL(fileName), FIXNULL(fontname));
+ swfoutput_setfont(&output, fontname, this->t1id, fileName);