X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fmodules%2Fswftext.c;h=8d61e0496b25516929dcea692eabac3b38a0a928;hb=1b92dcdf739c6b827ac037ce74a9d9df0fc857a8;hp=cb55d760285bc824ee92f3d7e9030852b7589f4e;hpb=5d8d800fc5ba13dadea83dd0ca63bfe1211d9372;p=swftools.git diff --git a/lib/modules/swftext.c b/lib/modules/swftext.c index cb55d76..8d61e04 100644 --- a/lib/modules/swftext.c +++ b/lib/modules/swftext.c @@ -6,6 +6,7 @@ Part of the swftools package. Copyright (c) 2001 Rainer Böhme + Copyright (c) 2003,2004 Matthias Kramm 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 @@ -174,6 +175,31 @@ int swf_FontExtract_DefineFontInfo(int id,SWFFONT * f,TAG * t) return id; } +int swf_FontExtract_GlyphNames(int id,SWFFONT * f,TAG * tag) +{ + U16 fid; + U16 maxcode; + U8 flags; + swf_SaveTagPos(tag); + swf_SetTagPos(tag,0); + + fid = swf_GetU16(tag); + + if (fid==id) + { + int num = swf_GetU16(tag); + int t; + f->glyphnames = malloc(sizeof(char*)*num); + for(t=0;tglyphnames[t] = strdup(swf_GetString(tag)); + } + } + + swf_RestoreTagPos(tag); + return id; +} + + int swf_FontExtract_DefineFont2(int id,SWFFONT * font,TAG * tag) { int t, glyphcount; @@ -400,6 +426,10 @@ int swf_FontExtract(SWF * swf,int id,SWFFONT * * font) 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); @@ -830,6 +860,7 @@ void swf_WriteFont(SWFFONT*font, char* filename) RGBA rgb; int f; int useDefineFont2 = 0; + int storeGlyphNames = 1; if(font->layout) useDefineFont2 = 1; /* the only thing new in definefont2 @@ -865,6 +896,17 @@ void swf_WriteFont(SWFFONT*font, char* filename) swf_FontSetDefine2(t,font); } + if(storeGlyphNames) + { + int c; + t = swf_InsertTag(t,ST_GLYPHNAMES); + swf_SetU16(t, font->id); + swf_SetU16(t, font->numchars); + for(c=0;cnumchars;c++) { + swf_SetString(t, font->glyphnames[c]); + } + } + if(1) //neccessary only for df1, but pretty to look at anyhow, so do it always { int textscale = 400; @@ -1159,11 +1201,12 @@ void swf_DrawText(drawer_t*draw, SWFFONT*font, char*text) while(*s) { SHAPE*shape; SHAPE2*shape2; + SHAPELINE*l; U32 c = readUTF8char(&s); int g = font->ascii2glyph[c]; shape = font->glyph[g].shape; shape2 = swf_ShapeToShape2(shape); - SHAPELINE*l = shape2->lines; + l = shape2->lines; while(l) { if(l->type == moveTo) { FPOINT to;