From ce3c08fef5972b6e05b7b1bb6fb65ff249c33505 Mon Sep 17 00:00:00 2001 From: kramm Date: Tue, 23 Nov 2004 18:42:55 +0000 Subject: [PATCH] swf_FontEnumerate now passes a self pointer to the callback function. --- lib/example/dumpfont.c | 4 ++-- lib/modules/swftext.c | 6 +++--- lib/rfxswf.h | 2 +- src/swfbbox.c | 8 ++++---- src/swfdump.c | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/example/dumpfont.c b/lib/example/dumpfont.c index 8d38b8e..f746238 100644 --- a/lib/example/dumpfont.c +++ b/lib/example/dumpfont.c @@ -133,7 +133,7 @@ void DumpGlobal(char * funcname) } -void fontcallback(U16 id,U8 * name) +void fontcallback(U16 id,U8 * name,0) { SWFFONT * font; int f; @@ -174,7 +174,7 @@ int main(int argc,char ** argv) sprintf(fn,"fn%04x",getpid()); // avoid name conflicts @ using multiple fonts printf("#define addGlyph %s\n",fn); DumpGlobal(fn); - swf_FontEnumerate(&swf,&fontcallback); + swf_FontEnumerate(&swf,&fontcallback,0); swf_FreeTags(&swf); printf("#undef addGlyph\n"); } diff --git a/lib/modules/swftext.c b/lib/modules/swftext.c index 06d3eea..638be12 100644 --- a/lib/modules/swftext.c +++ b/lib/modules/swftext.c @@ -101,7 +101,7 @@ int swf_FontIsBold(SWFFONT * f) static const int WRITEFONTID = 0x4e46; // font id for WriteFont and ReadFont -int swf_FontEnumerate(SWF * swf, void (*FontCallback) (U16, U8 *)) +int swf_FontEnumerate(SWF * swf, void (*FontCallback) (void*, U16, U8 *), void*self) { int n; TAG *t; @@ -129,7 +129,7 @@ int swf_FontEnumerate(SWF * swf, void (*FontCallback) (U16, U8 *)) s[l] = 0; } - (FontCallback) (id, s); + (FontCallback) (self, id, s); swf_RestoreTagPos(t); } @@ -381,7 +381,7 @@ int swf_FontExtract_DefineFont2(int id, SWFFONT * font, TAG * tag) static int swf_FontExtract_DefineTextCallback(int id, SWFFONT * f, TAG * t, int jobs, void (*callback) (void *self, - int *chars, int *ypos, int nr, int fontid, int fontsize, int xstart, int ystart, RGBA * color), void *self) + int *chars, int *xpos, int nr, int fontid, int fontsize, int xstart, int ystart, RGBA * color), void *self) { U16 cid; SRECT r; diff --git a/lib/rfxswf.h b/lib/rfxswf.h index 1b40494..3888319 100644 --- a/lib/rfxswf.h +++ b/lib/rfxswf.h @@ -559,7 +559,7 @@ typedef struct _EditTextLayout U16 leading; } EditTextLayout; -int swf_FontEnumerate(SWF * swf,void (*FontCallback) (U16,U8*)); +int swf_FontEnumerate(SWF * swf,void (*FontCallback) (void*,U16,U8*), void*self); // -> void fontcallback(U16 id,U8 * name); returns number of defined fonts int swf_FontExtract(SWF * swf,int id,SWFFONT ** f); diff --git a/src/swfbbox.c b/src/swfbbox.c index bb0322e..95ff67a 100644 --- a/src/swfbbox.c +++ b/src/swfbbox.c @@ -189,10 +189,10 @@ MATRIX getmatrix(TAG*tag) static int fontnum = -1; static SWFFONT**fonts; static SWF*c_swf; -static void fontcallback1(U16 id,U8 * name) +static void fontcallback1(void*self, U16 id,U8 * name) { fontnum++; } -static void fontcallback2(U16 id,U8 * name) +static void fontcallback2(void*self, U16 id,U8 * name) { fonts[fontnum] = 0; swf_FontExtract(c_swf,id,&fonts[fontnum]); @@ -296,11 +296,11 @@ static void swf_OptimizeBoundingBoxes(SWF*swf) if(verbose) printf("Extracting fonts...\n"); c_swf = swf; fontnum = 0; - swf_FontEnumerate(swf,&fontcallback1); + swf_FontEnumerate(swf,&fontcallback1,0); fonts = (SWFFONT**)malloc(fontnum*sizeof(SWFFONT*)); memset(fonts, 0, fontnum*sizeof(SWFFONT*)); fontnum = 0; - swf_FontEnumerate(swf,&fontcallback2); + swf_FontEnumerate(swf,&fontcallback2,0); } memset(&bounds, 0, sizeof(bounds)); diff --git a/src/swfdump.c b/src/swfdump.c index 49208ab..3940141 100644 --- a/src/swfdump.c +++ b/src/swfdump.c @@ -655,11 +655,11 @@ void handleShape(TAG*tag, char*prefix) printf("%s |\n", prefix); } -void fontcallback1(U16 id,U8 * name) +void fontcallback1(void*self, U16 id,U8 * name) { fontnum++; } -void fontcallback2(U16 id,U8 * name) +void fontcallback2(void*self, U16 id,U8 * name) { swf_FontExtract(&swf,id,&fonts[fontnum]); fontnum++; @@ -869,10 +869,10 @@ int main (int argc,char ** argv) if(showtext) { fontnum = 0; - swf_FontEnumerate(&swf,&fontcallback1); + swf_FontEnumerate(&swf,&fontcallback1, 0); fonts = (SWFFONT**)malloc(fontnum*sizeof(SWFFONT*)); fontnum = 0; - swf_FontEnumerate(&swf,&fontcallback2); + swf_FontEnumerate(&swf,&fontcallback2, 0); } while(tag) { -- 1.7.10.4