X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Flibgame%2Ftext.c;h=61800916ad91b2f2c18d6c92cae91d12c91e74a0;hp=890d1886a711ab00751b50798ac98495241a0965;hb=6ed4958820f8f97174ca47594dcc6f00ee31b2cb;hpb=72657dfeee6b6c184a42e83ed923a63c1768100b diff --git a/src/libgame/text.c b/src/libgame/text.c index 890d1886..61800916 100644 --- a/src/libgame/text.c +++ b/src/libgame/text.c @@ -135,6 +135,29 @@ int getFontHeight(int font_nr) return gfx.font_bitmap_info[font_bitmap_id].height; } +boolean getFontChar(int font_nr, char c, int *src_x, int *src_y) +{ + int font_bitmap_id = gfx.select_font_function(font_nr); + struct FontBitmapInfo *font = &gfx.font_bitmap_info[font_bitmap_id]; + + if ((c >= 32 && c <= 95) || c == '°' || c == '´' || c == '|') + { + *src_x = font->src_x + ((c - 32) % FONT_CHARS_PER_LINE) * font->width; + *src_y = font->src_y + ((c - 32) / FONT_CHARS_PER_LINE) * font->height; + + /* map '°' and 'TM' signs and cursor */ + if (c == '°' || c == '´' || c == '|') + { + *src_x = font->src_x + FONT_CHARS_PER_LINE * font->width; + *src_y = font->src_y + (c == '°' ? 1 : c == '´' ? 2 : 3) * font->height; + } + + return TRUE; + } + + return FALSE; +} + void DrawInitText(char *text, int ypos, int font_nr) { if (window && @@ -202,6 +225,8 @@ void DrawTextExt(DrawBuffer *dst_bitmap, int dst_x, int dst_y, char *text, int font_bitmap_id = gfx.select_font_function(font_nr); struct FontBitmapInfo *font = &gfx.font_bitmap_info[font_bitmap_id]; boolean print_inverse = FALSE; + boolean print_inverse_cursor = FALSE; + int src_x, src_y; if (font->bitmap == NULL) return; @@ -217,6 +242,9 @@ void DrawTextExt(DrawBuffer *dst_bitmap, int dst_x, int dst_y, char *text, if (c == '~') { print_inverse = TRUE; + if (strlen(text) == 1) + print_inverse_cursor = TRUE; + continue; } @@ -233,6 +261,10 @@ void DrawTextExt(DrawBuffer *dst_bitmap, int dst_x, int dst_y, char *text, else if (c == '\\') /* bad luck ... */ c = '/'; +#if 1 + if (getFontChar(font_nr, c, &src_x, &src_y)) + { +#else if ((c >= 32 && c <= 95) || c == '°' || c == '´' || c == '|') { int src_x= font->src_x + ((c - 32) % FONT_CHARS_PER_LINE) * font->width; @@ -243,14 +275,16 @@ void DrawTextExt(DrawBuffer *dst_bitmap, int dst_x, int dst_y, char *text, src_x = font->src_x + FONT_CHARS_PER_LINE * font->width; src_y = font->src_y + (c == '°' ? 1 : c == '´' ? 2 : 3) * font->height; } +#endif if (print_inverse) /* special mode for text gadgets */ { /* first step: draw solid colored rectangle (use "cursor" character) */ - BlitBitmap(font->bitmap, dst_bitmap, - font->src_x + FONT_CHARS_PER_LINE * font->width, - font->src_y + 3 * font->height, - font->width, font->height, dst_x, dst_y); + if (print_inverse_cursor) + BlitBitmap(font->bitmap, dst_bitmap, + font->src_x + FONT_CHARS_PER_LINE * font->width, + font->src_y + 3 * font->height, + font->width, font->height, dst_x, dst_y); /* second step: draw masked black rectangle (use "space" character) */ SetClipOrigin(font->bitmap, font->bitmap->stored_clip_gc,