- else
- { int i;
- int buf[256];
- for (i=0;i<flags;i++)
- { int glyph;
- int adv;
- glyph = swf_GetBits(t,gbits);
- adv = swf_GetBits(t,abits);
- if (id==fid) // mitlesen ?
- if (jobs&FEDTJ_PRINT) {
- { int code = f->glyph2ascii[glyph];
- printf("%c",code);
- }
- if (jobs&FEDTJ_MODIFY)
- /*if (!f->glyph[code].advance)*/ f->glyph[glyph].advance = adv;
+
+ return id;
+}
+
+int swf_ParseDefineText(TAG * tag,
+ void (*callback) (void *self, int *chars, int *ypos, int nr, int fontid, int fontsize, int xstart, int ystart, RGBA * color), void *self)
+{
+ return swf_FontExtract_DefineTextCallback(-1, 0, tag, FEDTJ_CALLBACK, callback, self);
+}
+
+int swf_FontExtract_DefineText(int id, SWFFONT * f, TAG * t, int jobs)
+{
+ return swf_FontExtract_DefineTextCallback(id, f, t, jobs, 0, 0);
+}
+
+int swf_FontExtract(SWF * swf, int id, SWFFONT * *font)
+{
+ TAG *t;
+ SWFFONT *f;
+
+ if ((!swf) || (!font))
+ return -1;
+
+ f = (SWFFONT *) rfx_calloc(sizeof(SWFFONT));
+
+ t = swf->firstTag;
+
+ while (t) {
+ int nid = 0;
+ switch (swf_GetTagID(t)) {
+ case ST_DEFINEFONT:
+ nid = swf_FontExtract_DefineFont(id, f, t);
+ break;
+
+ case ST_DEFINEFONT2:
+ nid = swf_FontExtract_DefineFont2(id, f, t);
+ break;
+
+ case ST_DEFINEFONTINFO:
+ case ST_DEFINEFONTINFO2:
+ nid = swf_FontExtract_DefineFontInfo(id, f, t);
+ break;
+
+ case ST_DEFINETEXT:
+ case ST_DEFINETEXT2:
+ nid = swf_FontExtract_DefineText(id, f, t, f->layout ? 0 : FEDTJ_MODIFY);
+ break;
+
+ case ST_GLYPHNAMES:
+ nid = swf_FontExtract_GlyphNames(id, f, t);
+ break;
+ }
+ if (nid > 0)
+ id = nid;
+ t = swf_NextTag(t);
+ }
+ if (f->id != id) {
+ rfx_free(f);
+ f = 0;
+ }
+ font[0] = f;
+ return 0;
+}
+
+int swf_FontSetID(SWFFONT * f, U16 id)
+{
+ if (!f)
+ return -1;
+ f->id = id;
+ return 0;
+}
+
+void swf_LayoutFree(SWFLAYOUT * l)
+{
+ if (l) {
+ if (l->kerning)
+ rfx_free(l->kerning);
+ l->kerning = NULL;
+ if (l->bounds)
+ rfx_free(l->bounds);
+ l->bounds = NULL;
+ }
+ rfx_free(l);
+}
+
+
+static void font_freeglyphnames(SWFFONT*f)
+{
+ if (f->glyphnames)
+ {
+ int t;
+ for (t = 0; t < f->numchars; t++)
+ {
+ if (f->glyphnames[t])
+ {
+ rfx_free(f->glyphnames[t]);
+ f->glyphnames[t] = 0;
+ }