static const int WRITEFONTID = 0x4e46; // font id for WriteFont and ReadFont
-int swf_FontEnumerate(SWF * swf, void (*FontCallback) (U16, U8 *))
+int swf_FontEnumerate(SWF * swf, void (*FontCallback) (void*, U16, U8 *), void*self)
{
int n;
TAG *t;
s[l] = 0;
}
- (FontCallback) (id, s);
+ (FontCallback) (self, id, s);
swf_RestoreTagPos(t);
}
static int
swf_FontExtract_DefineTextCallback(int id, SWFFONT * f, TAG * t, int jobs,
void (*callback) (void *self,
- int *chars, int *ypos, int nr, int fontid, int fontsize, int xstart, int ystart, RGBA * color), void *self)
+ int *chars, int *xpos, int nr, int fontid, int fontsize, int xstart, int ystart, RGBA * color), void *self)
{
U16 cid;
SRECT r;
swf_SetRGB(t, color);
}
if (dx) {
- if(dx>32767 || dx<-32768)
- fprintf(stderr, "Warning: Horizontal char position overflow: %d\n", dx);
- swf_SetS16(t, dx);
+ if(dx != SET_TO_ZERO) {
+ if(dx>32767 || dx<-32768)
+ fprintf(stderr, "Warning: Horizontal char position overflow: %d\n", dx);
+ swf_SetS16(t, dx);
+ } else {
+ swf_SetS16(t, 0);
+ }
}
if (dy) {
- if(dy>32767 || dy<-32768)
- fprintf(stderr, "Warning: Vertical char position overflow: %d\n", dy);
- swf_SetS16(t, dy);
+ if(dy != SET_TO_ZERO) {
+ if(dy>32767 || dy<-32768)
+ fprintf(stderr, "Warning: Vertical char position overflow: %d\n", dy);
+ swf_SetS16(t, dy);
+ } else {
+ swf_SetS16(t, 0);
+ }
}
if (font)
swf_SetU16(t, size);
SRECT swf_TextCalculateBBoxUTF8(SWFFONT * font, U8 * s, int scale)
{
- int pos = 0;
+ int xpos = 0;
+ int ypos = 0;
SRECT r;
swf_GetRect(0, &r);
while (*s) {
int g = font->ascii2glyph[c];
if (g >= 0) {
SRECT rn = font->layout->bounds[g];
- rn.xmin = (rn.xmin * scale) / 20 / 100 + pos;
- rn.xmax = (rn.xmax * scale) / 20 / 100 + pos;
- rn.ymin = (rn.ymin * scale) / 20 / 100;
- rn.ymax = (rn.ymax * scale) / 20 / 100;
+ rn.xmin = (rn.xmin * scale) / 20 / 100 + xpos;
+ rn.xmax = (rn.xmax * scale) / 20 / 100 + xpos;
+ rn.ymin = (rn.ymin * scale) / 20 / 100 + ypos;
+ rn.ymax = (rn.ymax * scale) / 20 / 100 + ypos;
swf_ExpandRect2(&r, &rn);
- pos += (font->glyph[g].advance * scale) / 20 / 100;
+ xpos += (font->glyph[g].advance * scale) / 20 / 100;
}
}
c++;