Split the function to extract the correct string of an IDWriteLocalizedStrings instance out into its own function. I'm not sure if I'll need the informational strings out of a font (need to see what the strings actually say first), but in case I do, this will help.
This commit is contained in:
parent
0bc140cd46
commit
fa94298015
|
@ -36,15 +36,24 @@ fontCollection *loadFontCollection(void)
|
||||||
WCHAR *fontCollectionFamilyName(fontCollection *fc, IDWriteFontFamily *family)
|
WCHAR *fontCollectionFamilyName(fontCollection *fc, IDWriteFontFamily *family)
|
||||||
{
|
{
|
||||||
IDWriteLocalizedStrings *names;
|
IDWriteLocalizedStrings *names;
|
||||||
UINT32 index;
|
WCHAR *str;
|
||||||
BOOL exists;
|
|
||||||
UINT32 length;
|
|
||||||
WCHAR *wname;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
hr = family->GetFamilyNames(&names);
|
hr = family->GetFamilyNames(&names);
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
logHRESULT("error getting names of font out in fontCollectionFamilyName()", hr);
|
logHRESULT("error getting names of font out in fontCollectionFamilyName()", hr);
|
||||||
|
str = fontCollectionCorrectString(fc, names);
|
||||||
|
names->Release();
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
WCHAR *fontCollectionCorrectString(fontCollection *fc, IDWriteLocalizedStrings *names)
|
||||||
|
{
|
||||||
|
UINT32 index;
|
||||||
|
BOOL exists;
|
||||||
|
UINT32 length;
|
||||||
|
WCHAR *wname;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
// this is complex, but we ignore failure conditions to allow fallbacks
|
// this is complex, but we ignore failure conditions to allow fallbacks
|
||||||
// 1) If the user locale name was successfully retrieved, try it
|
// 1) If the user locale name was successfully retrieved, try it
|
||||||
|
@ -71,7 +80,6 @@ WCHAR *fontCollectionFamilyName(fontCollection *fc, IDWriteFontFamily *family)
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
logHRESULT("error getting font name in fontCollectionFamilyName()", hr);
|
logHRESULT("error getting font name in fontCollectionFamilyName()", hr);
|
||||||
|
|
||||||
names->Release();
|
|
||||||
return wname;
|
return wname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,6 +150,7 @@ struct fontCollection {
|
||||||
extern fontCollection *loadFontCollection(void);
|
extern fontCollection *loadFontCollection(void);
|
||||||
extern WCHAR *fontCollectionFamilyName(fontCollection *fc, IDWriteFontFamily *family);
|
extern WCHAR *fontCollectionFamilyName(fontCollection *fc, IDWriteFontFamily *family);
|
||||||
extern void fontCollectionFree(fontCollection *fc);
|
extern void fontCollectionFree(fontCollection *fc);
|
||||||
|
extern WCHAR *fontCollectionCorrectString(fontCollection *fc, IDWriteLocalizedStrings *names);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// drawtext.cpp
|
// drawtext.cpp
|
||||||
|
|
Loading…
Reference in New Issue