Font size dilemma

forum.advanced.programming (1998-2005)

Font size dilemma

Post by stainless » 03 Aug 2005, 12:51

 Posted by:  stainless <> 

I am currently writing code that takes a piece of text (this is
variable), writes it to an excel spreedsheet in a cell of known length
and height (in centimetres so that it is always printed in exactly the
same dimensions) using the Arial font.

Knowing the cell size, I need to calculate the font size so that the
text fits into the cell and fills it with minimum space around it
(obviously, long text strings will be limited by the length, thus
appear as a smaller font, and short strings limited by height, thus
appearing as a larger font). The text will invariably have upper case
letters embedded so this can be used in any calculations.

There are several placess that I can do this calculation within the
system and I do not mind where this is done:

1. SQL Server stored procedure
2. C# code in .net
3. In Excel

I have tried one method in excel where I increase the font size to 72
and use shrink to fit. The results were variable (some arial texts
filled the cell, others left large gaps around the text in the cell).

Any ideas how this font can be calculated given fixed size cells, Arial
font, size of capital letters in fonts?



Return to “advanced.programming”

Who is online

Users browsing this forum: No registered users and 0 guests