Oh fixed the font dialog not showing all styles thing; stupid me forgot that a IDWriteFontFamily is also a IDWriteFontList.

This commit is contained in:
Pietro Gagliardi 2016-04-16 22:46:39 -04:00
parent 9a1367c0bc
commit 46db0b30ee
1 changed files with 11 additions and 20 deletions

View File

@ -79,33 +79,26 @@ good:
static void familyChanged(struct fontDialog *f) static void familyChanged(struct fontDialog *f)
{ {
LRESULT n; LRESULT familyn;
IDWriteFontList *specifics; IDWriteFontFamily *family;
IDWriteFont *specific; IDWriteFont *specific;
UINT32 i, ns; UINT32 i, n;
WCHAR *label; WCHAR *label;
LRESULT pos; LRESULT pos;
HRESULT hr; HRESULT hr;
wipeStylesBox(f); wipeStylesBox(f);
n = SendMessageW(f->familyCombobox, CB_GETCURSEL, 0, 0); // TODO store as item data in the combobox as well
if (n == (LRESULT) CB_ERR) familyn = SendMessageW(f->familyCombobox, CB_GETCURSEL, 0, 0);
if (familyn == (LRESULT) CB_ERR)
return; // TODO restore previous selection return; // TODO restore previous selection
family = f->families[familyn];
// TODO figure out what the correct sort order is // TODO test mutliple streteches; all the fonts I have have only one stretch value?
hr = f->families[n]->GetMatchingFonts( n = family->GetFontCount();
DWRITE_FONT_WEIGHT_NORMAL, for (i = 0; i < n; i++) {
DWRITE_FONT_STRETCH_NORMAL, hr = family->GetFont(i, &specific);
DWRITE_FONT_STYLE_NORMAL,
&specifics);
if (hr != S_OK)
logHRESULT("error getting styles for font in familyChanged()", hr);
// TODO test mutliple streteches; all the fonts I have have only one stretch value
ns = specifics->GetFontCount();
for (i = 0; i < ns; i++) {
hr = specifics->GetFont(i, &specific);
if (hr != S_OK) if (hr != S_OK)
logHRESULT("error getting font for filling styles box in familyChanged()", hr); logHRESULT("error getting font for filling styles box in familyChanged()", hr);
label = fontStyleName(f, specific); label = fontStyleName(f, specific);
@ -115,8 +108,6 @@ static void familyChanged(struct fontDialog *f)
logLastError("error setting font data in styles box in familyChanged()"); logLastError("error setting font data in styles box in familyChanged()");
} }
specifics->Release();
// TODO how do we preserve style selection? the real thing seems to have a very elaborate method of doing so // TODO how do we preserve style selection? the real thing seems to have a very elaborate method of doing so
// TODO check error // TODO check error
SendMessageW(f->styleCombobox, CB_SETCURSEL, 0, 0); SendMessageW(f->styleCombobox, CB_SETCURSEL, 0, 0);