+/* sets the matrix which is to be applied to characters drawn by swfoutput_drawchar() */
+static void setfontscale(gfxdevice_t*dev,double m11,double m12, double m21,double m22,double x, double y, char force)
+{
+ m11 *= 1024;
+ m12 *= 1024;
+ m21 *= 1024;
+ m22 *= 1024;
+ swfoutput_internal*i = (swfoutput_internal*)dev->internal;
+ if(i->lastfontm11 == m11 &&
+ i->lastfontm12 == m12 &&
+ i->lastfontm21 == m21 &&
+ i->lastfontm22 == m22 && !force)
+ return;
+ if(i->textmode)
+ endtext(dev);
+
+ i->lastfontm11 = m11;
+ i->lastfontm12 = m12;
+ i->lastfontm21 = m21;
+ i->lastfontm22 = m22;
+
+ double xsize = sqrt(m11*m11 + m12*m12);
+ double ysize = sqrt(m21*m21 + m22*m22);
+
+ int extrazoom = 1;
+ if(i->config_flashversion>=8 && !NO_FONT3)
+ extrazoom = 20;
+
+ i->current_font_size = (xsize>ysize?xsize:ysize)*extrazoom;
+ if(i->current_font_size < 1)
+ i->current_font_size = 1;
+
+ MATRIX m;
+ swf_GetMatrix(0, &m);
+
+ if(m21 || m12 || fabs(m11+m22)>0.001) {
+ double ifs = (double)extrazoom/(i->current_font_size);
+ m.sx = (S32)((m11*ifs)*65536); m.r1 = -(S32)((m21*ifs)*65536);
+ m.r0 = (S32)((m12*ifs)*65536); m.sy = -(S32)((m22*ifs)*65536);
+ }
+
+ /* this is the position of the first char to set a new fontmatrix-
+ we hope that it's close enough to all other characters using the
+ font, so we use its position as origin for the matrix */
+ m.tx = x*20;
+ m.ty = y*20;
+ i->fontmatrix = m;
+}
+
+