Agreed. I found the YIQ color space for perceived luminance to be extremely useful for foreground/background color readability.
http://blog.nitriq.com/BlackvsWhiteText.aspxThere are other tricks you can use like stroking/bordering the text with the opposite color as it provides contrast when white is on a light background or black is on a dark background. You can also have the text "glow" or some use a drop shadow. But these don't work that great when your text is small. However you have to use these tricks when you are putting text on top of a gradient.