다음을 통해 공유


IDWriteFontFamily::GetFamilyNames 메서드(dwrite.h)

로캘 이름으로 인덱싱된 글꼴 패밀리의 패밀리 이름을 포함하는 지역화된 문자열 개체를 만듭니다.

구문

HRESULT GetFamilyNames(
  [out] IDWriteLocalizedStrings **names
);

매개 변수

[out] names

형식: IDWriteLocalizedStrings**

새로 만든 IDWriteLocalizedStrings 개체에 대한 포인터의 주소입니다.

반환 값

형식: HRESULT

메서드가 성공하면 S_OK를 반환하고, 그러지 않으면 HRESULT 오류 코드를 반환합니다.

설명

다음 코드 예제에서는 IDWriteFontFamily 개체에서 글꼴 패밀리 이름을 가져오는 방법을 보여줍니다.

IDWriteLocalizedStrings* pFamilyNames = NULL;

// Get a list of localized strings for the family name.
if (SUCCEEDED(hr))
{
    hr = pFontFamily->GetFamilyNames(&pFamilyNames);
}

UINT32 index = 0;
BOOL exists = false;

wchar_t localeName[LOCALE_NAME_MAX_LENGTH];

if (SUCCEEDED(hr))
{
    // Get the default locale for this user.
    int defaultLocaleSuccess = GetUserDefaultLocaleName(localeName, LOCALE_NAME_MAX_LENGTH);

    // If the default locale is returned, find that locale name, otherwise use "en-us".
    if (defaultLocaleSuccess)
    {
        hr = pFamilyNames->FindLocaleName(localeName, &index, &exists);
    }
    if (SUCCEEDED(hr) && !exists) // if the above find did not find a match, retry with US English
    {
        hr = pFamilyNames->FindLocaleName(L"en-us", &index, &exists);
    }
}

// If the specified locale doesn't exist, select the first on the list.
if (!exists)
    index = 0;

UINT32 length = 0;

// Get the string length.
if (SUCCEEDED(hr))
{
    hr = pFamilyNames->GetStringLength(index, &length);
}

// Allocate a string big enough to hold the name.
wchar_t* name = new (std::nothrow) wchar_t[length+1];
if (name == NULL)
{
    hr = E_OUTOFMEMORY;
}

// Get the family name.
if (SUCCEEDED(hr))
{
    hr = pFamilyNames->GetString(index, name, length+1);
}

요구 사항

   
지원되는 최소 클라이언트 Windows 7, Windows Vista SP2 및 Windows Vista용 플랫폼 업데이트가 포함된 Windows Vista [데스크톱 앱 | UWP 앱]
지원되는 최소 서버 Windows Server 2008 R2, Windows Server 2008 SP2 및 Windows Server 2008용 플랫폼 업데이트 [데스크톱 앱 | UWP 앱]
대상 플랫폼 Windows
헤더 dwrite.h
라이브러리 Dwrite.lib
DLL Dwrite.dll

추가 정보

IDWriteFontFamily