+ while (*text_ptr)
+ {
+ char c = *text_ptr++;
+
+ if (c == '\n')
+ c = ' '; /* print space instead of newline */
+
+ getFontCharSource(font_nr, c, &src_bitmap, &src_x, &src_y);
+
+ /* 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 (dst_x + font_width > video.width)
+ break;
+
+ if (mask_mode == BLIT_INVERSE) /* special mode for text gadgets */
+ {
+ /* first step: draw solid colored rectangle (use "cursor" character) */
+ if (strlen(text) == 1) /* only one char inverted => draw cursor */
+ {
+ Bitmap *cursor_bitmap;
+ int cursor_x, cursor_y;
+
+ getFontCharSource(font_nr, FONT_ASCII_CURSOR, &cursor_bitmap,
+ &cursor_x, &cursor_y);
+
+ BlitBitmap(cursor_bitmap, dst_bitmap, cursor_x, cursor_y,
+ font_width, font_height, dst_x, dst_y);
+ }
+
+ /* second step: draw masked inverted character */
+ SDLCopyInverseMasked(src_bitmap, dst_bitmap, src_x, src_y,
+ font_width, font_height, dst_x, dst_y);
+ }
+ else if (mask_mode == BLIT_MASKED || mask_mode == BLIT_ON_BACKGROUND)
+ {
+ if (mask_mode == BLIT_ON_BACKGROUND)
+ {
+ /* clear font character background */
+ ClearRectangleOnBackground(dst_bitmap, dst_x, dst_y,
+ font_width, font_height);
+ }
+
+ BlitBitmapMasked(src_bitmap, dst_bitmap, src_x, src_y,
+ font_width, font_height, dst_x, dst_y);
+ }
+ else /* normal, non-masked font blitting */
+ {
+ BlitBitmap(src_bitmap, dst_bitmap, src_x, src_y,
+ font_width, font_height, dst_x, dst_y);
+ }
+
+ dst_x += font_width;
+ }
+}
+
+
+/* ========================================================================= */
+/* text buffer drawing functions */
+/* ========================================================================= */
+
+#define MAX_LINES_FROM_FILE 1024
+
+char *GetTextBufferFromFile(char *filename, int max_lines)
+{
+ File *file;
+ char *buffer;
+ int num_lines = 0;