Font 클래스

정의

글꼴, 크기 및 스타일 특성을 포함하여 텍스트의 특정 형식을 정의합니다. 이 클래스는 상속될 수 없습니다.

public ref class Font sealed : MarshalByRefObject, ICloneable, IDisposable, System::Runtime::Serialization::ISerializable
public sealed class Font : MarshalByRefObject, ICloneable, IDisposable, System.Runtime.Serialization.ISerializable
[System.ComponentModel.TypeConverter("System.Drawing.FontConverter, System.Windows.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")]
public sealed class Font : MarshalByRefObject, ICloneable, IDisposable, System.Runtime.Serialization.ISerializable
[System.ComponentModel.TypeConverter(typeof(System.Drawing.FontConverter))]
public sealed class Font : MarshalByRefObject, ICloneable, IDisposable, System.Runtime.Serialization.ISerializable
[System.ComponentModel.TypeConverter(typeof(System.Drawing.FontConverter))]
[System.Serializable]
public sealed class Font : MarshalByRefObject, ICloneable, IDisposable, System.Runtime.Serialization.ISerializable
[System.ComponentModel.TypeConverter(typeof(System.Drawing.FontConverter))]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class Font : MarshalByRefObject, ICloneable, IDisposable, System.Runtime.Serialization.ISerializable
type Font = class
    inherit MarshalByRefObject
    interface ICloneable
    interface IDisposable
    interface ISerializable
[<System.ComponentModel.TypeConverter("System.Drawing.FontConverter, System.Windows.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")>]
type Font = class
    inherit MarshalByRefObject
    interface ICloneable
    interface IDisposable
    interface ISerializable
[<System.ComponentModel.TypeConverter(typeof(System.Drawing.FontConverter))>]
type Font = class
    inherit MarshalByRefObject
    interface ICloneable
    interface IDisposable
    interface ISerializable
[<System.ComponentModel.TypeConverter(typeof(System.Drawing.FontConverter))>]
[<System.Serializable>]
type Font = class
    inherit MarshalByRefObject
    interface ICloneable
    interface IDisposable
    interface ISerializable
