   [c# Xna] 1 String in multiple colors ?
  hey ! ..ha i guess i'm going to be a regular here ^^well..this time i wanna try to make some parts of a string in different colors.so i thought i could use color-tags in my string like \r so the parser knows that everything following should be drawn in red or e.g \b blue etc.for the drawing itself i'd use multiple DrawString methods with different colors but that bears some problems i would need to partotionate the whole string in multiple strings(as much as i have different clors) and also everytime a color change i'd need to get the string's position(screen-coordinates) so that the next color knows where to start off..that's way to complicate for such a "simple" thing in my opinion :(i'd like to have only one StringDraw method if possible..but that's the only idea i came up with.any suggestions ? ^^chris   
  I suggest you to use this program: BITMAPFONTMAKER and load a bmp font instead of a normal windows font (you can edit the bmp as you want with all the colors!)ps. you have to set "Texture - XNA Framework" in the "content importer" property when you add the bmp spritefont and you have to set "Sprite Font Texture - XNA Framework" in the "content processor" property bye[Edited by - FOOLVER on September 2, 2009 10:08:50 AM];  awesome, thank you very much, FOOLVER ! :)   ;  If you want to do it programmatically - using a single font with multiple calls to DrawString (and different tints) - you can measure the current "piece" of the string by calling the SpriteFont.MeasureString method.string[] stringPieces = { "Hel", "lo, ", "wor", "ld!" };Color[] colors = { Color.Blue, Color.Green, Color.Yellow, Color.Red };Vector2 startPosition = new Vector2(100, 100);Vector2 offset = Vector2.Zero;SpriteFont font = Content.Load<SpriteFont>("myFont");spriteBatch.Begin();//Loop through each piece of the string, //drawing each with a different color,//and moving the offset forward by its measured lengthfor( int x = 0; x < stringPieces.Length; x++){    spriteBatch.Draw(font, stringPieces[x], startPosition + offset, colors[x]);    stringOffset.X += font.MeasureString(stringPieces[x]).X; }spriteBatch.End();Obviously, you could also write a function that can break up a long string into an array of pieces, along with a matching array of colors - maybe you want to create a gradient that changes from red to blue over the course of the entire string, with "x" number of steps.If you want every letter in your string to have a different color (with every letter's color holding constant), then use the Bitmap font maker.  If you want to have control over the color, and the change thereof, then do it this way.  There are pluses and minuses to each approach.[Edited by - BTownTKD on September 2, 2009 8:19:11 AM];  In fact, you've inspired me to make a post on my blog about this very subject.  The example in the post is a little more fully-fleshed out than the snippet I posted above.AND... I added the resulting extension method to my work-in-progress framework.Thanks for the inspiration!   ;  thank you BTownTKD, that was very helpful !edit: woahhh, your blog entry is even more awesome, i feel honored to have inspired you to do this awesome work ! ;)   ;  yeah that's pretty cool feature!!   