Freigeben über


FontFamily.IsStyleAvailable-Methode

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

Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)

Syntax

'Declaration
Public Function IsStyleAvailable ( _
    style As FontStyle _
) As Boolean
'Usage
Dim instance As FontFamily
Dim style As FontStyle
Dim returnValue As Boolean

returnValue = instance.IsStyleAvailable(style)
public bool IsStyleAvailable (
    FontStyle style
)
public:
bool IsStyleAvailable (
    FontStyle style
)
public boolean IsStyleAvailable (
    FontStyle style
)
public function IsStyleAvailable (
    style : FontStyle
) : boolean

Parameter

Rückgabewert

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

Beispiel

Das folgende Codebeispiel ist für die Verwendung mit Windows Forms vorgesehen und erfordert PaintEventArgse, wobei es sich um einen Parameter des Paint-Ereignishandlers handelt. Der Code führt die folgenden Aktionen aus:

  • Erstellt eine FontFamily.

  • Überprüft, ob die Schriftartfamilie in einer Schriftart mit kursiver Formatierung verfügbar ist.

  • Wenn dies der Fall ist, wird Text auf dem Bildschirm gezeichnet.

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
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:
   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.get_Graphics().DrawString(myFontFamily.get_Name()  
            + " is available in Italic", familyFont, 
            Brushes.get_Black(), new PointF(0, 0));
    }
} //IsStyleAvailable_Example

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

FontFamily-Klasse
FontFamily-Member
System.Drawing-Namespace