[<System.ComponentModel.TypeConverter(typeof(System.Drawing.FontConverter))>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Font = class
    inherit MarshalByRefObject
    interface ICloneable
    interface ISerializable
    interface IDisposable
Public NotInheritable Class Font
Inherits MarshalByRefObject
Implements ICloneable, IDisposable, ISerializable
상속
특성
구현

예제

다음 코드 예제를 사용 Font 하는 방법에 설명 합니다 생성자 및 Size, SizeInPoints, 및 Unit 속성입니다. 이 예제는 "Bigger" 및 "Smaller" 문자열과 라는 문자열로 채워진 라는 가 ComboBox1 포함된 ComboBox Windows Form과 LabelLabel1함께 사용하도록 설계되었습니다. 다음 코드를 양식에 붙여넣고 메서드를 ComboBox1_SelectedIndexChanged 컨트롤의 이벤트와 SelectedIndexChanged 연결합니다 ComboBox .

private:
    void ComboBox1_SelectedIndexChanged(System::Object^ sender,
        System::EventArgs^ e)
    {

        // Cast the sender object back to a ComboBox.
        ComboBox^ ComboBox1 = (ComboBox^) sender;

        // Retrieve the selected item.
        String^ selectedString = (String^) ComboBox1->SelectedItem;

        // Convert it to lowercase.
        selectedString = selectedString->ToLower();

        // Declare the current size.
        float currentSize;

        // If Bigger is selected, get the current size from the 
        // Size property and increase it. Reset the font to the
        //  new size, using the current unit.
        if (selectedString == "bigger")
        {
            currentSize = Label1->Font->Size;
            currentSize += 2.0F;
            Label1->Font =gcnew System::Drawing::Font(Label1->Font->Name, 
                currentSize, Label1->Font->Style, Label1->Font->Unit);

        }
        // If Smaller is selected, get the current size, in
        // points, and decrease it by 2.  Reset the font with
        // the new size in points.
        if (selectedString == "smaller")
        {
            currentSize = Label1->Font->Size;
            currentSize -= 2.0F;
            Label1->Font = gcnew System::Drawing::Font(Label1->Font->Name, 
                currentSize, Label1->Font->Style);

        }
    }
private void ComboBox1_SelectedIndexChanged(System.Object sender, 
    System.EventArgs e)
{

    // Cast the sender object back to a ComboBox.
    ComboBox ComboBox1 = (ComboBox) sender;

    // Retrieve the selected item.
    string selectedString = (string) ComboBox1.SelectedItem;

    // Convert it to lowercase.
    selectedString = selectedString.ToLower();

    // Declare the current size.
    float currentSize;

    // Switch on the selected item. 
    switch(selectedString)
    {

            // If Bigger is selected, get the current size from the 
            // Size property and increase it. Reset the font to the
            //  new size, using the current unit.
        case "bigger":
            currentSize = Label1.Font.Size;
            currentSize += 2.0F;
            Label1.Font = new Font(Label1.Font.Name, currentSize, 
                Label1.Font.Style, Label1.Font.Unit);

            // If Smaller is selected, get the current size, in points,
            // and decrease it by 1.  Reset the font with the new size
            // in points.
            break;
        case "smaller":
            currentSize = Label1.Font.SizeInPoints;
            currentSize -= 1;
            Label1.Font = new Font(Label1.Font.Name, currentSize, 
                Label1.Font.Style);
            break;
    }
}
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

    ' Cast the sender object back to a ComboBox.
    Dim ComboBox1 As ComboBox = CType(sender, ComboBox)

    ' Retrieve the selected item.
    Dim selectedString As String = CType(ComboBox1.SelectedItem, String)

    ' Convert it to lowercase.
    selectedString = selectedString.ToLower()

    ' Declare the current size.
    Dim currentSize As Single

    ' Switch on the selected item. 
    Select Case selectedString

        ' If Bigger is selected, get the current size from the 
        ' Size property and increase it. Reset the font to the
        '  new size, using the current unit.
    Case "bigger"
            currentSize = Label1.Font.Size
            currentSize += 2.0F
            Label1.Font = New Font(Label1.Font.Name, currentSize, _
                Label1.Font.Style, Label1.Font.Unit)

            ' If Smaller is selected, get the current size, in points,
            ' and decrease it by 1.  Reset the font with the new size
            ' in points.
        Case "smaller"
            currentSize = Label1.Font.SizeInPoints
            currentSize -= 1
            Label1.Font = New Font(Label1.Font.Name, currentSize, _
                Label1.Font.Style)
    End Select
End Sub

설명

글꼴을 생성하는 방법에 대한 자세한 내용은 방법: 글꼴 패밀리 및 글꼴 생성을 참조하세요. Windows Forms 애플리케이션 트루타입 글꼴을 지원 하 고 OpenType 글꼴에 대 한 지원이 제한 됩니다. 지원 되지 않는 글꼴을 사용 하려고 하면 글꼴은 애플리케이션을 실행 하는 컴퓨터에 설치 되어 있지 않거나, Microsoft Sans Serif 글꼴 대체 됩니다.

참고

.NET 6 이상 버전에서는 이 형식을 포함하는 System.Drawing.Common 패키지가 Windows 운영 체제에서만 지원됩니다. 플랫폼 간 앱에서 이 형식을 사용하면 컴파일 시간 경고 및 런타임 예외가 발생합니다. 자세한 내용은 Windows에서만 지원되는 System.Drawing.Common을 참조하세요.

생성자

Font(Font, FontStyle)

지정된 기존 FontFontStyle 열거형을 사용하는 새 Font를 초기화합니다.

Font(FontFamily, Single)

지정된 크기를 사용하여 새 Font를 초기화합니다.

Font(FontFamily, Single, FontStyle)

지정된 크기 및 스타일을 사용하여 새 Font를 초기화합니다.

Font(FontFamily, Single, FontStyle, GraphicsUnit)

지정된 크기, 스타일 및 단위를 사용하여 새 Font를 초기화합니다.

Font(FontFamily, Single, FontStyle, GraphicsUnit, Byte)

지정된 크기, 스타일, 단위 및 문자 집합을 사용하여 새 Font를 초기화합니다.

Font(FontFamily, Single, FontStyle, GraphicsUnit, Byte, Boolean)

지정된 크기, 스타일, 단위 및 문자 집합을 사용하여 새 Font를 초기화합니다.

Font(FontFamily, Single, GraphicsUnit)

지정된 크기 및 단위를 사용하여 새 Font를 초기화합니다. 스타일을 Regular로 설정합니다.

Font(String, Single)

지정된 크기를 사용하여 새 Font를 초기화합니다.

Font(String, Single, FontStyle)

지정된 크기 및 스타일을 사용하여 새 Font를 초기화합니다.

Font(String, Single, FontStyle, GraphicsUnit)

지정된 크기, 스타일 및 단위를 사용하여 새 Font를 초기화합니다.

Font(String, Single, FontStyle, GraphicsUnit, Byte)

지정된 크기, 스타일, 단위 및 문자 집합을 사용하여 새 Font를 초기화합니다.

Font(String, Single, FontStyle, GraphicsUnit, Byte, Boolean)

지정된 크기, 스타일, 단위 및 문자 집합을 사용하여 새 Font를 초기화합니다.

Font(String, Single, GraphicsUnit)

지정된 크기 및 단위를 사용하여 새 Font를 초기화합니다. 스타일은 Regular로 설정됩니다.

속성

Bold

Font가 볼드인지 여부를 나타내는 값을 가져옵니다.

FontFamily

FontFamily와 연결된 Font를 가져옵니다.

GdiCharSet

Font가 사용하는 GDI 문자 집합을 지정하는 바이트 값을 가져옵니다.

GdiVerticalFont

Font가 GDI 세로 방향 글꼴에서 파생되었는지 여부를 나타내는 부울 값을 가져옵니다.

Height

이 글꼴의 줄 간격을 가져옵니다.

IsSystemFont

글꼴이 SystemFonts의 멤버인지 여부를 나타내는 값을 가져옵니다.

Italic

이 글꼴에 기울임꼴 스타일이 적용되었는지를 나타내는 값을 가져옵니다.

Name

Font의 글꼴 이름을 가져옵니다.

OriginalFontName

원래 지정된 글꼴의 이름을 가져옵니다.

Size

Font 속성에서 지정하는 단위로 측정된 이 Unit의 em-size를 가져옵니다.

SizeInPoints

Font의 em-size(포인트)를 가져옵니다.

Strikeout

Font가 글꼴을 통과하는 가로줄을 지정하는지 여부를 나타내는 값을 가져옵니다.

Style

Font의 스타일 정보를 가져옵니다.

SystemFontName

IsSystemFont 속성이 true를 반환하는 경우 시스템 글꼴의 이름을 가져옵니다.

Underline

Font에 밑줄이 있는지 여부를 나타내는 값을 가져옵니다.

Unit

Font의 단위를 가져옵니다.

메서드

Clone()

Font의 정확한 복사본을 만듭니다.

CreateObjRef(Type)

원격 개체와 통신하는 데 사용되는 프록시 생성에 필요한 모든 관련 정보가 들어 있는 개체를 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
Dispose()

Font에서 사용하는 리소스를 모두 해제합니다.

Equals(Object)

지정된 개체가 Font이고 이 Font와 같은 FontFamily, GdiVerticalFont, GdiCharSet, Style, SizeUnit 속성 값을 갖고 있는지 여부를 나타냅니다.

Finalize()

가비지 컬렉션이 회수하기 전에 개체가 리소스를 해제하고 다른 정리 작업을 수행할 수 있게 합니다.

FromHdc(IntPtr)

디바이스 컨텍스트에 대한 지정된 창 핸들에서 Font를 만듭니다.

FromHfont(IntPtr)

지정된 창 핸들에서 Font를 만듭니다.

FromLogFont(LOGFONT)

글꼴, 크기 및 스타일 특성을 포함하여 텍스트의 특정 형식을 정의합니다. 이 클래스는 상속될 수 없습니다.

FromLogFont(LOGFONT, IntPtr)

글꼴, 크기 및 스타일 특성을 포함하여 텍스트의 특정 형식을 정의합니다. 이 클래스는 상속될 수 없습니다.

FromLogFont(Object)

Font 지정된 GDI 논리 글꼴(LOGFONT) 구조체에서 를 만듭니다.

FromLogFont(Object, IntPtr)

Font 지정된 GDI 논리 글꼴(LOGFONT) 구조체에서 를 만듭니다.

GetHashCode()

Font의 해시 코드를 가져옵니다.

GetHeight()

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

GetHeight(Graphics)

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

GetHeight(Single)

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

GetLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 현재의 수명 서비스 개체를 검색합니다.

(다음에서 상속됨 MarshalByRefObject)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
InitializeLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 수명 서비스 개체를 가져옵니다.

(다음에서 상속됨 MarshalByRefObject)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
MemberwiseClone(Boolean)

현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
ToHfont()

Font의 핸들을 반환합니다.

ToLogFont(LOGFONT)

글꼴, 크기 및 스타일 특성을 포함하여 텍스트의 특정 형식을 정의합니다. 이 클래스는 상속될 수 없습니다.

ToLogFont(LOGFONT, Graphics)

글꼴, 크기 및 스타일 특성을 포함하여 텍스트의 특정 형식을 정의합니다. 이 클래스는 상속될 수 없습니다.

ToLogFont(Object)

Font에서 GDI 논리 글꼴(LOGFONT) 구조를 만듭니다.

ToLogFont(Object, Graphics)

Font에서 GDI 논리 글꼴(LOGFONT) 구조를 만듭니다.

ToString()

Font의 사람이 인식할 수 있는 문자열 표현을 반환합니다.

명시적 인터페이스 구현

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

대상 개체를 직렬화하는 데 필요한 데이터로 SerializationInfo를 채웁니다.

적용 대상

추가 정보