Font.GetHeight 메서드

정의

이 글꼴의 줄 간격을 반환합니다.

오버로드

GetHeight()

이 글꼴의 줄 간격(픽셀)을 반환합니다.

GetHeight(Graphics)

이 글꼴의 줄 간격을 지정된 Graphics의 현재 단위로 반환합니다.

GetHeight(Single)

지정된 수직 해상도를 가진 디바이스에 그리는 경우 이 Font의 높이(픽셀)를 반환합니다.

GetHeight()

Source:
Font.cs
Source:
Font.cs
Source:
Font.cs

이 글꼴의 줄 간격(픽셀)을 반환합니다.

public:
 float GetHeight();
public float GetHeight ();
member this.GetHeight : unit -> single
Public Function GetHeight () As Single

반환

이 글꼴의 줄 간격(픽셀)입니다.

설명

Font 줄 간격은 연속된 두 텍스트 줄의 기준선 사이의 세로 거리입니다. 따라서 줄 간격에는 문자 자체의 높이와 함께 선 사이의 빈 공간이 포함됩니다.

Unit 글꼴의 속성이 이외의 GraphicsUnit.Pixel값으로 설정된 경우 높이(픽셀)는 화면 표시의 세로 해상도를 사용하여 계산됩니다. 예를 들어 글꼴 단위가 인치이고 글꼴 크기가 0.3이라고 가정합니다. 또한 해당 글꼴 패밀리의 경우 em 높이가 2048이고 줄 간격이 2355라고 가정합니다. 세로 해상도가 인치당 96개인 화면 디스플레이의 경우 다음과 같이 높이를 계산할 수 있습니다.

2355*(0.3/2048)*96 = 33.11719

적용 대상

GetHeight(Graphics)

Source:
Font.cs
Source:
Font.cs
Source:
Font.cs

이 글꼴의 줄 간격을 지정된 Graphics의 현재 단위로 반환합니다.

public:
 float GetHeight(System::Drawing::Graphics ^ graphics);
public float GetHeight (System.Drawing.Graphics graphics);
member this.GetHeight : System.Drawing.Graphics -> single
Public Function GetHeight (graphics As Graphics) As Single

매개 변수

graphics
Graphics

디스플레이 디바이스의 수직 해상도(인치당 도트 수)와 페이지 단위 및 페이지 배율에 대한 설정을 보유하는 Graphics입니다.

반환

이 글꼴의 줄 간격(픽셀)입니다.

예외

graphics이(가) null인 경우

예제

다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse 코드는 다음 작업을 수행합니다.

  • Font을 만듭니다.

  • Font를 사용하여 화면에 텍스트 줄을 그립니다.

  • 글꼴의 높이를 가져옵니다.

  • 첫 번째 줄 바로 아래에 두 번째 텍스트 줄을 그립니다.

public:
   void GetHeight_Example( PaintEventArgs^ e )
   {
      // Create a Font object.
      System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",16 );

      //Draw text to the screen with myFont.
      e->Graphics->DrawString( "This is the first line", myFont, Brushes::Black, PointF(0,0) );

      //Get the height of myFont.
      float height = myFont->GetHeight( e->Graphics );

      //Draw text immediately below the first line of text.
      e->Graphics->DrawString( "This is the second line", myFont, Brushes::Black, PointF(0,height) );
   }
public void GetHeight_Example(PaintEventArgs e)
{
             
    // Create a Font object.
    Font myFont = new Font("Arial", 16);
             
    //Draw text to the screen with myFont.
    e.Graphics.DrawString("This is the first line",myFont,
        Brushes.Black, new PointF(0, 0));
             
    //Get the height of myFont.
    float height = myFont.GetHeight(e.Graphics);
             
    //Draw text immediately below the first line of text.
    e.Graphics.DrawString(
        "This is the second line",
        myFont,
        Brushes.Black,
        new PointF(0, height));
}
Public Sub GetHeight_Example(ByVal e As PaintEventArgs)

    ' Create a Font object.
    Dim myFont As New Font("Arial", 16)

    'Draw text to the screen with myFont.
    e.Graphics.DrawString("This is the first line", myFont, _
    Brushes.Black, New PointF(0, 0))

    'Get the height of myFont.
    Dim height As Single = myFont.GetHeight(e.Graphics)

    'Draw text immediately below the first line of text.
    e.Graphics.DrawString("This is the second line", myFont, _
    Brushes.Black, New PointF(0, height))
End Sub

설명

Font 줄 간격은 연속된 두 텍스트 줄의 기준선 사이의 세로 거리입니다. 따라서 줄 간격에는 문자 자체의 높이와 함께 선 사이의 빈 공간이 포함됩니다.

Unit 글꼴의 속성을 이외의 GraphicsUnit.Pixel값으로 설정하면 지정된 Graphics 개체의 세로 해상도를 사용하여 높이를 픽셀 단위로 계산합니다. 예를 들어 글꼴 단위가 인치이고 글꼴 크기가 0.3이라고 가정합니다. 또한 해당 글꼴 패밀리의 경우 em 높이가 2048이고 줄 간격이 2355라고 가정합니다. 개체 UnitGraphics 속성 값과 DpiY 속성 값 GraphicsUnit.Pixel 이 인치당 96개의 점인 경우 높이는 다음과 같이 계산됩니다.

2355*(0.3/2048)*96 = 33.1171875

동일한 예제를 계속 진행하면서 개체의 속성이 UnitGraphics 가 아닌 GraphicsUnit.Pixel로 설정되어 있다고 가정합니다GraphicsUnit.Millimeter. 그런 다음(1인치 = 25.4밀리미터 사용) 높이(밀리미터)는 다음과 같이 계산됩니다.

2355*(0.3/2048)25.4 = 8.762256

추가 정보

적용 대상

GetHeight(Single)

Source:
Font.cs
Source:
Font.cs
Source:
Font.cs

지정된 수직 해상도를 가진 디바이스에 그리는 경우 이 Font의 높이(픽셀)를 반환합니다.

public:
 float GetHeight(float dpi);
public float GetHeight (float dpi);
member this.GetHeight : single -> single
Public Function GetHeight (dpi As Single) As Single

매개 변수

dpi
Single

글꼴의 높이를 계산하는 데 사용되는 수직 해상도(인치당 도트 수)입니다.

반환

Font의 높이(픽셀)입니다.

설명

Unit 글꼴의 속성이 이외의 GraphicsUnit.Pixel값으로 설정된 경우 높이(픽셀)는 화면 표시의 세로 해상도를 사용하여 계산됩니다. 예를 들어 글꼴 단위가 인치이고 글꼴 크기가 0.3이라고 가정합니다. 또한 해당 글꼴 패밀리의 경우 em 높이가 2048이고 줄 간격이 2355라고 가정합니다. 지정된 세로 해상도가 인치당 96개의 점인 경우 높이는 다음과 같이 계산됩니다.

2355*(0.3/2048)*96 = 33.1171875

추가 정보

적용 대상