다음을 통해 공유


CFont::CreateFontIndirect

초기화는 CFont 에서 특성을 가진 개체는 LOGFONT구조.

BOOL CreateFontIndirect( 
   const LOGFONT* lpLogFont  
);

매개 변수

  • lpLogFont
    가리키는 있는 LOGFONT 논리 글꼴의 특성을 정의 하는 구조입니다.

반환 값

성공 하면 0이 아닌. 그렇지 않으면 0입니다.

설명

모든 장치에 대 한 현재 글꼴 글꼴 이후에 선택할 수 있습니다.

이 글꼴에 지정 된 특성이 있는 LOGFONT 구조. 사용 하 여 글꼴을 선택한 경우는 CDC::SelectObject 멤버 함수는 GDI 글꼴 매퍼 시도 하는 논리 글꼴을 기존의 실제 글꼴과 일치 하도록 합니다. 글꼴 매퍼는 논리 글꼴을 정확히 일치 하지 않으면 해당 특성이 요청 된 특징과 최대한 많이 일치 하는 대체 글꼴을 제공 합니다.

더 이상 필요는 CFont 만든 개체는 CreateFontIndirect 기능, 사용 CDC::SelectObject 다른 글꼴 디바이스 컨텍스트로 선택 하 고 삭제를 CFont 더 이상 필요 없는 개체.

예제

// The code fragment shows how to create a font object, 
// select the font object into a DC (device context) for text 
// drawing, and finally delete the font object. 

// Initializes a CFont object with the characteristics given  
// in a LOGFONT structure.
CFont font;
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));       // zero out structure
lf.lfHeight = 12;                      // request a 12-pixel-height font
_tcsncpy_s(lf.lfFaceName, LF_FACESIZE, 
   _T("Arial"), 7);                    // request a face name "Arial"
VERIFY(font.CreateFontIndirect(&lf));  // create the font 

// Do something with the font just created...
CClientDC dc(this);
CFont* def_font = dc.SelectObject(&font);
dc.TextOut(5, 5, _T("Hello"), 5);
dc.SelectObject(def_font);

// Done with the font. Delete the font object.
font.DeleteObject();

요구 사항

헤더: afxwin.h

참고 항목

참조

CFont 클래스

계층 구조 차트

CFont::CreateFont

CFont::CreatePointFontIndirect

CDC::SelectObject

CGdiObject::DeleteObject

CreateFontIndirect

LOGFONT