- standardtable[t] = strdup(name);
- msg("<debug> Char %d is named %s\n", t, name);
- }
-
- outline = (T1_OUTLINE**)malloc(charnum*sizeof(T1_OUTLINE*));
- charname = (char**)malloc(charnum*sizeof(char*));
- width = (int*)malloc(charnum*sizeof(int));
- memset(width, 0, charnum*sizeof(int));
- memset(charname, 0, charnum*sizeof(char*));
- used = (char*)malloc(charnum*sizeof(char));
- char2swfcharid = (U16*)malloc(charnum*2);
- swfcharid2char = (U16*)malloc(charnum*2);
- swfcharpos = 0;
-
- memset(used,0,charnum*sizeof(char));
-
- this->swfid = ++currentswfid;
-
- t=0;
- while(*a)
- {
- map[t] = strdup(*a);
- a++;
- t++;
- if(t==256 || !*a) {
- int s;
- for(s=t;s<256;s++)
- map[s] = ".notdef";
-
- int ret = T1_ReencodeFont(id, map);
- if(ret) {
- T1_DeleteFont(id);
- T1_LoadFont(id);
- int ret = T1_ReencodeFont(id, map);
- if(ret)
- fprintf(stderr,"Can't reencode font: (%s) ret:%d\n",filename, ret);
- /* Deleting the font invalidates the charname array,
- so we have to ask for it again now.
- We continue at the position we were, hoping the font
- didn't shrink in the meantime or something.
- */
- a = T1_GetAllCharNames(id) + (a - charnamebase);
- }
-
- // parsecharacters
- for(s=0;s<t;s++)
- {
- char* name = T1_GetCharName(id, s);
- if(!name) name = "";
- this->outline[outlinepos] = T1_CopyOutline(T1_GetCharOutline(id, s, 100.0, 0));
- this->width[outlinepos] = T1_GetCharWidth(id, s);
- this->charname[outlinepos] = strdup(name);
- outlinepos++;
- }
-
- for(s=0;s<t;s++)
- free(map[s]);
- t=0;
- }
- }
-}
-
-/* free all tables, write out definefont tags */
-SWFFont::~SWFFont()
-{
- int t,usednum=0;
- int*ptr;
-
- if(storeallcharacters)
- {
- int t;
- for(t=0;t<this->charnum;t++)
- {
- if(this->charname[t])
- getSWFCharID(this->charname[t], -1);
- }
- }
-
- ptr = (int*)malloc(swfcharpos*sizeof(int));
-
- for(t=0;t<charnum;t++)
- if(used[t]) usednum++;
-
- if(usednum && !drawonlyshapes)
- {
- msg("<verbose> Font %s has %d used characters",FIXNULL(fontid), usednum);
- TAG*ftag = swf_InsertTag(swf.firstTag,ST_DEFINEFONT);
- swf_SetU16(ftag, this->swfid);
- int initpos = swf_GetTagLen(ftag);
- swfmatrix m;
- m.m11 = m.m22 = 1;
- m.m21 = m.m12 = 0;
- m.m13 = CHARMIDX;
- m.m23 = CHARMIDY;
-
- for(t=0;t<swfcharpos;t++)
- {
- ptr[t] = swf_GetTagLen(ftag);
- swf_SetU16(ftag, 0x1234);
- }
- for(t=0;t<swfcharpos;t++)
- {
- *(U16*)&ftag->data[ptr[t]] =
- SWAP16(swf_GetTagLen(ftag)-initpos);
-
- swflastx=0;
- swflasty=0;
- swf_SetU8(ftag,0x10); //1 fill bits, 0 linestyle bits
- SHAPE s;
- s.bits.fill = 1;
- s.bits.line = 0;
- swf_ShapeSetStyle(ftag,&s,0,1,0);
- fillstylechanged = 1;
- int lastfill = fill;
- fill = 1;
- storefont = 1;
- drawpath(ftag, outline[swfcharid2char[t]],&m, 0);
- storefont = 0;
- fill = lastfill;
- swf_ShapeSetEnd(ftag);
- }
- ftag = swf_InsertTag(ftag,ST_DEFINEFONTINFO);
- swf_SetU16(ftag, this->swfid);
- if(this->fontid) {
- swf_SetU8(ftag, strlen(this->fontid));
- swf_SetBlock(ftag, (U8*)this->fontid, strlen(this->fontid));
- } else {
- swf_SetU8(ftag, 0);
- }
- swf_SetU8(ftag, 0); //flags
- for(t=0;t<swfcharpos;t++)
- {
- int s;
- char * name = this->charname[this->swfcharid2char[t]];
- for(s=0;s<256;s++) {
- if(standardEncodingNames[s] &&
- !strcmp(name,standardEncodingNames[s]))
- break;