Monthly Archives: June 2011

Markup text rendering in XNA

Update: New version, fixed some minor issues, add start()/stop() methods to support the video tag.

Now that I submitted my game to Dream.Build.Play 2011 and I’m all done with it I’ll try to post a few things I made while developing said game and may be useful to other XNA developers.

I’ll start with an update to the markup text engine/thingy I did to display the in-game dialog and help screens (I first wrote about in this post, look there for details and a bit of a tutorial on how to use it). Since that post I added a

Here it is in action, scroll down for source and demo project.

And the markup that generated the image above:

Lorem Ipsum

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Temporibus autem

Duis aute irure in reprehenderit.
Velit esse cillum dolore eu dolore eu.

Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum. , temporibus autem quibusdam aut officiis debitis .
Et harum quidem rerum facilis est et expedita distinctio.

At vero eos et accusamus et iusto odio dignissimos ducimus!

Here is a list of supported tags:

  • sets the font and color. Nested text blocks are supported and will inherit any attributes from the enclosing parent tag.
  • obviously specifies an image and has color and scale attributes.
  • specifies a video and also supports the color and scale attributes.

  • adds a line break.
  • inserts a space.
  • is used for conditional rendering.

Download the source code, drop me a note if you use it in your game.

Note: The code is licensed under MS-PL