Maelstrom: Use color modulation instead of hard-coding the color so the same image can be reused for multiple colors of text.

From 7625a7dad12b65a7135969b6392dc55150c554b4 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 20 Oct 2011 22:41:45 -0400
Subject: [PATCH] Use color modulation instead of hard-coding the color so the
 same image can be reused for multiple colors of text. Technically this means
 that it's no longer possible to have two identical strings with different
 colors.  If this becomes a problem we can add the color into the hash key.

Also removed the background color since it's no longer meaningful.
---
 maclib/Mac_FontServ.cpp | 7 ++++---
 maclib/Mac_FontServ.h   | 5 ++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/maclib/Mac_FontServ.cpp b/maclib/Mac_FontServ.cpp
index 7cc7c798..ea3c9c66 100644
--- a/maclib/Mac_FontServ.cpp
+++ b/maclib/Mac_FontServ.cpp
@@ -301,8 +301,7 @@ FontServ:: TextHeight(MFont *font)
 		((scanline[(i)/16] >> (15 - (i)%16)) & 1)
 
 SDL_Texture *
-FontServ:: TextImage(const char *text, MFont *font, Uint8 style,
-			SDL_Color foreground, SDL_Color background)
+FontServ:: TextImage(const char *text, MFont *font, Uint8 style, SDL_Color fg)
 {
 	char *key, *keycopy;
 	int keysize;
@@ -325,6 +324,7 @@ FontServ:: TextImage(const char *text, MFont *font, Uint8 style,
 	key = SDL_stack_alloc(char, keysize);
 	sprintf(key, "%s:%d:%s", font->name, font->ptsize, text);
 	if (hash_find(strings, key, (const void**)&image)) {
+		SDL_SetTextureColorMod(image, fg.r, fg.g, fg.b);
 		return image;
 	}
 
@@ -385,7 +385,7 @@ FontServ:: TextImage(const char *text, MFont *font, Uint8 style,
 
 	/* Allocate the text pixels */
 	bitmap = new Uint32[width*height];
-	color = screen->MapRGB(foreground.r, foreground.g, foreground.b);
+	color = screen->MapRGB(0xFF, 0xFF, 0xFF);
 
 	/* Print the individual characters */
 	/* Note: this could probably be optimized.. eh, who cares. :) */
@@ -436,6 +436,7 @@ FontServ:: TextImage(const char *text, MFont *font, Uint8 style,
 	/* Create the image */
 	image = screen->LoadImage(width, height, bitmap);
 	delete[] bitmap;
+	SDL_SetTextureColorMod(image, fg.r, fg.g, fg.b);
 
 	/* Add it to our cache */
 	keycopy = new char[keysize];
diff --git a/maclib/Mac_FontServ.h b/maclib/Mac_FontServ.h
index af9b6fcf..a4142f83 100644
--- a/maclib/Mac_FontServ.h
+++ b/maclib/Mac_FontServ.h
@@ -113,16 +113,15 @@ class FontServ {
 	   The text should be freed with FreeText() after it is used.
 	 */
 	SDL_Texture *TextImage(const char *text, MFont *font, Uint8 style,
-				SDL_Color background, SDL_Color foreground);
+						SDL_Color foreground);
 	SDL_Texture *TextImage(const char *text, MFont *font, Uint8 style,
 						Uint8 R, Uint8 G, Uint8 B) {
-		SDL_Color background = { 0xFF, 0xFF, 0xFF, 0 };
 		SDL_Color foreground;
 
 		foreground.r = R;
 		foreground.g = G;
 		foreground.b = B;
-		return(TextImage(text, font, style, foreground, background));
+		return(TextImage(text, font, style, foreground));
 	}
 	void FreeText(SDL_Texture *text);