FontFamily.IsStyleAvailable(FontStyle) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Indicates whether the specified FontStyle enumeration is available.
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
Parameters
Returns
true
if the specified FontStyle is available; otherwise, false
.
Examples
The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e
, which is a parameter of the Paint event handler. The code performs the following actions:
Creates a FontFamily.
Tests whether the font family is available in an italic font.
If it is, draws text to the screen.
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
Applies to
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應