Make my_draw_text() clip horizontally.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 19 Feb 2005 19:16:03 +0000 (19:16 +0000)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 19 Feb 2005 19:16:03 +0000 (19:16 +0000)
bigscreen/fonts.cpp

index e65e356..a2ac91b 100644 (file)
@@ -68,7 +68,9 @@ unsigned my_draw_text(const widestring &str, unsigned char *buf, double size, in
 
                                unsigned char *dst = buf + dsty * 800*4 + (x + xpos + slot->bitmap_left)*4;
                                unsigned char *src = bm->buffer + y * bm->width;
-                               for (xx = 0; xx < bm->width; xx++) {
+
+                               int width = (x + xpos + slot->bitmap_left + bm->width >= 800) ? (799 - x - xpos - slot->bitmap_left) : bm->width;
+                               for (xx = 0; xx < width; xx++) {
                                        *dst = (*dst * (256-*src) + r * *src) >> 8;
                                        *dst++;
                                        *dst = (*dst * (256-*src) + g * *src) >> 8;