enumerating fonts, their sizes and styles

C

Colin McGuire

Hi again. I have written the following small piece of code

Dim f As FontFamily
For Each f In System.Drawing.FontFamily.Families
Console.WriteLine(f.Name)
Next f

and when executed it prints out


Arial
Arial Black
Arial Narrow
Arial Unicode MS
Batang
Book Antiqua
Bookman Old Style
Century
..
..
..


How the heck do you get a list of the font styles (eg. Regular,
Italic, Bold, Bold Italic) and supported font sizes (8, 9, 10 11, 12,
14, 16 etc) for each of these font family names.


All I can figure is to

Dim ff as new Font(f.name,x)

where x is the font size. But you therefore have to know in advance
what x is and not all fonts support, for example, 6 point (if x is 6).

I guess what I am asking is in a font dialog box, how are the font
style and font sizes populated - where does this information come
from?

Thank you all very much again.
Colin
 
O

One Handed Man [ OHM# ]

Easy.

f.IsStyleAvailable(FontStyle.Bold)

OHM




Colin said:
Hi again. I have written the following small piece of code

Dim f As FontFamily
For Each f In System.Drawing.FontFamily.Families
Console.WriteLine(f.Name)
Next f

and when executed it prints out


Arial
Arial Black
Arial Narrow
Arial Unicode MS
Batang
Book Antiqua
Bookman Old Style
Century
.
.
.


How the heck do you get a list of the font styles (eg. Regular,
Italic, Bold, Bold Italic) and supported font sizes (8, 9, 10 11, 12,
14, 16 etc) for each of these font family names.


All I can figure is to

Dim ff as new Font(f.name,x)

where x is the font size. But you therefore have to know in advance
what x is and not all fonts support, for example, 6 point (if x is 6).

I guess what I am asking is in a font dialog box, how are the font
style and font sizes populated - where does this information come
from?

Thank you all very much again.
Colin

Regards - OHM# OneHandedMan{at}BTInternet{dot}com
 
C

Cor

Hi OHM,

Hi I thought it were beer days?

:))

Do not think I am not having Christmas, even three days

But my family says it are lazy days.

And I am the one who has to make dinners.
(And I like that)

Cor
 
E

Eduardo A. Morcillo [MS MVP VB]

How the heck do you get a list of the font styles (eg. Regular,
Italic, Bold, Bold Italic) and supported font sizes (8, 9, 10 11, 12,
14, 16 etc) for each of these font family names.

Use the IsStyleAvailable method to find out if the font supports a style. I don't know how you can get the sizes for bitmap fonts. True type fonts are vector fonts and they can be scaled to any size so there's no "supported size" list (all sizes are supported by them).
 
O

One Handed Man [ OHM# ]

yes well I had my girlfriends parents here for 48 hours, so I have not
posted until they went. We had huge dinners ( which I also made ) but did
not get drunk.

Roll on new year and spring sunshine !

:)

OHM

Hi OHM,

Hi I thought it were beer days?

:))

Do not think I am not having Christmas, even three days

But my family says it are lazy days.

And I am the one who has to make dinners.
(And I like that)

Cor

Regards - OHM# OneHandedMan{at}BTInternet{dot}com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top