Parameters

The FontStyle to apply to the new Font. Multiple values of the FontStyle enumeration can be combined with the OR operator.

Examples

The following code example demonstrates the Inequality operator, the Font constructor, and the Bold property. This example is designed to be used with a Windows Form that contains a button named Button2. Paste the following code into your form and associate the Button2_Click method with the button's Click event.

Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
If (Color.op_Inequality(Me.BackColor, SystemColors.ControlDark)) Then
Me.BackColor = SystemColors.ControlDark
End If
If Not (Me.Font.Bold) Then
Me.Font = New Font(Me.Font, FontStyle.Bold)
End If
End Sub

Remarks

For localized applications that are based on the .NET Framework 2.0 and earlier releases, specifying a font for prototype when that font has not been installed on the computer that is used to build your application will cause the Microsoft Sans Serif font to be used instead. If your application depends on this behavior and you must recompile your application for the .NET Framework 3.0, you should specify the Microsoft Sans Serif font for prototype.

Exceptions

emSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

Remarks

The gdiCharSet parameter takes a value from the list defined in the Windows SDK header file WinGDI.h. If the familyName parameter specifies a font that is not installed on the machine running the application or is not supported, Microsoft Sans Serif will be substituted.

Exceptions

emSize is less than or equal to 0, evaluates to infinity or is not a valid number.

Examples

The following code example demonstrates how to use the Font constructor. This example is designed to be used with Windows Forms. To run this example, paste this code into a form that contains a button named Button2, and associate the Button2_Click method with the Click event of the button.

Remarks

Windows Forms applications support TrueType fonts and have limited support for OpenType fonts. If the familyName parameter specifies a font that is not installed on the machine running the application or is not supported, Microsoft Sans Serif will be substituted.

Exceptions

emSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

Remarks

The gdiCharSet parameter takes a value from the list defined in the Windows SDK header file WinGDI.h. Windows Forms applications support TrueType fonts and have limited support for OpenType fonts. If the familyName parameter specifies a font that is not installed on the machine running the application or is not supported, Microsoft Sans Serif will be substituted.

Exceptions

emSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

Remarks

The resulting font has its Unit property set to Point. Windows Forms applications support TrueType fonts and have limited support for OpenType fonts. If the familyName parameter specifies a font that is not installed on the machine running the application or is not supported, Microsoft Sans Serif will be substituted.

Examples

The following code example demonstrates how to set the Font property of a button to a new, bold-style Font. This example is designed to be used with a Windows Form that contains a button named Button1. Paste the following code into your form and associate the Button1_Click method with the button's Click event.

Exceptions

emSize is less than or equal to 0, evaluates to infinity or is not a valid number.

Examples

The following code example demonstrates how to use the Font constructor. This example is designed to be used with a Windows Form and requires a PaintEventArgse, which is a parameter of the Paint event.

Remarks

The resulting font has its Style property set to FontStyle.Regular and its Unit property set to GraphicsUnit.Point. Windows Forms applications support TrueType fonts and have limited support for OpenType fonts. If the familyName parameter specifies a font that is not installed on the machine running the application or is not supported, Microsoft Sans Serif will be substituted.