X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fexample%2Fdumpfont.c;h=8d38b8e056c25146bb848fc3c603c71f2cfcb605;hb=6feed80959ad2c11f0427bf0e5a30aab8abd7083;hp=aeb73fbb0d6b681225c63a585000f53635453994;hpb=5a8551400347ebdfdc8ed343fe02f992eaf3ee7a;p=swftools.git diff --git a/lib/example/dumpfont.c b/lib/example/dumpfont.c index aeb73fb..8d38b8e 100644 --- a/lib/example/dumpfont.c +++ b/lib/example/dumpfont.c @@ -9,23 +9,31 @@ 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 - This file is distributed under the GPL, see file COPYING for details + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -*/ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include "../rfxswf.h" -#define PRINTABLE(a) ((a>='A')&&(a<='Z'))||((a>='a')&&(a<='z'))||((a>='0')&&(a<='9')) +#define PRINTABLE(a) (((a>0x20)&&(a<0xff)&&(a!='\\'))?a:0x20) SWF swf; @@ -62,16 +70,41 @@ void DumpFont(SWFFONT * f,char * name) printf(" f->id = id;\n"); printf(" f->version = %d;\n", f->version); printf(" f->name = strdup(\"%s\");\n",f->name); - printf(" f->flags = 0x%02x;\n",f->flags); + printf(" f->style = 0x%02x;\n",f->style); + printf(" f->encoding = 0x%02x;\n",f->encoding); printf(" f->numchars = %d;\n",f->numchars); - printf(" f->glyph = (SWFGLYPH*)malloc(sizeof(SWFGLYPH)*%d);\n\n",f->numchars); - printf(" f->codes = (U16*)malloc(sizeof(U16)*%d);\n\n",f->numchars); + printf(" f->maxascii = %d;\n",f->maxascii); + printf(" f->glyph = (SWFGLYPH*)malloc(sizeof(SWFGLYPH)*%d);\n",f->numchars); + printf(" f->glyph2ascii = (U16*)malloc(sizeof(U16)*%d);\n",f->numchars); + printf(" f->ascii2glyph = (int*)malloc(sizeof(int)*%d);\n",f->maxascii); + printf(" memset(f->ascii2glyph, -1, sizeof(int)*%d);\n\n", f->maxascii); + if(f->layout) { + printf(" f->layout = (SWFLAYOUT*)malloc(sizeof(SWFLAYOUT));\n"); + printf(" f->layout->ascent = %d;\n", f->layout->ascent); + printf(" f->layout->descent = %d;\n", f->layout->descent); + printf(" f->layout->leading = %d;\n", f->layout->leading); + printf(" f->layout->kerningcount = 0;\n"); + printf(" f->layout->kerning = 0;\n"); + printf(" f->layout->bounds = (SRECT*)malloc(sizeof(SRECT)*%d);\n", f->numchars); + printf(" memset(f->layout->bounds, 0, sizeof(SRECT)*%d);\n\n", f->numchars); + } for (i=0;inumchars;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(" addGlyph(f,%3i, 0x%03x,%4i, &Glyphs_%s[0x%04x], %4i, ", + i, f->glyph2ascii[i], f->glyph[i].advance, name, gpos[i], + f->glyph[i].shape->bitlen); + if(f->layout && f->layout->bounds) { + printf("%d, %d, %d, %d);", + f->layout->bounds[i].xmin, + f->layout->bounds[i].ymin, + f->layout->bounds[i].xmax, + f->layout->bounds[i].ymax); + } else { + printf("/* bbox not set */ 0, 0, 0, 0);"); + } + printf(" // %c\n", PRINTABLE(f->glyph2ascii[i])); } printf(" return f;\n}\n\n"); @@ -79,17 +112,23 @@ void DumpFont(SWFFONT * f,char * name) } void DumpGlobal(char * funcname) -{ printf("\nvoid %s(SWFFONT * f,int i,U16 code,U16 advance,U16 gid,U8 * data,U32 bitlen)\n",funcname); +{ printf("\nvoid %s(SWFFONT * f,int i,U16 ascii,U16 advance,U8 * data,U32 bitlen,int xmin,int ymin,int xmax, int ymax)\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(" f->glyph2ascii[i] = ascii;\n"); + printf(" f->ascii2glyph[ascii] = i;\n"); + printf(" f->glyph[i].advance = advance;\n"); + printf(" f->glyph[i].shape = s;\n"); + printf(" s->bitlen = bitlen;\n"); + printf(" s->bits.fill = 1;\n"); + printf(" if(f->layout && f->layout->bounds)\n"); + printf(" { f->layout->bounds[i].xmin = xmin;\n"); + printf(" f->layout->bounds[i].ymin = ymin;\n"); + printf(" f->layout->bounds[i].xmax = xmax;\n"); + printf(" f->layout->bounds[i].ymax = ymax;\n"); + printf(" }\n"); printf(" memcpy(s->data,data,l);\n}\n\n"); }