FontFamily.IsStyleAvailable(FontStyle) Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menunjukkan apakah enumerasi FontStyle yang ditentukan tersedia.
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
Mengembalikan
true
jika FontStyle yang ditentukan tersedia; jika tidak, false
.
Contoh
Contoh kode berikut dirancang untuk digunakan dengan Windows Forms, dan memerlukan PaintEventArgse
, yang merupakan parameter penanganan aktivitas Paint. Kode melakukan tindakan berikut:
Membuat FontFamily.
Menguji apakah keluarga font tersedia dalam font miring.
Jika ya, gambar teks ke layar.
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