// (c) 1995-2014 by Artsoft Entertainment
// Holger Schemel
// info@artsoft.org
-// http://www.artsoft.org/
+// https://www.artsoft.org/
// ----------------------------------------------------------------------------
// text.c
// ============================================================================
// simple text drawing functions
// ============================================================================
-void DrawInitText(char *text, int ypos, int font_nr)
+static void DrawInitTextExt(char *text, int ypos, int font_nr, boolean update)
{
LimitScreenUpdates(TRUE);
int width = video.width;
int height = getFontHeight(font_nr);
- ClearRectangle(drawto, 0, y, width, height);
- DrawTextExt(drawto, x, y, text, font_nr, BLIT_OPAQUE);
+ ClearRectangleOnBackground(drawto, 0, y, width, height);
+ DrawTextExt(drawto, x, y, text, font_nr, BLIT_MASKED);
- BlitBitmap(drawto, window, 0, 0, video.width, video.height, 0, 0);
+ if (update)
+ BlitBitmap(drawto, window, 0, 0, video.width, video.height, 0, 0);
}
}
+void DrawInitText(char *text, int ypos, int font_nr)
+{
+ DrawInitTextExt(text, ypos, font_nr, FALSE);
+}
+
+void DrawInitTextHead(char *text)
+{
+ DrawInitTextExt(text, 120, FC_GREEN, FALSE);
+}
+
+void DrawInitTextItem(char *text)
+{
+ DrawInitTextExt(text, 150, FC_YELLOW, TRUE);
+}
+
void DrawTextF(int x, int y, int font_nr, char *format, ...)
{
char buffer[MAX_OUTPUT_LINESIZE + 1];
va_end(ap);
if (strlen(buffer) > MAX_OUTPUT_LINESIZE)
- Error(ERR_EXIT, "string too long in DrawTextF() -- aborting");
+ Fail("string too long in DrawTextF() -- aborting");
DrawText(gfx.sx + x, gfx.sy + y, buffer, font_nr);
}
va_end(ap);
if (strlen(buffer) > MAX_OUTPUT_LINESIZE)
- Error(ERR_EXIT, "string too long in DrawTextFCentered() -- aborting");
+ Fail("string too long in DrawTextFCentered() -- aborting");
DrawText(gfx.sx + (gfx.sxsize - getTextWidth(buffer, font_nr)) / 2,
gfx.sy + y, buffer, font_nr);
closeFile(file);
+ if (getTextEncoding(buffer) == TEXT_ENCODING_UTF_8)
+ {
+ char *body_latin1 = getLatin1FromUTF8(buffer);
+
+ checked_free(buffer);
+
+ buffer = body_latin1;
+ }
+
return buffer;
}
return current_line;
}
+int DrawTextBufferS(int x, int y, char *text_buffer, int font_nr,
+ int line_length, int cut_length, int max_lines,
+ int line_spacing, int mask_mode, boolean autowrap,
+ boolean centered, boolean parse_comments)
+{
+ return DrawTextBuffer(gfx.sx + x, gfx.sy + y, text_buffer, font_nr,
+ line_length, cut_length, max_lines,
+ line_spacing, mask_mode, autowrap,
+ centered, parse_comments);
+}
+
int DrawTextBufferVA(int x, int y, char *format, va_list ap, int font_nr,
int line_length, int cut_length, int max_lines,
int line_spacing, int mask_mode, boolean autowrap,
int text_length = vsnprintf(text_buffer, MAX_OUTPUT_LINESIZE, format, ap);
if (text_length >= MAX_OUTPUT_LINESIZE)
- Error(ERR_WARN, "string too long in DrawTextBufferVA() -- truncated");
+ Warn("string too long in DrawTextBufferVA() -- truncated");
int num_lines_printed = DrawTextBuffer(x, y, text_buffer, font_nr,
line_length, cut_length, max_lines,