FontFamily.IsStyleAvailable(FontStyle) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指示指定的 FontStyle 枚举是否可用。
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
参数
返回
如果指定的 FontStyle 可用,true
;否则,false
。
示例
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse
,这是 Paint 事件处理程序的参数。 该代码执行以下操作:
创建 FontFamily。
测试字体系列是否在斜体字体中可用。
如果是,请向屏幕绘制文本。
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