Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set multiple FontStyles when instantiating a font?

Tags:

In looking at the constructors for the System.Drawing.Font class there is a parameter to pass in one of the FontStyles defined in the System.Drawing.FontStyle enum.

ie. Bold Italic Regular Underline

and there are boolean properties for Bold, Italic, Underline etc. in the instantiated object, but they are read only.

What if I want to define my font to have multiple styles like Bold and Underline?

How can I do this?

like image 905
etoisarobot Avatar asked May 11 '10 17:05

etoisarobot


1 Answers

The FontStyle enum is a Flags enum. This means that its members are all powers of two, allowing you to combine them using a binary OR.

For example, if you want bold and underline, you'd pass

FontStyle.Bold | FontStyle.Underline

The vertical bar (|) is the binary OR operator.

like image 190
Adam Robinson Avatar answered Sep 30 '22 14:09

Adam Robinson