rnd-20030404-3-src
[rocksndiamonds.git] / src / libgame / text.c
index 61800916ad91b2f2c18d6c92cae91d12c91e74a0..e21acc03955d46c6db0ef61fb2f246968fd93a22 100644 (file)
@@ -115,12 +115,18 @@ void InitFontInfo(struct FontBitmapInfo *font_bitmap_info, int num_fonts,
   gfx.num_fonts = num_fonts;
   gfx.font_bitmap_info = font_bitmap_info;
   gfx.select_font_function = select_font_function;
+  gfx.inverse_text_color = WHITE_PIXEL;
 
 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
   InitFontClipmasks();
 #endif
 }
 
+void SetInverseTextColor(Pixel inverse_text_color)
+{
+  gfx.inverse_text_color = inverse_text_color;
+}
+
 int getFontWidth(int font_nr)
 {
   int font_bitmap_id = gfx.select_font_function(font_nr);
@@ -168,7 +174,7 @@ void DrawInitText(char *text, int ypos, int font_nr)
 
     ClearRectangle(window, 0, ypos, video.width, getFontHeight(font_nr));
     DrawTextExt(window, (video.width - text_width) / 2, ypos, text, font_nr,
-               FONT_OPAQUE);
+               BLIT_OPAQUE);
     FlushDisplay();
   }
 }
@@ -206,10 +212,10 @@ void DrawTextF(int x, int y, int font_nr, char *format, ...)
 
 void DrawText(int x, int y, char *text, int font_nr)
 {
-  int mask_mode = FONT_OPAQUE;
+  int mask_mode = BLIT_OPAQUE;
 
   if (DrawingOnBackground(x, y))
-    mask_mode = FONT_MASKED;
+    mask_mode = BLIT_MASKED;
 
   DrawTextExt(drawto, x, y, text, font_nr, mask_mode);
 
@@ -261,24 +267,19 @@ 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;
-      int src_y= font->src_y + ((c - 32) / FONT_CHARS_PER_LINE) * font->height;
-
-      if (c == '°' || c == '´' || c == '|')    /* map '°' and 'TM' signs */
-      {
-       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 */
       {
+#if defined(TARGET_SDL)
+       /* blit normally (non-masked) */
+       BlitBitmap(font->bitmap, dst_bitmap, src_x, src_y,
+                  font->width, font->height, dst_x, dst_y);
+
+       /* invert character */
+       SDLInvertArea(dst_bitmap, dst_x, dst_y, font->width, font->height,
+                     gfx.inverse_text_color);
+#else
        /* first step: draw solid colored rectangle (use "cursor" character) */
        if (print_inverse_cursor)
          BlitBitmap(font->bitmap, dst_bitmap,
@@ -291,8 +292,9 @@ void DrawTextExt(DrawBuffer *dst_bitmap, int dst_x, int dst_y, char *text,
                      dst_x - src_x, dst_y - src_y);
        BlitBitmapMasked(font->bitmap, dst_bitmap,
                         0, 0, font->width, font->height, dst_x, dst_y);
+#endif
       }
-      else if (mask_mode == FONT_MASKED)
+      else if (mask_mode == BLIT_MASKED)
       {
        /* clear font character background */
        ClearRectangleOnBackground(dst_bitmap, dst_x, dst_y,