0
votes

As per MSDN the enumeration values supported for the font styles are

Bold text.  1

Italic

Italic text.    2

Regular

Normal text.    0

Strikeout

Text with a line through the middle.    8

Underline

Underlined text.    4

There are many fonts which have additional styles apart from these.How can get the enumeration integer value for a particular font from the Style of that font

1

1 Answers

3
votes

Simply cast it to an integer:

var intRepresentation = (int)myFont.Style;

If your goal is to work out what style a font is a better approch would be something like this:

var isBold = myFont.Style & FontStyle.Bold; // isBold is 0 if not, 1 if it is
var isItalic = myFont.Style & FontStyle.Italic; // isItalic is 0 if not, 2 if it is

See the Enumeration as Bit Flags section of this page: http://msdn.microsoft.com/en-us/library/cc138362.aspx