다음을 통해 공유


IDWriteLocalizedStrings 인터페이스(dwrite.h)

로캘 이름으로 인덱싱된 문자열의 컬렉션을 나타냅니다.

상속

IDWriteLocalizedStrings 인터페이스는IUnknown 인터페이스에서 상속됩니다. IDWriteLocalizedStrings 에는 다음과 같은 유형의 멤버도 있습니다.

메서드

IDWriteLocalizedStrings 인터페이스에는 이러한 메서드가 있습니다.

 
IDWriteLocalizedStrings::FindLocaleName

지정된 로캘 이름을 가진 로캘 이름/문자열 쌍의 인덱스(0부터 시작)를 가져옵니다.
IDWriteLocalizedStrings::GetCount

언어/문자열 쌍의 수를 가져옵니다.
IDWriteLocalizedStrings::GetLocaleName

지정된 인덱스가 있는 로캘 이름을 지정된 배열에 복사합니다. (IDWriteLocalizedStrings.GetLocaleName)
IDWriteLocalizedStrings::GetLocaleNameLength

지정된 인덱스가 있는 로캘 이름의 문자 길이(null 종결자를 포함하지 않음)를 가져옵니다. (IDWriteLocalizedStrings.GetLocaleNameLength)
IDWriteLocalizedStrings::GetString

지정된 인덱스가 있는 문자열을 지정된 배열에 복사합니다. (IDWriteLocalizedStrings.GetString)
IDWriteLocalizedStrings::GetStringLength

지정된 인덱스가 있는 문자열의 길이(null 종결자를 포함하지 않음)를 가져옵니다. (IDWriteLocalizedStrings.GetStringLength)

설명

IDWriteLocalizedStrings로 표시되는 문자열 집합은 로캘에 매핑되는 0부터 시작하는 UINT32 숫자로 인덱싱됩니다. 특정 로캘의 숫자 인덱스는 FindLocaleName 메서드를 사용하여 다시 처리됩니다.

IDWriteLocalizedStrings 인터페이스의 일반적인 용도는 IDWriteFontFamily::GetFamilyNames 메서드를 사용하여 만든 지역화된 글꼴 패밀리 이름 목록을 보유하는 것입니다. 다음 예제에서는 "en-us" 로캘의 가족 이름을 가져오는 방법을 보여 주었습니다.

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용 플랫폼 업데이트 [데스크톱 앱 | UWP 앱]
지원되는 최소 서버 Windows Server 2008 R2, Windows Server 2008 SP2 및 Windows Server 2008용 플랫폼 업데이트 [데스크톱 앱 | UWP 앱]
대상 플랫폼 Windows
헤더 dwrite.h