-int opennewwindow=0;
-int ignoredraworder=0;
-int drawonlyshapes=0;
-int jpegquality=85;
-int storeallcharacters=0;
-int enablezlib=0;
-int insertstoptag=0;
-int flashversion=5;
-int splinemaxerror=1;
-int fontsplinemaxerror=1;
-int filloverlap=0;
-float minlinewidth=0.05;
-
-static char storefont = 0;
-static int flag_protected = 0;
-
-typedef unsigned char u8;
-typedef unsigned short int u16;
-typedef unsigned long int u32;
-
-static int fi;
-static char* filename = 0;
-static SWF swf;
-static TAG *tag;
-static int currentswfid = 0;
-static int depth = 1;
-static int startdepth = 1;
-static int linewidth = 0;
-static SRECT lastpagesize;
-
-static SHAPE* shape;
-static int shapeid = -1;
-static int textid = -1;
-
-static int fillstyleid;
-static int linestyleid;
-static int swflastx=0;
-static int swflasty=0;
-static int lastwasfill = 0;
-static int shapeisempty = 1;
-static char fill = 0;
-static int sizex;
-static int sizey;
-TAG* cliptags[128];
-int clipshapes[128];
-u32 clipdepths[128];
-int clippos = 0;
-
-int CHARMIDX = 0;
-int CHARMIDY = 0;
-
-char fillstylechanged = 0;
-
-int bboxrectpos = -1;
-SRECT bboxrect;
+#define CHARDATAMAX 8192
+#define CHARMIDX 0
+#define CHARMIDY 0
+
+typedef struct _chardata {
+ int charid;
+ int fontid; /* TODO: use a SWFFONT instead */
+ int x;
+ int y;
+ int size;
+ RGBA color;
+} chardata_t;
+
+struct fontlist_t
+{
+ SWFFONT *swffont;
+ fontlist_t*next;
+};
+
+int config_opennewwindow=0;
+int config_ignoredraworder=0;
+int config_drawonlyshapes=0;
+int config_jpegquality=85;
+int config_storeallcharacters=0;
+int config_enablezlib=0;
+int config_insertstoptag=0;
+int config_flashversion=5;
+int config_splinemaxerror=1;
+int config_fontsplinemaxerror=1;
+int config_filloverlap=0;
+int config_protect=0;
+float config_minlinewidth=0.05;
+
+typedef struct _swfoutput_internal
+{
+ fontlist_t* fontlist;
+
+ char storefont;
+
+ MATRIX page_matrix;
+
+ SWF swf;
+ TAG *tag;
+ int currentswfid;
+ int depth;
+ int startdepth;
+ int linewidth;
+ SRECT lastpagesize;
+
+ SHAPE* shape;
+ int shapeid;
+ int textid;
+
+ int fillstyleid;
+ int linestyleid;
+ int swflastx;
+ int swflasty;
+ int lastwasfill;
+ int shapeisempty;
+ char fill;
+ int sizex;
+ int sizey;
+ TAG* cliptags[128];
+ int clipshapes[128];
+ U32 clipdepths[128];
+ int clippos;
+
+ char fillstylechanged;
+
+ int bboxrectpos;
+ SRECT bboxrect;
+
+ chardata_t chardata[CHARDATAMAX];
+ int chardatapos;
+ int firstpage;
+} swfoutput_internal;
+
+static swfoutput_internal* init_internal_struct()
+{
+ swfoutput_internal*i = (swfoutput_internal*)malloc(sizeof(swfoutput_internal));
+ memset(i, 0, sizeof(swfoutput_internal));
+
+
+ i->storefont = 0;
+ i->currentswfid = 0;
+ i->depth = 1;
+ i->startdepth = 1;
+ i->linewidth = 0;
+ i->shapeid = -1;
+ i->textid = -1;
+
+ i->fillstyleid;
+ i->linestyleid;
+ i->swflastx=0;
+ i->swflasty=0;
+ i->lastwasfill = 0;
+ i->shapeisempty = 1;
+ i->fill = 0;
+ i->clippos = 0;
+
+ i->fillstylechanged = 0;
+
+ i->bboxrectpos = -1;
+ i->chardatapos = 0;
+ i->firstpage = 1;
+
+ return i;
+};