fontlist_t*next;
};
+double config_dumpfonts=0;
double config_ppmsubpixels=0;
double config_jpegsubpixels=0;
int config_opennewwindow=1;
int config_fontsplinemaxerror=1;
int config_filloverlap=0;
int config_protect=0;
+int config_bboxvars=0;
float config_minlinewidth=0.05;
double config_caplinewidth=1;
int firstpage;
char pagefinished;
+ char overflow;
+
/* during the transition to the gfxdevice interface:
a device which uses this swfoutput as target */
gfxdevice_t device;
i->storefont = 0;
i->currentswfid = 0;
i->depth = 0;
+ i->overflow = 0;
i->startdepth = 0;
i->linewidth = 0;
i->shapeid = -1;
if(!id_error)
msg("<error> ID Table overflow");
id_error=1;
+ i->overflow = 1;
}
return ++i->currentswfid;
}
+static U16 getNewDepth(struct swfoutput* obj)
+{
+ swfoutput_internal*i = (swfoutput_internal*)obj->internal;
+ if(i->depth == 65535) {
+ if(!id_error)
+ msg("<error> Depth Table overflow");
+ id_error=1;
+ i->overflow = 1;
+ }
+ return ++i->depth;
+}
static void startshape(struct swfoutput* obj);
static void starttext(struct swfoutput* obj);
If we set it to low, however, the char positions will be inaccurate */
#define FONT_INTERNAL_SIZE 4
+static int font_active = 0;
+static char* font_active_filename = 0;
+
/* process a character. */
static int drawchar(struct swfoutput*obj, SWFFONT *swffont, char*character, int charnr, int u, swfmatrix*m, gfxcolor_t*col)
{
}
int charid = getCharID(swffont, charnr, character, u);
+ if(font_active) {
+ char buf[1024];
+ sprintf(buf, "%s.usage", font_active_filename);
+ FILE*fi = fopen(buf, "ab+");
+ if(fi) {
+ fprintf(fi, "%d %d %d %s\n", charnr, u, charid, character);
+ fclose(fi);
+ } else
+ msg("<error> Couldn't write to %s", buf);
+ }
if(charid<0) {
msg("<warning> Didn't find character '%s' (c=%d,u=%d) in current charset (%s, %d characters)",
putcharacters(obj, i->tag);
swf_SetU8(i->tag,0);
i->tag = swf_InsertTag(i->tag,ST_PLACEOBJECT2);
- //swf_ObjectPlace(i->tag,i->textid,/*depth*/i->depth++,&i->page_matrix,NULL,NULL);
MATRIX m2;
swf_MatrixJoin(&m2,&obj->fontmatrix, &i->page_matrix);
- swf_ObjectPlace(i->tag,i->textid,/*depth*/++i->depth,&m2,NULL,NULL);
+ swf_ObjectPlace(i->tag,i->textid,getNewDepth(obj),&m2,NULL,NULL);
i->textid = -1;
}
return -1;
}
-
/* set's the t1 font index of the font to use for swfoutput_drawchar(). */
void swfoutput_setfont(struct swfoutput*obj, char*fontid, char*filename)
{
swfoutput_internal*i = (swfoutput_internal*)obj->internal;
+ font_active = 0;
fontlist_t*last=0,*iterator;
if(!fontid) {
msg("<error> No fontid");
swf_SetLoadFontParameters(64,/*skip unused*/0,/*full unicode*/1);
SWFFONT*swffont = swf_LoadFont(filename);
+ if(config_dumpfonts) {
+ font_active = 1;
+ font_active_filename = strdup(filename);
+ }
+
if(swffont == 0) {
msg("<warning> Couldn't load font %s (%s)", fontid, filename);
swffont = swf_LoadFont(0);
swffont->encoding = 255;
}
}
+
+ if(swffont->encoding != FONT_ENCODING_UNICODE && swffont->encoding != 255) {
+ msg("<warning> Non-unicode mapping for font %s (%s)", fontid, filename);
+ }
swf_FontSetID(swffont, getNewID(obj));
swf_ShapeSetEnd(i->tag);
swf_ShapeFree(s);
i->tag = swf_InsertTag(i->tag, ST_PLACEOBJECT2);
- swf_ObjectPlace(i->tag,shapeid,++i->depth,0,0,0);
+ swf_ObjectPlace(i->tag,shapeid,getNewDepth(obj),0,0,0);
i->tag = swf_InsertTag(i->tag, ST_PLACEOBJECT2);
- swf_ObjectPlaceClip(i->tag,shapeid,++i->depth,0,0,0,65535);
+ swf_ObjectPlaceClip(i->tag,shapeid,getNewDepth(obj),0,0,0,65535);
i->cliptag = i->tag;
}
msg("<trace> Placing shape id %d", i->shapeid);
i->tag = swf_InsertTag(i->tag,ST_PLACEOBJECT2);
- swf_ObjectPlace(i->tag,i->shapeid,/*depth*/++i->depth,&i->page_matrix,NULL,NULL);
+ swf_ObjectPlace(i->tag,i->shapeid,getNewDepth(obj),&i->page_matrix,NULL,NULL);
swf_ShapeFree(i->shape);
i->shape = 0;
}*/
}
+void wipeSWF(SWF*swf)
+{
+ TAG*tag = swf->firstTag;
+ while(tag) {
+ TAG*next = tag->next;
+ if(tag->id != ST_SETBACKGROUNDCOLOR &&
+ tag->id != ST_END &&
+ tag->id != ST_DOACTION &&
+ tag->id != ST_SHOWFRAME) {
+ swf_DeleteTag(tag);
+ }
+ tag = next;
+ }
+}
+
+
void swfoutput_finalize(struct swfoutput*obj)
{
swfoutput_internal*i = (swfoutput_internal*)obj->internal;
if(i->tag && i->tag->id == ST_END)
return; //already done
+ if(config_bboxvars) {
+ TAG* tag = swf_InsertTag(i->swf.firstTag, ST_DOACTION);
+ ActionTAG*a = 0;
+ a = action_PushString(a, "xmin");
+ a = action_PushFloat(a, i->swf.movieSize.xmin / 20.0);
+ a = action_SetVariable(a);
+ a = action_PushString(a, "ymin");
+ a = action_PushFloat(a, i->swf.movieSize.ymin / 20.0);
+ a = action_SetVariable(a);
+ a = action_PushString(a, "xmax");
+ a = action_PushFloat(a, i->swf.movieSize.xmax / 20.0);
+ a = action_SetVariable(a);
+ a = action_PushString(a, "ymax");
+ a = action_PushFloat(a, i->swf.movieSize.ymax / 20.0);
+ a = action_SetVariable(a);
+ a = action_PushString(a, "width");
+ a = action_PushFloat(a, (i->swf.movieSize.xmax - i->swf.movieSize.xmin) / 20.0);
+ a = action_SetVariable(a);
+ a = action_PushString(a, "height");
+ a = action_PushFloat(a, (i->swf.movieSize.ymax - i->swf.movieSize.ymin) / 20.0);
+ a = action_SetVariable(a);
+ a = action_End(a);
+ swf_ActionSet(tag, a);
+ swf_ActionFree(a);
+ }
+
if(i->frameno == i->lastframeno) // fix: add missing pagefeed
swfoutput_pagefeed(obj);
swf_DeleteTag(tag);
tag = prev;
}
+
+ if(i->overflow) {
+ wipeSWF(&i->swf);
+ }
}
SWF* swfoutput_get(struct swfoutput*obj)
m = i->page_matrix;
m.tx = p.x;
m.ty = p.y;
- swf_ObjectPlace(i->tag, buttonid, ++i->depth,&m,0,0);
+ swf_ObjectPlace(i->tag, buttonid, getNewDepth(obj),&m,0,0);
} else {
- swf_ObjectPlace(i->tag, buttonid, ++i->depth,&i->page_matrix,0,0);
+ swf_ObjectPlace(i->tag, buttonid, getNewDepth(obj),&i->page_matrix,0,0);
}
}
config_storeallcharacters = atoi(value);
} else if(!strcmp(name, "enablezlib")) {
config_enablezlib = atoi(value);
+ } else if(!strcmp(name, "bboxvars")) {
+ config_bboxvars = atoi(value);
} else if(!strcmp(name, "insertstop")) {
config_insertstoptag = atoi(value);
} else if(!strcmp(name, "protected")) {
config_minlinewidth = atof(value);
} else if(!strcmp(name, "caplinewidth")) {
config_caplinewidth = atof(value);
+ } else if(!strcmp(name, "dumpfonts")) {
+ config_dumpfonts = atoi(value);
} else if(!strcmp(name, "jpegquality")) {
int val = atoi(value);
if(val<0) val=0;
}
}
+/* TODO */
+static int imageInCache(swfoutput*obj, void*data, int width, int height)
+{
+ return -1;
+}
+static void addImageToCache(swfoutput*obj, void*data, int width, int height)
+{
+}
+
static int add_image(swfoutput_internal*i, gfximage_t*img, int targetwidth, int targetheight, int* newwidth, int* newheight)
{
swfoutput*obj = i->obj;
RGBA*newpic = 0;
RGBA*mem = (RGBA*)img->data;
- int bitid = getNewID(obj);
int sizex = img->width;
int sizey = img->height;
}
printf("\n");*/
- i->tag = swf_AddImage(i->tag, bitid, mem, sizex, sizey, config_jpegquality);
+ int bitid = -1;
+ int cacheid = imageInCache(obj, mem, sizex, sizey);
+
+ if(cacheid<=0) {
+ bitid = getNewID(obj);
+ i->tag = swf_AddImage(i->tag, bitid, mem, sizex, sizey, config_jpegquality);
+ addImageToCache(obj, mem, sizex, sizey);
+ } else {
+ bitid = cacheid;
+ }
if(newpic)
free(newpic);
-
return bitid;
}
i->tag = swf_InsertTag(i->tag,ST_PLACEOBJECT2);
CXFORM cxform2 = gfxcxform_to_cxform(cxform);
- swf_ObjectPlace(i->tag,myshapeid,/*depth*/++i->depth,&i->page_matrix,&cxform2,NULL);
+ swf_ObjectPlace(i->tag,myshapeid,getNewDepth(obj),&i->page_matrix,&cxform2,NULL);
}
void swf_startclip(gfxdevice_t*dev, gfxline_t*line)
i->tag = swf_InsertTag(i->tag,ST_PLACEOBJECT2);
i->cliptags[i->clippos] = i->tag;
i->clipshapes[i->clippos] = myshapeid;
- i->clipdepths[i->clippos] = ++i->depth;
+ i->clipdepths[i->clippos] = getNewDepth(obj);
i->clippos++;
}