swf_FontEnumerate now passes a self pointer to the callback function.
authorkramm <kramm>
Tue, 23 Nov 2004 18:42:55 +0000 (18:42 +0000)
committerkramm <kramm>
Tue, 23 Nov 2004 18:42:55 +0000 (18:42 +0000)
lib/example/dumpfont.c
lib/modules/swftext.c
lib/rfxswf.h
src/swfbbox.c
src/swfdump.c

index 8d38b8e..f746238 100644 (file)
@@ -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");
       }
index 06d3eea..638be12 100644 (file)
@@ -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;
index 1b40494..3888319 100644 (file)
@@ -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);
index bb0322e..95ff67a 100644 (file)
@@ -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));
index 49208ab..3940141 100644 (file)
@@ -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) {