Wednesday, January 05, 2005

Week 11: Rendering Dynamic Text

Just spent the evening figuring out the best way to render user determined text in rectangles of user determined size.

The solution is actually pretty simple using .NET. First, measue the size of the rendered text using some arbitrary font and some arbitrary bounding box. Next, determine the ratio between the width of the arbitrary bounding box and the actual area you want to render to. Do the same for the height. Choose the smaller ratio of the width and height ratios and scale the font size by that ratio. Wallah! The text fills the area you want.

1 Comments:

Blogger Rachel Rutherford said...

How did you ever think of this? I can see thinking of the arbitrary font size & box size. You have to start somewhere. What made you think of the ratios?

5:09 PM  

Post a Comment

<< Home