Link to home
Start Free TrialLog in
Avatar of mromeo
mromeo

asked on

Enumerating Monospaced Fonts


I am trying to enumerate the monospaced fonts in a C# program. I am trying to do it by using the FromLogFont method of the Font class.  I was hoping that I could fill in a LOGFONT structure with the appropriate flags turned on and get the monopsaced fonts.  I  have two questions.

1. Is this the best way to do this?  I don't see any other way to get only the monospaced fonts.

2.  How do you use FromLogFont.  I don't see how you create a LOGFONT structure in C#.

Thanks.
Avatar of Wim_Bl
Wim_Bl
Flag of Belgium image

Hi,

the following thread is about finding out if a font is monospaced or not, and since it seems that there is no easy way to do that, I figure there also isn't an easy way to get a list of those fonts. However, you can use certain techniques, like MeasureString(), to get an idea. Check out:
http://www.dotnet247.com/247reference/msgs/35/178197.aspx

greetings
ASKER CERTIFIED SOLUTION
Avatar of Erick37
Erick37
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Did that work out for you mromeo?
How can you return the enumerated font information back to the application? Or do you have to use the call back function to write to a file or something?
I figured it out. If you want an object to be available in the callback method, you just have to change the type of lParam and then pass that object. So, if I wanted to have a list box available I would change int lParam to TextBox lParam and then send the name of the text in the call to the EnumFontFamiliesEx function. =o)