X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Ftext.c;h=bfd2a7c4bdf0dde187a768591dba61ea32776b57;hb=e05dda5c8cc6687dcbc59e182a81aed627e262d0;hp=de70abc34c6faeb0289e2330ec0cc0347a9981a1;hpb=fa628a204ea4662806244b0ed994a48b40ece2ca;p=rocksndiamonds.git diff --git a/src/libgame/text.c b/src/libgame/text.c index de70abc3..bfd2a7c4 100644 --- a/src/libgame/text.c +++ b/src/libgame/text.c @@ -1,7 +1,7 @@ /*********************************************************** * Artsoft Retro-Game Library * *----------------------------------------------------------* -* (c) 1994-2002 Artsoft Entertainment * +* (c) 1994-2006 Artsoft Entertainment * * Holger Schemel * * Detmolder Strasse 189 * * 33604 Bielefeld * @@ -130,6 +130,13 @@ void FreeFontInfo(struct FontBitmapInfo *font_bitmap_info) free(font_bitmap_info); } +struct FontBitmapInfo *getFontBitmapInfo(int font_nr) +{ + int font_bitmap_id = gfx.select_font_function(font_nr); + + return &gfx.font_bitmap_info[font_bitmap_id]; +} + int getFontWidth(int font_nr) { int font_bitmap_id = gfx.select_font_function(font_nr); @@ -255,19 +262,25 @@ void DrawTextExt(DrawBuffer *dst_bitmap, int dst_x, int dst_y, char *text, struct FontBitmapInfo *font = &gfx.font_bitmap_info[font_bitmap_id]; int font_width = getFontWidth(font_nr); int font_height = getFontHeight(font_nr); +#if 0 int border_1 = gfx.sx + gfx.sxsize; int border_2 = gfx.dx + gfx.dxsize; + int dst_x_start = dst_x; +#endif Bitmap *src_bitmap; int src_x, src_y; - int dst_x_start = dst_x; char *text_ptr = text; if (font->bitmap == NULL) return; + /* skip text to be printed outside the window (left/right will be clipped) */ + if (dst_y < 0 || dst_y + font_height > video.height) + return; + /* add offset for drawing font characters */ - dst_x += font->draw_x; - dst_y += font->draw_y; + dst_x += font->draw_xoffset; + dst_y += font->draw_yoffset; while (*text_ptr) { @@ -278,10 +291,24 @@ void DrawTextExt(DrawBuffer *dst_bitmap, int dst_x, int dst_y, char *text, getFontCharSource(font_nr, c, &src_bitmap, &src_x, &src_y); - /* make sure that text does not run off the screen at the right side */ + /* clip text at the left side of the window */ + if (dst_x < 0) + { + dst_x += font_width; + + continue; + } + + /* clip text at the right side of the window */ +#if 1 + if (dst_x + font_width > video.width) + break; +#else + /* (this does not work well when trying to print text to whole screen) */ if ((dst_x_start < border_1 && dst_x + font_width > border_1) || (dst_x_start < border_2 && dst_x + font_width > border_2)) break; +#endif if (mask_mode == BLIT_INVERSE) /* special mode for text gadgets */ {