   Coloring Text
  I was wondering how one would go about programming something like in warcraft3 where you can do |cffff0000Text|r to color a portion of text red. Is there a simple way of doing this?Right now I am using directX font to draw my text.Any info/help is much appreciated.   
  What does the "cffff0000" part of the string mean? Is that the colour? And what does the "r" part mean?It sounds like all you need to do is parse the text for tags and then draw each part of the string in a different colour, based on the tags preceding it.   ;  I don't really remember what the values stood for. The |r is where the coloring ends though. Thanks for the reply.   ;  Assuming it's |cAARRGGBB (Where AA, RR, GG and BB are the alpha, red, green and blue colour components in hex), then you can do this (Untested, just an example):struct StringSegment{   D3DCOLOR cr;   std::string str;};std::vector<StringSegment> SplitString(const std::string& strIn){   std::vector<StringSegment> vRet;   size_t nNext = 0;   StringSegment seg;   seg.cr = D3DCOLOR_XRGB(255, 255, 255); // Default to white text   while(nNext < strIn.length())   { size_t nPos = strIn.find('|', nNext); if(nPos != std::string::npos && nPos < strIn.length()-1) {    char ch = std::tolower(strIn[nPos+1]);    if(ch == 'r')    {  seg.cr = D3DCOLOR_XRGB(255, 255, 255); // Reset colour to white  nPos ++; // Skip 'r'    }    else if(ch == 'c' && nPos < strIn.length()-8)    {  std::string strColour = strIn.substr(nPos+1, 8);  seg.cr = HexStringToColour(strColour); // Need to write this function yourself  nPos += 9; // Skip 'c' + colour    }    seg.str = strIn.substr(nNext, nPos-nNext-1);    vRet.push_back(seg);    nNext = nPos; } else {    seg.str = strIn.substr(nNext);    vRet.push_back(seg);    nNext = strIn.length(); }   }   return vRet;};  Thanks so much!   ;  Sorry for double posting but is there a way to know the length of a text line? Right now if I try drawing each element in my vector of string segments they all end up overlapping. I'll have to adjust the rect used to draw the font for each but I need to know what the length of each line will be.Thanks.   ;ID3DXFont::DrawText(..., DT_CALCRECT) can be used to determine the length of a line of text, then you can offset the position you draw each segment at by the length of the previous segment.   