- /* for newline, we don't print an error. FIXME: We shouldn't get newlines here
- in the first place
- */
- if(character != '\n') {
- logf("<error> Char to set is not defined!");
- logf("<error> - font file is %s\n", font->getName());
- logf("<error> - char 0x%02x is named %s\n",character, charname);
- }
- return;
+ charstorepos = 0;
+ lastfontid = -1;
+ lastx = CHARMIDX;
+ lasty = CHARMIDY;
+ lastsize = -1;
+
+ if(pass==1)
+ {
+ advancebits++; // add sign bit
+ SetU8(tag, glyphbits);
+ SetU8(tag, advancebits);
+ }
+
+ for(t=0;t<=chardatapos;t++)
+ {
+ if(lastfontid != chardata[t].fontid ||
+ lastx!=chardata[t].x ||
+ lasty!=chardata[t].y ||
+ !colorcompare(&color, &chardata[t].color) ||
+ charstorepos==127 ||
+ lastsize != chardata[t].size ||
+ t == chardatapos)
+ {
+ if(charstorepos && pass==0)
+ {
+ int s;
+ for(s=0;s<charstorepos;s++)
+ {
+ while(charids[s]>=(1<<glyphbits))
+ glyphbits++;
+ while(charadvance[s]>=(1<<advancebits))
+ advancebits++;
+ }
+ }
+ if(charstorepos && pass==1)
+ {
+ tag->bitcount = 0;
+ SetBits(tag, 0, 1); // GLYPH Record
+ SetBits(tag, charstorepos, 7); // number of glyphs
+ int s;
+ for(s=0;s<charstorepos;s++)
+ {
+ SetBits(tag, charids[s], glyphbits);
+ SetBits(tag, charadvance[s], advancebits);
+ }
+ }
+ charstorepos = 0;
+
+ if(pass == 1 && t<chardatapos)
+ {
+ RGBA*newcolor=0;
+ SWFFONT*newfont=0;
+ int newx = 0;
+ int newy = 0;
+ if(lastx != chardata[t].x ||
+ lasty != chardata[t].y)
+ {
+ newx=chardata[t].x;
+ newy=chardata[t].y;
+ }
+ if(!colorcompare(&color, &chardata[t].color))
+ {
+ color = chardata[t].color;
+ newcolor = &color;
+ }
+ font.id = chardata[t].fontid;
+ if(lastfontid != chardata[t].fontid || lastsize != chardata[t].size)
+ newfont = &font;
+
+ tag->bitcount = 0;
+ TextSetInfoRecord(tag, newfont, chardata[t].size, newcolor, newx,newy);
+ }
+
+ lastfontid = chardata[t].fontid;
+ lastx = chardata[t].x;
+ lasty = chardata[t].y;
+ lastsize = chardata[t].size;
+ }
+
+ if(t==chardatapos)
+ break;
+
+ int advance;
+ int nextt = t==chardatapos-1?t:t+1;
+ int rel = chardata[nextt].x-chardata[t].x;
+ if(rel>=0 && (rel<(1<<(advancebits-1)) || pass==0)) {
+ advance = rel;
+ lastx=chardata[nextt].x;
+ }
+ else {
+ advance = 0;
+ lastx=chardata[t].x;
+ }
+ charids[charstorepos] = chardata[t].charid;
+ charadvance[charstorepos] = advance;
+ charstorepos ++;
+ }