FontFamily.GetLineSpacing(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.
Returns the line spacing, in design units, of the FontFamily of the specified style. The line spacing is the vertical distance between the base lines of two consecutive lines of text.
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
Parameters
Returns
The distance between two consecutive lines of text.
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.
Gets the line spacing for the font family.
Draws the value of the line spacing to the screen as text.
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