Groups | Blog | Home
all groups > dotnet drawing api > july 2007 >

dotnet drawing api : Font Size Maximization for the area



RobinS
7/5/2007 1:48:18 PM
I am creating Text Slides for my user, i.e. taking text input and creating
jpegs out of it.

I have text and the selected font. Is there a method for calculating the
maximum font size I should use in order to fit the output to a specific
area, like 1024x768?

Or do I have to use MeasureString with the width and iterate until the
height is hit?

Thanks in advance,
RobinS.

Bob Powell [MVP]
7/7/2007 12:00:00 AM
Effectively, as you surmise, it's an iterative process. I use a binary chop
type algorithm.

The effect depends greatly on the font used.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.



[quoted text, click to view]

RobinS
7/8/2007 11:04:02 PM
I figured as much, darn it. I am giving the user the ability to select his
own font, too. Thanks; just wanted to make sure there wasn't some magic
function available (wishful thinking).

Robin S.
----------------------------

[quoted text, click to view]

AddThis Social Bookmark Button