views:

559

answers:

1

I want to write out some text using smallcaps in combination with different fonts for different words.

To clarify I might want the message 'Welcome to our New Website' which is generated into a PNG file for the header of a page.

  • The text will be smallcaps - everything is capitalized but the 'W', 'N' and 'W' are slightly larger.
  • The 'New Website' will be in a different font than the rest of the text.

Is there a way i can do this without doing it completely manually?

Doing something like this is conceptually what I want to do :

 graphics.DrawString("<font size=2>W</font>ELCOME TO OUR <b><font size=2>N</font>" +
                     "EW <font size=2>W</font>EBSITE</b>");

The best approach I could find so far is here, but I'm worried that I'll go to all the trouble to do this manually and end up with some horrible kerning or tracking problems.

Edit: I should have mentioned that this is being done within ASP.NET so it needs to be fast and as lean as possible. I want it to be automated so I can localize easily and not have to create tonnes of little images.

A: 

It seems like you should really be using a RichTextBox here... there is a method to extract a bitmap from the RichTextBox which you could then render as a bitmap to your graphics context. Of course, you'd need to make a Managed C++ call here and I don't know if you're able to do that in your project.

Otherwise, I think you will need to do it manually with DrawString and MeasureString, which is a pain.

Chris Blackwell
this is ASP.NET :-) i'll add that above !
Simon_Weaver
well i guess part two of your answer is correct :) im trying to up my accept ratio
Simon_Weaver