X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=src%2Fswfdump.c;h=0828ea45b2de542e1b0f4c340917af81db545e57;hp=12c653d04a9584ade0ae9c5843711b8e36b06882;hb=2391d7ae5d8a145a250a8b80ab8c93ba74eba030;hpb=5c336b4f7017fb121fc2cbe2a02c1fa56986b560 diff --git a/src/swfdump.c b/src/swfdump.c index 12c653d..0828ea4 100644 --- a/src/swfdump.c +++ b/src/swfdump.c @@ -298,7 +298,7 @@ void dumpFont(TAG*tag, char*prefix) { SWFFONT* font = malloc(sizeof(SWFFONT)); memset(font, 0, sizeof(SWFFONT)); - if(tag->id == ST_DEFINEFONT2) { + if(tag->id == ST_DEFINEFONT2 || tag->id == ST_DEFINEFONT3) { swf_FontExtract_DefineFont2(0, font, tag); } else if(tag->id == ST_DEFINEFONT) { swf_FontExtract_DefineFont(0, font, tag); @@ -323,7 +323,10 @@ void dumpFont(TAG*tag, char*prefix) int t; for(t=0;tnumchars;t++) { int u = font->glyph2ascii?font->glyph2ascii[t]:-1; - printf("%s== Glyph %d: advance=%d encoding=%d ==\n", prefix, t, font->glyph[t].advance, u); + char ustr[16]; + if(u>=32) sprintf(ustr, " '%c'", u); + else sprintf(ustr, " 0x%02x", u); + printf("%s== Glyph %d: advance=%d encoding=%d%s ==\n", prefix, t, font->glyph[t].advance, u, ustr); SHAPE2* shape = swf_ShapeToShape2(font->glyph[t].shape); SHAPELINE*line = shape->lines; @@ -379,10 +382,12 @@ static SWF swf; static int fontnum = 0; static SWFFONT**fonts; -void textcallback(void*self, int*glyphs, int*ypos, int nr, int fontid, int fontsize, int startx, int starty, RGBA*color) +void textcallback(void*self, int*glyphs, int*xpos, int nr, int fontid, int fontsize, int startx, int starty, RGBA*color) { int font=-1,t; - printf(" <%2d glyphs in font %2d size %d, color #%02x%02x%02x%02x> ",nr, fontid, fontsize, color->r, color->g, color->b, color->a); + if(nr<1) + return; + printf(" <%2d glyphs in font %04d size %d, color #%02x%02x%02x%02x at %.2f,%.2f> ",nr, fontid, fontsize, color->r, color->g, color->b, color->a, (startx+xpos[0])/20.0, starty/20.0); for(t=0;tid == fontid) { @@ -604,7 +609,7 @@ void handleVideoFrame(TAG*tag, char*prefix) deblock = swf_GetBits(tag, 1); if(deblock) - printf(" deblock ", deblock); + printf(" deblock %d ", deblock); quantizer = swf_GetBits(tag, 5); printf(" quant: %d ", quantizer); } @@ -962,6 +967,98 @@ void handleExportAssets(TAG*tag, char* prefix) } } +static void handleFontAlign1(TAG*tag) +{ + swf_SetTagPos(tag, 0); + U16 id = swf_GetU16(tag); + U8 flags = swf_GetU8(tag); + printf(" for font %04d, ", id); + if((flags&3)==0) printf("thin, "); + else if((flags&3)==1) printf("medium, "); + else if((flags&3)==2) printf("thick, "); + else printf("?, "); + int num=0; + while(tag->pos < tag->len) { + int nr = swf_GetU8(tag); // should be 2 + int t; + if(nr>2) { + printf("*** unsupported multiboxes ***, "); + break; + } + for(t=0;tprev) swf.firstTag = swf.firstTag->prev; + SWFFONT* font = 0; + swf_FontExtract(&swf, id, &font); +#endif + swf_SetTagPos(tag, 3); + while(tag->pos < tag->len) { + printf("%sglyph %d) ", prefix, num); + int nr = swf_GetU8(tag); // should be 2 + int t; + for(t=0;t<2;t++) { + // pos + float v = swf_GetF16(tag); + printf("%f ", v*1024.0); + } + int s; + for(s=0;snumchars) { + SHAPE2* shape = swf_ShapeToShape2(font->glyph[num].shape); + SHAPELINE*line = shape->lines; + while(line) { + if(line->type == moveTo) { + printf("%smoveTo %.2f %.2f\n", prefix, line->x/20.0, line->y/20.0); + } else if(line->type == lineTo) { + printf("%slineTo %.2f %.2f\n", prefix, line->x/20.0, line->y/20.0); + } else if(line->type == splineTo) { + printf("%ssplineTo (%.2f %.2f) %.2f %.2f\n", prefix, + line->sx/20.0, line->sy/20.0, + line->x/20.0, line->y/20.0 + ); + } + line = line->next; + } + swf_Shape2Free(shape); + free(shape); + } + if(num==font->numchars-1) break; +#endif + num++; + } +} + + void dumperror(const char* format, ...) { char buf[1024]; @@ -1135,7 +1232,7 @@ int main (int argc,char ** argv) else printf("\n"); } - printf("[HEADER] File size: %ld%s\n", swf.fileSize, swf.compressed?" (Depacked)":""); + printf("[HEADER] File size: %d%s\n", swf.fileSize, swf.compressed?" (Depacked)":""); printf("[HEADER] Frame rate: %f\n",swf.frameRate/256.0); printf("[HEADER] Frame count: %d\n",swf.frameCount); printf("[HEADER] Movie width: %.2f",(swf.movieSize.xmax-swf.movieSize.xmin)/20.0); @@ -1172,25 +1269,12 @@ int main (int argc,char ** argv) } if(cumulative) { filepos += tag->len; - printf("[%03x] %9ld %9ld %s%s", tag->id, tag->len, filepos, prefix, swf_TagGetName(tag)); + printf("[%03x] %9d %9d %s%s", tag->id, tag->len, filepos, prefix, swf_TagGetName(tag)); } else { - printf("[%03x] %9ld %s%s", tag->id, tag->len, prefix, swf_TagGetName(tag)); + printf("[%03x] %9d %s%s", tag->id, tag->len, prefix, swf_TagGetName(tag)); } - if(swf_isDefiningTag(tag)) { - U16 id = swf_GetDefineID(tag); - printf(" defines id %04d", id); - if(idtab[id]) - dumperror("Id %04d is defined more than once.", id); - idtab[id] = 1; - } - else if(swf_isPseudoDefiningTag(tag)) { - U16 id = swf_GetDefineID(tag); - printf(" adds information to id %04d", id); - if(!idtab[id]) - dumperror("Id %04d is not yet defined.\n", id); - } - else if(tag->id == ST_PLACEOBJECT) { + if(tag->id == ST_PLACEOBJECT) { printf(" places id %04d at depth %04x", swf_GetPlaceID(tag), swf_GetDepth(tag)); if(swf_GetName(tag)) printf(" name \"%s\"",swf_GetName(tag)); @@ -1279,7 +1363,7 @@ int main (int argc,char ** argv) } } else if(tag->id == ST_FRAMELABEL) { - int l = strlen(tag->data); + int l = strlen((char*)tag->data); printf(" \"%s\"", tag->data); if((l+1) < tag->len) { printf(" has %d extra bytes", tag->len-1-l); @@ -1291,8 +1375,8 @@ int main (int argc,char ** argv) dumperror("Frame %d has more than one label", issprite?spriteframe:mainframe); } - if(issprite) spriteframelabel = tag->data; - else framelabel = tag->data; + if(issprite) spriteframelabel = (char*)tag->data; + else framelabel = (char*)tag->data; } else if(tag->id == ST_SHOWFRAME) { char*label = issprite?spriteframelabel:framelabel; @@ -1329,6 +1413,9 @@ int main (int argc,char ** argv) printf(" %s", swf_GetString(tag)); } } + else if(tag->id == ST_DEFINEFONTALIGNZONES) { + handleFontAlign1(tag); + } else if(tag->id == ST_CSMTEXTSETTINGS) { U16 id = swf_GetU16(tag); U8 flags = swf_GetU8(tag); @@ -1349,6 +1436,19 @@ int main (int argc,char ** argv) printf("s=%.2f,t=%.2f)", thickness, sharpness); swf_GetU8(tag); } + else if(swf_isDefiningTag(tag)) { + U16 id = swf_GetDefineID(tag); + printf(" defines id %04d", id); + if(idtab[id]) + dumperror("Id %04d is defined more than once.", id); + idtab[id] = 1; + } + else if(swf_isPseudoDefiningTag(tag)) { + U16 id = swf_GetDefineID(tag); + printf(" adds information to id %04d", id); + if(!idtab[id]) + dumperror("Id %04d is not yet defined.\n", id); + } if(tag->id == ST_DEFINEBITSLOSSLESS || tag->id == ST_DEFINEBITSLOSSLESS2) { @@ -1463,6 +1563,9 @@ int main (int argc,char ** argv) else if(tag->id == ST_PLACEOBJECT2 || tag->id == ST_PLACEOBJECT3) { handlePlaceObject23(tag, myprefix); } + else if(tag->id == ST_DEFINEFONTALIGNZONES) { + handleFontAlign2(tag, myprefix); + } else if(tag->id == ST_DEFINEFONTNAME) { swf_SetTagPos(tag, 0); swf_GetU16(tag); //id