#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
-#ifdef HAVE_FONTCONFIG_H
+#ifdef HAVE_FONTCONFIG
#include <fontconfig.h>
#endif
//xpdf header files
#include "swfoutput.h"
#include "../lib/log.h"
#include "../lib/gfxdevice.h"
-#include "gfxtools.h"
+#include "../lib/gfxtools.h"
+#include "../lib/gfxfont.h"
#include <math.h>
/* config */
static double caplinewidth = 3.0;
static int zoom = 72; /* xpdf: 86 */
-static int forceType0Fonts = 0;
+static int forceType0Fonts = 1;
static void printInfoString(Dict *infoDict, char *key, char *fmt);
static void printInfoDate(Dict *infoDict, char *key, char *fmt);
}
};
+typedef struct _fontlist
+{
+ char*id;
+ char*filename;
+ gfxfont_t*font;
+ _fontlist*next;
+} fontlist_t;
+
class SWFOutputDev: public OutputDev {
int outputstarted;
struct swfoutput output;
void drawGeneralImage(GfxState *state, Object *ref, Stream *str,
int width, int height, GfxImageColorMap*colorMap, GBool invert,
GBool inlineImg, int mask, int *maskColors);
+ int SWFOutputDev::setGfxFont(char*id, char*filename);
+
SWFOutputState states[64];
int statepos;
int user_movex,user_movey;
int user_clipx1,user_clipx2,user_clipy1,user_clipy2;
+
+ gfxline_t* current_text_stroke;
+ char* current_font_id;
+ gfxfont_t* current_gfxfont;
+ fontlist_t* fontlist;
};
static char*getFontID(GfxFont*font);
user_clipy1 = 0;
user_clipx2 = 0;
user_clipy2 = 0;
+ current_text_stroke = 0;
+ fontlist = 0;
memset(&output, 0, sizeof(output));
// printf("SWFOutputDev::SWFOutputDev() \n");
};
{
swfoutput_destroy(&output);
outputstarted = 0;
+
+ fontlist_t*l = this->fontlist;
+ while(l) {
+ fontlist_t*next = l->next;
+ l->next = 0;
+ gfxfont_free(l->font);
+ free(l->id);
+ free(l->filename);
+ free(l);
+ l = next;
+ }
};
GBool SWFOutputDev::upsideDown()
{
if(enc && enc[c])
name = enc[c];
}
-
if (CIDToGIDMap) {
msg("<debug> drawChar(%f, %f, c='%c' (%d), GID=%d, u=%d <%d>) CID=%d name=\"%s\" render=%d\n", x, y, (c&127)>=32?c:'?', c, CIDToGIDMap[c], u, uLen, font->isCIDFont(), FIXNULL(name), render);
- swfoutput_drawchar(&output, x1, y1, name, CIDToGIDMap[c], u, &col);
+ c = CIDToGIDMap[c];
} else {
msg("<debug> drawChar(%f,%f,c='%c' (%d), u=%d <%d>) CID=%d name=\"%s\" render=%d\n",x,y,(c&127)>=32?c:'?',c,u, uLen, font->isCIDFont(), FIXNULL(name), render);
- swfoutput_drawchar(&output, x1, y1, name, c, u, &col);
}
+
+ swfoutput_drawchar(&output, x1, y1, name, c, u, &col);
}
void SWFOutputDev::endString(GfxState *state)
void SWFOutputDev::endTextObject(GfxState *state)
{
+ if(states[statepos].textRender != state->getRender())
+ msg("<error> Internal error: drawChar.render!=beginString.render");
msg("<trace> endTextObject()");
}
this->xref = xref;
}
+int SWFOutputDev::setGfxFont(char*id, char*filename)
+{
+ gfxfont_t*font = 0;
+ fontlist_t*last=0,*l = this->fontlist;
+
+ /* TODO: should this be part of the state? */
+ while(l) {
+ last = l;
+ if(!strcmp(l->id, id)) {
+ current_font_id = l->id;
+ current_gfxfont = l->font;
+ font = l->font;
+ return 1;
+ }
+ l = l->next;
+ }
+ if(!filename) return 0;
+ font = gfxfont_load(filename);
+ l = new fontlist_t;
+ l->font = font;
+ l->filename = strdup(filename);
+ l->id = strdup(id);
+ l->next = 0;
+ current_font_id = l->id;
+ current_gfxfont = l->font;
+ if(last) {
+ last->next = l;
+ } else {
+ this->fontlist = l;
+ }
+ return 1;
+}
void SWFOutputDev::updateFont(GfxState *state)
{
/* second, see if swfoutput already has this font
cached- if so, we are done */
+ setGfxFont(fontid, 0);
if(swfoutput_queryfont(&output, fontid))
{
swfoutput_setfont(&output, fontid, 0);
dumpFontInfo("<verbose>", gfxFont);
swfoutput_setfont(&output, fontid, fileName);
+
+ if(!setGfxFont(fontid, 0)) {
+ setGfxFont(fontid, fileName);
+ }
if(fileName && del)
unlinkfont(fileName);