static void startshape(struct swfoutput* obj);
static void starttext(struct swfoutput* obj);
static void endshape();
-static void endtext();
+static void endtext(struct swfoutput* obj);
// matrix multiplication. changes p0
static void transform (plotxy*p0,struct swfmatrix*m)
if(chardatapos == CHARDATAMAX)
{
msg("<warning> Character buffer too small. SWF will be slightly bigger");
- endtext();
+ endtext(obj);
starttext(obj);
}
chardata[chardatapos].fontid = fontid;
/* process a character. */
static int drawchar(struct swfoutput*obj, SWFFONT *swffont, char*character, int charnr, int u, swfmatrix*m)
{
- int usefonts=1;
- if(m->m12!=0 || m->m21!=0)
- usefonts=0;
- if(m->m11 != m->m22)
- usefonts=0;
-
if(!swffont) {
msg("<warning> Font is NULL");
return 0;
}
- if(!usefonts) {
- msg("<verbose> Non diagonal font matrix: %f %f", m->m11, m->m21);
- msg("<verbose> | %f %f", m->m12, m->m22);
+ int charid = getCharID(swffont, charnr, character, u);
+
+ if(charid<0) {
+ msg("<warning> Didn't find character '%s' (c=%d,u=%d) in current charset (%s, %d characters)",
+ FIXNULL(character),charnr, u, FIXNULL((char*)swffont->name), swffont->numchars);
+ return 0;
}
- //if(usefonts && ! drawonlyshapes)
- if (1)
- {
- int charid = getCharID(swffont, charnr, character, u);
-
- if(charid<0) {
- msg("<warning> Didn't find character '%s' (c=%d,u=%d) in current charset (%s, %d characters)",
- FIXNULL(character),charnr, u, FIXNULL((char*)swffont->name), swffont->numchars);
- /*fontlist_t*it = fontlist;
- while(it) {
- msg("<warning> Font history: %s [%d]", it->swffont->name, getCharID(it->swffont, charnr, character, u));
- it = it->next;
- }*/
- return 0;
- }
-
- if(shapeid>=0)
- endshape();
- if(textid<0)
- starttext(obj);
+ if(shapeid>=0)
+ endshape();
+ if(textid<0)
+ starttext(obj);
- putcharacter(obj, swffont->id, charid,(int)(m->m13*20),(int)(m->m23*20),
- (int)(m->m11+0.5));
- swf_FontUseGlyph(swffont, charid);
+ float x = m->m13;
+ float y = m->m23;
+ float det = ((m->m11*m->m22)-(m->m21*m->m12));
+ if(fabs(det) < 0.0005) {
+ /* x direction equals y direction- the text is invisible */
return 1;
}
+ det = 20 / det;
+
+ SPOINT p;
+ p.x = (SCOORD)(( x * m->m22 - y * m->m12)*det);
+ p.y = (SCOORD)((- x * m->m21 + y * m->m11)*det);
+
+ putcharacter(obj, swffont->id, charid,p.x,p.y,1);
+ swf_FontUseGlyph(swffont, charid);
+ return 1;
+
/*else
{
SWF_OUTLINE*outline = font->getOutline(character, charnr);
m2.m22/=100;
if(textid>=0)
- endtext();
+ endtext(obj);
if(shapeid<0)
startshape(obj);
}*/
}
+static void endtext(swfoutput*obj)
+{
+ if(textid<0)
+ return;
+ putcharacters(tag);
+ swf_SetU8(tag,0);
+ tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
+ swf_ObjectPlace(tag,textid,/*depth*/depth++,&obj->fontmatrix,NULL,NULL);
+ textid = -1;
+}
+
+
/* draw a curved polygon. */
void swfoutput_drawpath(swfoutput*output, SWF_OUTLINE*outline,
struct swfmatrix*m)
{
if(textid>=0)
- endtext();
+ endtext(output);
/* Multiple polygons in one shape don't overlap correctly,
so we better start a new shape here if the polygon is filled
void swfoutput_drawpath2poly(struct swfoutput*output, SWF_OUTLINE*outline, struct swfmatrix*m, int line_join, int line_cap, double line_width, double miter_limit)
{
if(textid>=0)
- endtext();
+ endtext(output);
if(shapeid>=0)
endshape();
assert(shapeid<0);
obj->fontm21 == m21 &&
obj->fontm22 == m22)
return;
-// if(textid>=0)
-// endtext();
+ if(textid>=0)
+ endtext(obj);
obj->fontm11 = m11;
obj->fontm12 = m12;
obj->fontm21 = m21;
obj->fontm22 = m22;
+
+ MATRIX m;
+ m.sx = (U32)((obj->fontm11)*65536); m.r1 = (U32)((obj->fontm12)*65536);
+ m.r0 = (U32)((obj->fontm21)*65536); m.sy = (U32)((obj->fontm22)*65536);
+ m.tx = 0;
+ m.ty = 0;
+ obj->fontmatrix = m;
}
/* draws a character at x,y. */
SRECT r;
if(textid>=0)
- endtext();
+ endtext(obj);
tag = swf_InsertTag(tag,ST_DEFINESHAPE);
shapeid = ++currentswfid;
swf_SetU16(tag,shapeid); // ID
+ /* TODO: patch back */
r.xmin = 0;
r.ymin = 0;
r.xmax = 20*sizex;
MATRIX m;
if(shapeid>=0)
endshape();
+
tag = swf_InsertTag(tag,ST_DEFINETEXT);
textid = ++currentswfid;
swf_SetU16(tag, textid);
+ /* TODO: patch back */
r.xmin = 0;
r.ymin = 0;
r.xmax = 20*sizex;
swf_SetRect(tag,&r);
- m.sx = 65536;
- m.sy = 65536;
- m.r0 = 0;
- m.r1 = 0;
- m.tx = 0;
- m.ty = 0;
-
+ swf_GetMatrix(0, &m);
swf_SetMatrix(tag,&m);
swflastx=swflasty=0;
}
shapeid = -1;
}
-static void endtext()
-{
- if(textid<0)
- return;
- putcharacters(tag);
- swf_SetU8(tag,0);
- tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
- swf_ObjectPlace(tag,textid,/*depth*/depth++,NULL,NULL,NULL);
- textid = -1;
-}
-
static void endpage(struct swfoutput*obj)
{
if(shapeid>=0)
endshape();
if(textid>=0)
- endtext();
+ endtext(obj);
while(clippos)
swfoutput_endclip(obj);
void swfoutput_startclip(swfoutput*obj, SWF_OUTLINE*outline, struct swfmatrix*m)
{
if(textid>=0)
- endtext();
+ endtext(obj);
if(shapeid>=0)
endshape();
void swfoutput_endclip(swfoutput*obj)
{
if(textid>=0)
- endtext();
+ endtext(obj);
if(shapeid>=0)
endshape();
if(shapeid>=0)
endshape();
if(textid>=0)
- endtext();
+ endtext(obj);
if(opennewwindow)
actions = action_GetUrl(0, url, "_parent");
if(shapeid>=0)
endshape();
if(textid>=0)
- endtext();
+ endtext(obj);
actions = action_GotoFrame(0, page);
actions = action_End(actions);
if(shapeid>=0)
endshape();
if(textid>=0)
- endtext();
+ endtext(obj);
if(!strncmp(tmp, "call:", 5))
{
if(shapeid>=0)
endshape();
if(textid>=0)
- endtext();
+ endtext(obj);
int bitid = ++currentswfid;
oldtag = tag;
if(shapeid>=0)
endshape();
if(textid>=0)
- endtext();
+ endtext(obj);
int bitid = ++currentswfid;
oldtag = tag;
if(shapeid>=0)
endshape();
if(textid>=0)
- endtext();
+ endtext(obj);
int bitid = ++currentswfid;
oldtag = tag;
if(shapeid>=0)
endshape();
if(textid>=0)
- endtext();
+ endtext(obj);
if(sizex&3)
{
if(shapeid>=0)
endshape();
if(textid>=0)
- endtext();
+ endtext(obj);
drawimage(obj, id, sizex, sizey, x1,y1,x2,y2,x3,y3,x4,y4);
}