+ if (s->fix_bounds) {
+
+ /* calculate footprint of text effects */
+ int boxoffset = s->draw_box ? FFMAX(s->boxborderw, 0) : 0;
+ int borderoffset = s->borderw ? FFMAX(s->borderw, 0) : 0;
+
+ int offsetleft = FFMAX3(boxoffset, borderoffset,
+ (s->shadowx < 0 ? FFABS(s->shadowx) : 0));
+ int offsettop = FFMAX3(boxoffset, borderoffset,
+ (s->shadowy < 0 ? FFABS(s->shadowy) : 0));
+
+ int offsetright = FFMAX3(boxoffset, borderoffset,
+ (s->shadowx > 0 ? s->shadowx : 0));
+ int offsetbottom = FFMAX3(boxoffset, borderoffset,
+ (s->shadowy > 0 ? s->shadowy : 0));
+
+
+ if (s->x - offsetleft < 0) s->x = offsetleft;
+ if (s->y - offsettop < 0) s->y = offsettop;
+
+ if (s->x + box_w + offsetright > width)
+ s->x = FFMAX(width - box_w - offsetright, 0);
+ if (s->y + box_h + offsetbottom > height)
+ s->y = FFMAX(height - box_h - offsetbottom, 0);
+ }
+