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:
Pietro Gagliardi 2016-04-15 10:14:23 -04:00
parent 0bc140cd46
commit fa94298015
2 changed files with 14 additions and 5 deletions

View File

@ -36,15 +36,24 @@ fontCollection *loadFontCollection(void)
WCHAR *fontCollectionFamilyName(fontCollection *fc, IDWriteFontFamily *family)
{
IDWriteLocalizedStrings *names;
UINT32 index;
BOOL exists;
UINT32 length;
WCHAR *wname;
WCHAR *str;
HRESULT hr;
hr = family->GetFamilyNames(&names);
if (hr != S_OK)
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
// 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)
logHRESULT("error getting font name in fontCollectionFamilyName()", hr);
names->Release();
return wname;
}

View File

@ -150,6 +150,7 @@ struct fontCollection {
extern fontCollection *loadFontCollection(void);
extern WCHAR *fontCollectionFamilyName(fontCollection *fc, IDWriteFontFamily *family);
extern void fontCollectionFree(fontCollection *fc);
extern WCHAR *fontCollectionCorrectString(fontCollection *fc, IDWriteLocalizedStrings *names);
#endif
// drawtext.cpp