Compartilhar via


FontFamily.IsStyleAvailable(FontStyle) Método

Definição

Indica se a enumeração FontStyle especificada está disponível.

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

Parâmetros

style
FontStyle

O FontStyle a ser testado.

Retornos

true se o FontStyle especificado estiver disponível; caso contrário, false.

Exemplos

O exemplo de código a seguir foi projetado para uso com o Windows Forms e requer PaintEventArgse, que é um parâmetro do manipulador de eventos Paint. O código executa as seguintes ações:

  • Cria um FontFamily.

  • Testa se a família de fontes está disponível em uma fonte itálica.

  • Se for, desenha o texto para a tela.

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

Aplica-se a