--- /dev/null
+/* demofont.c
+
+ Character data for some glyphs needed by text.c
+
+ Dumped with dumpfont.c
+
+ Part of the swftools package.
+
+ This file is distributed under the GPL, see file COPYING for details
+
+*/
+
+#define addGlyph fn3711
+
+void fn3711(SWFFONT * f,int i,U16 code,U16 advance,U16 gid,U8 * data,U32 bitlen)
+{ SHAPE * s;
+ U32 l = (bitlen+7)/8;
+
+ if (FAILED(swf_ShapeNew(&s))) return;
+ s->data = malloc(l);
+ if (!s->data) { swf_ShapeFree(s); return; }
+
+ f->codes[i] = code;
+ f->glyph[i].advance = advance;
+ f->glyph[i].gid = gid;
+ f->glyph[i].shape = s;
+ s->bitlen = bitlen;
+ s->bits.fill = 1;
+ memcpy(s->data,data,l);
+}
+
+U8 Glyphs_Demo_Font[] = {
+ 0x35, 0x66, 0xc2, 0xd5, 0xe3, 0x9b, 0x62, 0x08,
+ 0xea, 0x09, 0xe2, 0x4c, 0xf8, 0xba, 0x59, 0x2d,
+ 0x93, 0x1d, 0xe4, 0xc3, 0x6b, 0x40, 0x92, 0x90,
+ 0x30, 0x36, 0x4c, 0x0c, 0xe5, 0xa9, 0xbe, 0x46,
+ 0x40, 0x1a, 0xf5, 0x50, 0xec, 0x3b, 0x6a, 0xa4,
+ 0xd8, 0x8a, 0xe1, 0x4b, 0x66, 0x00, 0x40, 0x0e,
+ 0x11, 0x91, 0x35, 0x9f, 0x03, 0x51, 0x4e, 0x8a,
+ 0x5c, 0x17, 0x7e, 0x8d, 0xda, 0x0a, 0x48, 0xa0,
+ 0x08, 0xed, 0x22, 0x1b, 0x0f, 0x7c, 0xa1, 0xb7,
+ 0x80, 0x9f, 0xc3, 0x69, 0xec, 0x53, 0xea, 0xdc,
+ 0xd8, 0x59, 0xd1, 0x8a, 0x60, 0x0b, 0xc1, 0x6d,
+ 0x09, 0x4b, 0x51, 0x5b, 0x8e, 0x55, 0xb8, 0x9c,
+ 0x80, 0x95, 0xa0, 0x05, 0x88, 0xa4, 0x75, 0x70,
+ 0x1c,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d, 0xdc, 0x6d,
+ 0x68, 0xa7, 0x2d, 0xc0, 0x3c, 0x46, 0x49, 0xb1,
+ 0x00, 0x23, 0xa4, 0x45, 0x78, 0x8d, 0x08, 0x3e,
+ 0xf3, 0x0c, 0x0b, 0x58, 0xaa, 0xba, 0x76, 0xbf,
+ 0x5d, 0xaf, 0x1a, 0x36, 0xee, 0x24, 0x34, 0x53,
+ 0x96, 0xa8, 0x6d, 0x6d, 0x78, 0xec, 0xec, 0x56,
+ 0x85, 0x9c, 0x78, 0xdb, 0x73, 0x8e, 0xf6, 0x92,
+ 0x68, 0x5b, 0xc7, 0x6d, 0x9f, 0xe5, 0xe5, 0x73,
+ 0x97, 0x39, 0x32, 0xce, 0x2e, 0xb4, 0x6d, 0xdc,
+ 0x60, 0x68, 0xa7, 0xae, 0xe8, 0x98, 0xf0, 0x80,
+ 0x3a, 0x40, 0x0f, 0x21, 0x6e, 0x23, 0x12, 0x11,
+ 0xbc, 0xc7, 0x29, 0xdb, 0xcd, 0x7b, 0x26, 0x91,
+ 0x59, 0xa6, 0xba, 0xfe, 0x34, 0x6d, 0x00, 0x00 };
+
+SWFFONT * Font_Demo_Font(U16 id)
+{ SWFFONT * f;
+ int i;
+
+ if (!(f=malloc(sizeof(SWFFONT)))) return NULL;
+ memset(f,0x00,sizeof(SWFFONT));
+ f->id = id;
+ f->name = strdup("Demo Font");
+ f->flags = 0x10;
+
+ addGlyph(f,102, 0x00, 64, 0, &Glyphs_Demo_Font[0x0000], 872); // f
+ addGlyph(f,108, 0x00, 53, 1, &Glyphs_Demo_Font[0x006d], 452); // l
+ addGlyph(f,111, 0x00, 96, 2, &Glyphs_Demo_Font[0x00a6], 743); // o
+ addGlyph(f,115, 0x00, 74, 3, &Glyphs_Demo_Font[0x0103], 951); // s
+ addGlyph(f,116, 0x00, 53, 4, &Glyphs_Demo_Font[0x017a], 570); // t
+ addGlyph(f,119, 0x00, 138, 5, &Glyphs_Demo_Font[0x01c2], 806); // w
+ return f;
+}
+
+#undef addGlyph
--- /dev/null
+/* dumpfont.c
+
+ Example for font handling
+
+ This tool dumps font information into C files
+ which can be included to rfxswf applications.
+ This is an easy way for developers to use
+ fonts in applications without dealing with
+ external files.
+
+ Usage: ./dumpfont filename.swf > myfont.c
+
+ Limits: does not parse ST_DEFINEFONT2
+
+ Part of the swftools package.
+
+ Copyright (c) 2000, 2001 Rainer Böhme <rfxswf@reflex-studio.de>
+
+ This file is distributed under the GPL, see file COPYING for details
+
+*/
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include "../rfxswf.h"
+
+#define PRINTABLE(a) ((a>='A')&&(a<='Z'))||((a>='a')&&(a<='z'))||((a>='0')&&(a<='9'))
+
+SWF swf;
+
+void DumpFont(SWFFONT * f,char * name)
+{ int gpos[MAX_CHAR_PER_FONT];
+ int n,i;
+
+ // Glyph Shapes Data
+
+ n = 0;
+ printf("U8 Glyphs_%s[] = {\n\t ",name);
+ memset(&gpos,0x00,sizeof(gpos));
+
+ for (i=0;i<MAX_CHAR_PER_FONT;i++)
+ if (f->glyph[i].shape)
+ { SHAPE * s = f->glyph[i].shape;
+ int j,l = (s->bitlen+7)/8;
+ gpos[i] = n;
+
+ for (j=0;j<l;j++)
+ { printf("0x%02x, ",s->data[j]);
+ if ((n&7)==7) printf("\n\t ");
+ n++;
+ }
+ }
+ printf("0x00 };\n");
+
+ // SWFFONT function
+
+ printf("\nSWFFONT * Font_%s(U16 id)\n",name);
+ printf("{ SWFFONT * f;\n int i;\n\n");
+ printf(" if (!(f=malloc(sizeof(SWFFONT)))) return NULL;\n");
+ printf(" memset(f,0x00,sizeof(SWFFONT));\n");
+ printf(" f->id = id;\n");
+ printf(" f->name = strdup(\"%s\");\n",f->name);
+ printf(" f->flags = 0x%02x;\n\n",f->flags);
+
+ for (i=0;i<MAX_CHAR_PER_FONT;i++)
+ if (f->glyph[i].shape)
+ { printf(" addGlyph(f,%3i, 0x%02x,%4i,%3i, &Glyphs_%s[0x%04x],%4i); // %c\n",
+ i, f->codes[i], f->glyph[i].advance, f->glyph[i].gid, name, gpos[i],
+ f->glyph[i].shape->bitlen,(i!='\\')?i:0x20);
+ }
+
+ printf(" return f;\n}\n\n");
+}
+
+void DumpGlobal(char * funcname)
+{ printf("\nvoid %s(SWFFONT * f,int i,U16 code,U16 advance,U16 gid,U8 * data,U32 bitlen)\n",funcname);
+ printf("{ SHAPE * s;\n U32 l = (bitlen+7)/8;\n\n");
+ printf(" if (FAILED(swf_ShapeNew(&s))) return;\n");
+ printf(" s->data = malloc(l);\n");
+ printf(" if (!s->data) { swf_ShapeFree(s); return; }\n\n");
+ printf(" f->codes[i] = code;\n");
+ printf(" f->glyph[i].advance = advance;\n");
+ printf(" f->glyph[i].gid = gid;\n");
+ printf(" f->glyph[i].shape = s;\n");
+ printf(" s->bitlen = bitlen;\n");
+ printf(" s->bits.fill = 1;\n");
+ printf(" memcpy(s->data,data,l);\n}\n\n");
+}
+
+
+void fontcallback(U16 id,U8 * name)
+{ SWFFONT * font;
+
+ int f;
+ char s[500],*ss;
+
+ swf_FontExtract(&swf,id,&font);
+ sprintf(s,"%s%s%s",name,swf_FontIsBold(font)?"_bold":"",swf_FontIsItalic(font)?"_italic":"");
+
+ ss = s;
+ while(ss[0])
+ { if ((*ss)==0x20) (*ss)='_';
+ ss++;
+ }
+
+ DumpFont(font,s);
+
+ swf_FontFree(font);
+}
+
+int main(int argc,char ** argv)
+{ int f;
+
+ if (argc>1)
+ { f = open(argv[1],O_RDONLY);
+ if (f>=0)
+ { if FAILED(swf_ReadSWF(f,&swf))
+ { fprintf(stderr,"%s is not a valid SWF file or contains errors.\n",argv[1]);
+ close(f);
+ }
+ else
+ { char fn[200];
+ close(f);
+ sprintf(fn,"fn%04x",getpid()); // avoid name conflicts @ using multiple fonts
+ printf("#define addGlyph %s\n",fn);
+ DumpGlobal(fn);
+ swf_FontEnumerate(&swf,&fontcallback);
+ swf_FreeTags(&swf);
+ printf("#undef addGlyph\n");
+ }
+ } else fprintf(stderr,"File not found: %s\n",argv[1]);
+ }
+ else fprintf(stderr,"\nreflex SWF Font Dump Utility\n(w) 2000 by Rainer Boehme <rb@reflex-studio.de>\n\nUsage: dumpfont filename.swf\n");
+
+ return 0;
+}
+