Nota
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
Crea un objeto de cadenas localizadas que contiene los nombres de familia de la familia de fuentes, indizados por nombre de configuración regional.
Sintaxis
HRESULT GetFamilyNames(
[out] IDWriteLocalizedStrings **names
);
Parámetros
[out] names
Tipo: IDWriteLocalizedStrings**
Dirección de un puntero al objeto IDWriteLocalizedStrings recién creado.
Valor devuelto
Tipo: HRESULT
Si este método se realiza correctamente, devuelve S_OK. De lo contrario, devuelve un código de error de HRESULT.
Comentarios
En el ejemplo de código siguiente se muestra cómo obtener el nombre de familia de fuentes de un objeto 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);
}
Requisitos
Cliente mínimo compatible | Windows 7, Windows Vista con SP2 y Platform Update para Windows Vista [aplicaciones de escritorio | Aplicaciones para UWP] |
Servidor mínimo compatible | Windows Server 2008 R2, Windows Server 2008 con SP2 y Actualización de plataforma para Windows Server 2008 [aplicaciones de escritorio | Aplicaciones para UWP] |
Plataforma de destino | Windows |
Encabezado | dwrite.h |
Library | Dwrite.lib |
Archivo DLL | Dwrite.dll |