FontFamily.IsStyleAvailable(FontStyle) Methode

Definition

Gibt an, ob die angegebene FontStyle-Enumeration verfügbar ist.

public:
 bool IsStyleAvailable(System::Drawing::FontStyle style);
public bool IsStyleAvailable (System.Drawing.FontStyle style);
member this.IsStyleAvailable : System.Drawing.FontStyle -> bool
Public Function IsStyleAvailable (style As FontStyle) As Boolean

Parameter

style
FontStyle

Der zu überprüfende FontStyle.

Gibt zurück

true, wenn der angegebene FontStyle verfügbar ist, andernfalls false.

Beispiele

Das folgende Codebeispiel ist für die Verwendung mit Windows Forms konzipiert und erfordert PaintEventArgse, was ein Parameter des Paint Ereignishandlers ist. Der Code führt die folgenden Aktionen aus:

  • Erstellt eine FontFamily.

  • Testet, ob die Schriftfamilie in einer kursiv geschriebenen Schriftart verfügbar ist.

  • Wenn dies der Grund ist, zeichnet Text auf den Bildschirm.

public:
   void IsStyleAvailable_Example( PaintEventArgs^ e )
   {
      // Create a FontFamily object.
      FontFamily^ myFontFamily = gcnew FontFamily( "Arial" );

      // Test whether myFontFamily is available in Italic.
      if ( myFontFamily->IsStyleAvailable( FontStyle::Italic ) )
      {
         // Create a Font object using myFontFamily.
         System::Drawing::Font^ familyFont = gcnew System::Drawing::Font( myFontFamily,16,FontStyle::Italic );

         // Use familyFont to draw text to the screen.
         e->Graphics->DrawString( myFontFamily->Name + " is available in Italic",
               familyFont, Brushes::Black, PointF(0,0) );
      }
   }
public void IsStyleAvailable_Example(PaintEventArgs e)
{
    // Create a FontFamily object.
    FontFamily myFontFamily = new FontFamily("Arial");
             
    // Test whether myFontFamily is available in Italic.
    if(myFontFamily.IsStyleAvailable(FontStyle.Italic))
    {
             
        // Create a Font object using myFontFamily.
        Font familyFont = new Font(myFontFamily, 16, FontStyle.Italic);
             
        // Use familyFont to draw text to the screen.
        e.Graphics.DrawString(
            myFontFamily.Name + " is available in Italic",
            familyFont,
            Brushes.Black,
            new PointF(0, 0));
    }
}
Public Sub IsStyleAvailable_Example(ByVal e As PaintEventArgs)

    ' Create a FontFamily object.
    Dim myFontFamily As New FontFamily("Arial")

    ' Test whether myFontFamily is available in Italic.
    If myFontFamily.IsStyleAvailable(FontStyle.Italic) Then

        ' Create a Font object using myFontFamily.
        Dim familyFont As New Font(myFontFamily, 16, FontStyle.Italic)

        ' Use familyFont to draw text to the screen.
        e.Graphics.DrawString(myFontFamily.Name & _
        " is available in Italic", familyFont, Brushes.Black, _
        New PointF(0, 0))
    End If
End Sub

Gilt für: