Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

FontDialog Only Allows Integrals?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike - 11 Jul 2006 17:14 GMT
I've noticed that the FontDialog only allows positive integers as input when
you show the dialog.  Is there some reason for this?  The font that it
returns allows singles and I can't really find anywhere that explains why
this might be.  We're writing our own FontDialog (due to some other
limitations), and we're trying to find out if there is a practical reason for
this or if we should allow any positive decimal number.  

Thanks.
Bob Powell [MVP] - 11 Jul 2006 19:30 GMT
I assume you're talking about the font height...

The font dialog always creates a font with a point size. This is to a
resolution of 1/72 of an inch so floats in here don't make a lot of sense.

The Font is more or less read-only once created and will return a height in
a floating point number so that the different units might be accommodated.

When you request a font, you may get back a different size to that requested
depending on how the font grid-fitting is calculated. For example a
"standard" 8 point font will probably declare a point size of 8.25 points.
On a screen resolution of 96 DPI this corresponds to exactly 11 pixels
whereas 8 points exacly would be 10.666r pixels. These round to the nearest
pixel.

Signature

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.

> I've noticed that the FontDialog only allows positive integers as input
> when
[quoted text clipped - 6 lines]
>
> Thanks.
Mike - 11 Jul 2006 19:57 GMT
       Dim fd As New FontDialog
       fd.ShowDialog()
       Console.WriteLine(fd.Font.SizeInPoints)

If I choose a the font size to be 10 here, the output is 9.75.  If I choose
the font size to be 11 here, the output is 11.25.  8 gets 8.25 and 9 gets 9.  
So I see what you are saying there, sort of.

What initially brought my question up is when you actually have that font
dialog open, you are forbidden from inputting 9.75, it forces you to put a
positive integer in.  Which seems weird, considering that all the Font.Size
methods return Singles.

I'm using scaled fonts through Graphics, and I have not had a problem having
all sorts of font sizes (8.198598 as a point size works beautifully); I'm not
limited to what the FontDialog is rounding me to.  

So I guess my main problem is still that the FontDialog inexplicably
prevents my users from using singles.  I'm confused as to, if I want the
Dialog to return to me a Font with height 10 or 10.5, why it can't actually
do that.  It seems odd that it is limiting itself to one sort of resolution.

Perhaps I'm not understanding what the Size box is intended to be when you
open a FontDialog.

Thanks,
Mike

> I assume you're talking about the font height...
>
[quoted text clipped - 21 lines]
> >
> > Thanks.
Bruce Wood - 11 Jul 2006 21:32 GMT
> The font dialog always creates a font with a point size. This is to a
> resolution of 1/72 of an inch so floats in here don't make a lot of sense.

I disagree. I don't have a lot of experience using the dialog, but in
MS Word, for example, I do occasionally ask for a font of 8.5 points,
for example, and it is noticeably different from 8 points and from 9
points.

When you get down to the smaller font sizes, a half a point (or even
less) makes a noticeable difference.

Given that other products (MS Word, Crystal Reports designer) allow one
to specify font height in fractions of points, it seems odd that .NET's
standard dialog doesn't.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.