Click here to Skip to main content
15,920,596 members
Home / Discussions / C#
   

C#

 
QuestionFind maximum font size where string fits in a box [modified] Pin
hain30-Jan-10 11:43
hain30-Jan-10 11:43 
AnswerRe: Find maximum font size where string fits in a box Pin
Luc Pattyn30-Jan-10 12:24
sitebuilderLuc Pattyn30-Jan-10 12:24 
GeneralRe: Find maximum font size where string fits in a box Pin
DaveyM6930-Jan-10 13:46
professionalDaveyM6930-Jan-10 13:46 
GeneralRe: Find maximum font size where string fits in a box Pin
Luc Pattyn30-Jan-10 13:56
sitebuilderLuc Pattyn30-Jan-10 13:56 
GeneralRe: Find maximum font size where string fits in a box Pin
DaveyM6930-Jan-10 14:07
professionalDaveyM6930-Jan-10 14:07 
GeneralRe: Find maximum font size where string fits in a box Pin
hain6-Feb-10 17:19
hain6-Feb-10 17:19 
AnswerRe: Find maximum font size where string fits in a box Pin
Dave Kreskowiak30-Jan-10 14:07
mveDave Kreskowiak30-Jan-10 14:07 
AnswerRe: Find maximum font size where string fits in a box Pin
#realJSOP31-Jan-10 0:16
professional#realJSOP31-Jan-10 0:16 
0) Get the pixel width of the container box.

1) Divide the box width by the number of characters in your string. This will give you your "desired average character width.

2) Get the average character width of the font that you want to use, and starting at the current font size, get the average character width. Depending on whether the average character width is less than or greater than the desired character width, loop up or down in font size until you find one that matches, or is a little smaller.

3) Once you get to a candidate font size, measure the width of your string using that font, and see if it fits. If it doesn't bump the font size up or down as appropriate.

.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

QuestionSorting Pin
BobInNJ30-Jan-10 11:00
BobInNJ30-Jan-10 11:00 
AnswerRe: Sorting Pin
Luc Pattyn30-Jan-10 11:30
sitebuilderLuc Pattyn30-Jan-10 11:30 
GeneralRe: Sorting Pin
BobInNJ30-Jan-10 12:06
BobInNJ30-Jan-10 12:06 
GeneralRe: Sorting Pin
Luc Pattyn30-Jan-10 12:14
sitebuilderLuc Pattyn30-Jan-10 12:14 
GeneralRe: Sorting Pin
Gideon Engelberth30-Jan-10 19:15
Gideon Engelberth30-Jan-10 19:15 
GeneralRe: Sorting Pin
Luc Pattyn1-Feb-10 3:32
sitebuilderLuc Pattyn1-Feb-10 3:32 
GeneralRe: Sorting Pin
Gerry Schmitz30-Jan-10 14:43
mveGerry Schmitz30-Jan-10 14:43 
GeneralRe: Sorting [modified] Pin
PIEBALDconsult30-Jan-10 17:09
mvePIEBALDconsult30-Jan-10 17:09 
GeneralRe: Sorting [modified] Pin
Gideon Engelberth30-Jan-10 19:18
Gideon Engelberth30-Jan-10 19:18 
GeneralRe: Sorting Pin
Luc Pattyn31-Jan-10 1:58
sitebuilderLuc Pattyn31-Jan-10 1:58 
GeneralRe: Sorting Pin
Gideon Engelberth31-Jan-10 6:46
Gideon Engelberth31-Jan-10 6:46 
GeneralRe: Sorting Pin
Luc Pattyn31-Jan-10 14:14
sitebuilderLuc Pattyn31-Jan-10 14:14 
GeneralRe: Sorting Pin
Garth J Lancaster31-Jan-10 0:29
professionalGarth J Lancaster31-Jan-10 0:29 
GeneralRe: Sorting Pin
BobInNJ31-Jan-10 6:27
BobInNJ31-Jan-10 6:27 
QuestionMonitoring Folder Access Pin
Yekoor30-Jan-10 8:48
Yekoor30-Jan-10 8:48 
AnswerRe: Monitoring Folder Access [modified] Pin
#realJSOP30-Jan-10 8:53
professional#realJSOP30-Jan-10 8:53 
AnswerRe: Monitoring Folder Access Pin
Gerry Schmitz30-Jan-10 14:53
mveGerry Schmitz30-Jan-10 14:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.