X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=src%2Fswfdump.c;h=0828ea45b2de542e1b0f4c340917af81db545e57;hp=3df34df44689d09012bbc1dd9283536feeaeae14;hb=2391d7ae5d8a145a250a8b80ab8c93ba74eba030;hpb=1233dfe1f22d9f14584e3811d480a97c6a89d4ff diff --git a/src/swfdump.c b/src/swfdump.c index 3df34df..0828ea4 100644 --- a/src/swfdump.c +++ b/src/swfdump.c @@ -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); } @@ -990,25 +995,66 @@ static void handleFontAlign1(TAG*tag) printf(" %d glyphs", num); } +#define ALIGN_WITH_GLYPHS static void handleFontAlign2(TAG*tag, char*prefix) { if(!showfonts) return; swf_SetTagPos(tag, 0); - swf_GetU16(tag); + U16 id = swf_GetU16(tag); swf_GetU8(tag); int num = 0; +#ifdef ALIGN_WITH_GLYPHS + SWF swf; + swf.firstTag = tag; + while(swf.firstTag->prev) 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++); + printf("%sglyph %d) ", prefix, num); int nr = swf_GetU8(tag); // should be 2 int t; - for(t=0;tnumchars) { + 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++; } } @@ -1186,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); @@ -1223,9 +1269,9 @@ 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(tag->id == ST_PLACEOBJECT) {