david's daily developer note

[Native] CFONT 본문

[Develop] Native/Native

[Native] CFONT

mouse-david 2012. 4. 12. 11:24
728x90


1.   CFont
CFont 클래스는 MFC에서제공하는 GDI 오브젝트 중 하나로 화면에 그리는 텍스트의 글꼴을 설정할 때 사용
CFont 폰트 스타일을 지정하는 과정은 다음과 같다

1.    DC 얻기
2.    CFont 선언
3.    폰트 생성
4.    DC에 CFontObject 설정
5.    텍스트 그리기
6.    CFont Object 제거


위의 과정의 코드는 다음과 같습니다.

1. DC 얻기

CClientDC cClientDC(this);


2. CFont 선언

CFont cFont

CString strTitle = _T("CFont 예제");


3. 폰트생성

cFont.CreateFont (20,                           // 글자높이
                  10,                           // 글자너비
                  0,                            // 출력각도
                  0,                            // 기준 선에서의각도
                  FW_HEAVY,                     // 글자굵기
                  FALSE,                      	// Italic 적용여부
                  FALSE,                      	// 밑줄적용여부
                  FALSE,                      	// 취소선적용여부
                  DEFAULT_CHARSET,              // 문자셋종류
                  OUT_DEFAULT_PRECIS,           // 출력정밀도
                  CLIP_DEFAULT_PRECIS,          // 클리핑정밀도
                  DEFAULT_QUALITY,              // 출력문자품질
                  DEFAULT_PITCH,                // 글꼴 Pitch
                  _T("굴림체")                   // 글꼴
);

4. DC에 CFont Object 설정

cClientDC.SelectObject(CFont);

5. 텍스트그리기

cClientDC.DrawText(strTitle, CRect(100,100,320,240), NULL);


6. CFont Object 제거

cFont.DeleteObject();


CreateFont에서 사용되는 미리 정의된 속성 값은 MS 공식문서 참조


https://learn.microsoft.com/ko-kr/windows/win32/api/wingdi/ns-wingdi-logfonta

 

LOGFONTA(wingdi.h) - Win32 apps

LOGFONT 구조체는 글꼴의 특성을 정의합니다. (ANSI)

learn.microsoft.com

https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-wmf/0d0b32ac-a836-4bd2-a112-b6000a1b4fc9

 

[MS-WMF]: CharacterSet Enumeration

The CharacterSet Enumeration defines the possible sets of character glyphs that are defined in fonts for graphics output.  typedef  enum  {  

learn.microsoft.com

 

728x90