共用方式為


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

適用於

另請參閱