+typedef struct _usagetmp {
+ SWFFONT*font;
+ int lastx,lasty;
+ int last;
+} usagetmp_t;
+static void updateusage(void *self, int *chars, int *xpos, int nr,
+ int fontid, int fontsize, int xstart, int ystart, RGBA * color)
+{
+ usagetmp_t*u = (usagetmp_t*)self;
+ if(!u->font->use) {
+ swf_FontInitUsage(u->font);
+ }
+ if(fontid!=u->font->id)
+ return;
+
+ int t;
+ for(t=0;t<nr;t++) {
+ int x=xpos[t];
+ int y=ystart;
+ int c = chars[t];
+ if(c<0 || c>u->font->numchars)
+ continue;
+ swf_FontUseGlyph(u->font, c, fontsize);
+ if(u->lasty == y && x>=u->lastx-200 && abs(u->lastx-x)<200 &&
+ u->last!=c && !swf_ShapeIsEmpty(u->font->glyph[u->last].shape) &&
+ !swf_ShapeIsEmpty(u->font->glyph[c].shape))
+ {
+ swf_FontUsePair(u->font, u->last, c);
+ }
+ u->lasty = y;
+ /* FIXME: do we still need to divide advance by 20 for definefont3? */
+ u->lastx = x + (u->font->glyph[c].advance*fontsize/20480);
+ u->last = c;
+ }
+}
+
+void swf_FontUpdateUsage(SWFFONT*f, TAG* tag)
+{
+ usagetmp_t u;
+ u.font = f;
+ u.lastx = -0x80000000;
+ u.lasty = -0x80000000;
+ u.last = 0;
+ swf_ParseDefineText(tag, updateusage, &u);
+}
+