FontFamily.GetLineSpacing(FontStyle) 方法

定义

返回指定样式的 FontFamily 的行距,采用设计单位。 行距是两个连续文本行的基线之间的垂直距离。

public:
 int GetLineSpacing(System::Drawing::FontStyle style);
public int GetLineSpacing (System.Drawing.FontStyle style);
member this.GetLineSpacing : System.Drawing.FontStyle -> int
Public Function GetLineSpacing (style As FontStyle) As Integer

参数

style
FontStyle

要应用的 FontStyle

返回

两行相邻文本之间的距离。

示例

下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse,它是 事件处理程序的Paint一个参数。 此代码执行以下操作:

  • 创建一个 FontFamily

  • 获取字体系列的行距。

  • 以文本形式绘制屏幕的行距值。

public:
   void GetLineSpacing_Example( PaintEventArgs^ e )
   {
      // Create a FontFamily object.
      FontFamily^ myFontFamily = gcnew FontFamily( "Arial" );

      // Get the line spacing for myFontFamily.
      int lineSpacing = myFontFamily->GetLineSpacing( FontStyle::Regular );

      // Draw the value of lineSpacing to the screen as a string.
      e->Graphics->DrawString( String::Format( "lineSpacing = {0}", lineSpacing ),
            gcnew System::Drawing::Font( myFontFamily,16 ), Brushes::Black, PointF(0,0) );
   }
public void GetLineSpacing_Example(PaintEventArgs e)
{
    // Create a FontFamily object.
    FontFamily myFontFamily = new FontFamily("Arial");
             
    // Get the line spacing for myFontFamily.
    int lineSpacing = myFontFamily.GetLineSpacing(FontStyle.Regular);
             
    // Draw the value of lineSpacing to the screen as a string.
    e.Graphics.DrawString(
        "lineSpacing = " + lineSpacing.ToString(),
        new Font(myFontFamily, 16),
        Brushes.Black,
        new PointF(0, 0));
}
Public Sub GetLineSpacing_Example(ByVal e As PaintEventArgs)

    ' Create a FontFamily object.
    Dim myFontFamily As New FontFamily("Arial")

    ' Get the line spacing for myFontFamily.
    Dim lineSpacing As Integer = _
    myFontFamily.GetLineSpacing(FontStyle.Regular)

    ' Draw the value of lineSpacing to the screen as a string.
    e.Graphics.DrawString("lineSpacing = " & lineSpacing.ToString(), _
    New Font(myFontFamily, 16), Brushes.Black, New PointF(0, 0))
End Sub

适用于

另请参阅