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 Forms 使用,而且需要 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

適用於

另請參閱