Windows default font
This commit is contained in:
parent
e114e71741
commit
9561e87d49
|
@ -106,16 +106,15 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p)
|
||||||
} else {
|
} else {
|
||||||
uiFontButtonFont(fontButton, &defaultFont);
|
uiFontButtonFont(fontButton, &defaultFont);
|
||||||
}
|
}
|
||||||
printf("%s\n", defaultFont.Family);
|
|
||||||
params.DefaultFont = &defaultFont;
|
params.DefaultFont = &defaultFont;
|
||||||
params.Width = p->AreaWidth;
|
params.Width = p->AreaWidth;
|
||||||
params.Align = (uiDrawTextAlign) uiComboboxSelected(alignment);
|
params.Align = (uiDrawTextAlign) uiComboboxSelected(alignment);
|
||||||
textLayout = uiDrawNewTextLayout(¶ms);
|
textLayout = uiDrawNewTextLayout(¶ms);
|
||||||
uiDrawText(p->Context, textLayout, 0, 0);
|
uiDrawText(p->Context, textLayout, 0, 0);
|
||||||
uiDrawFreeTextLayout(textLayout);
|
uiDrawFreeTextLayout(textLayout);
|
||||||
if(!useSystemFont) {
|
|
||||||
uiFreeFontButtonFont(&defaultFont);
|
//TODO RENAME?
|
||||||
}
|
uiFreeFontButtonFont(&defaultFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *e)
|
static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *e)
|
||||||
|
|
|
@ -535,46 +535,46 @@ void uiDrawTextLayoutExtents(uiDrawTextLayout *tl, double *width, double *height
|
||||||
*height = metrics.height;
|
*height = metrics.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
uiDrawTextFont *uiDrawLoadDefaultFont()
|
void uiDrawLoadDefaultFont(uiFontDescriptor *f)
|
||||||
{
|
{
|
||||||
uiDrawTextFont *font;
|
fontCollection *collection;
|
||||||
fontCollection *collection;
|
IDWriteGdiInterop *gdi;
|
||||||
IDWriteGdiInterop *gdi;
|
IDWriteFont *dwfont;
|
||||||
IDWriteFont *dwfont;
|
IDWriteFontFamily *dwfamily;
|
||||||
IDWriteFontFamily *dwfamily;
|
NONCLIENTMETRICS metrics;
|
||||||
NONCLIENTMETRICS metrics;
|
WCHAR *family;
|
||||||
WCHAR *family;
|
double size;
|
||||||
double size;
|
int pixels;
|
||||||
int pixels;
|
HRESULT hr;
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
metrics.cbSize = sizeof(metrics);
|
metrics.cbSize = sizeof(metrics);
|
||||||
if (!SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0))
|
if (!SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0))
|
||||||
logLastError(L"error getting non-client metrics");
|
logLastError(L"error getting non-client metrics");
|
||||||
hr = dwfactory->GetGdiInterop(&gdi);
|
hr = dwfactory->GetGdiInterop(&gdi);
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
logHRESULT(L"error getting GDI interop", hr);
|
logHRESULT(L"error getting GDI interop", hr);
|
||||||
|
|
||||||
hr = gdi->CreateFontFromLOGFONT(&metrics.lfMessageFont, &dwfont);
|
hr = gdi->CreateFontFromLOGFONT(&metrics.lfMessageFont, &dwfont);
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
logHRESULT(L"error loading font", hr);
|
logHRESULT(L"error loading font", hr);
|
||||||
|
|
||||||
hr = dwfont->GetFontFamily(&dwfamily);
|
hr = dwfont->GetFontFamily(&dwfamily);
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
logHRESULT(L"error loading font family", hr);
|
logHRESULT(L"error loading font family", hr);
|
||||||
collection = loadFontCollection();
|
collection = uiprivLoadFontCollection();
|
||||||
family = fontCollectionFamilyName(collection, dwfamily);
|
family = uiprivFontCollectionFamilyName(collection, dwfamily);
|
||||||
|
|
||||||
pixels = GetDeviceCaps(GetDC(NULL), LOGPIXELSY);
|
pixels = GetDeviceCaps(GetDC(NULL), LOGPIXELSY);
|
||||||
if (pixels == 0)
|
if (pixels == 0)
|
||||||
logLastError(L"error getting device caps");
|
logLastError(L"error getting device caps");
|
||||||
size = abs(metrics.lfMessageFont.lfHeight) * 72 / pixels;
|
size = abs(metrics.lfMessageFont.lfHeight) * 72 / pixels;
|
||||||
|
|
||||||
font = mkTextFont(dwfont, FALSE, family, FALSE, size);
|
uiprivFontDescriptorFromIDWriteFont(dwfont, f);
|
||||||
|
f->Family = toUTF8(family);
|
||||||
|
f->Size = size;
|
||||||
|
|
||||||
fontCollectionFree(collection);
|
uiprivFree(family);
|
||||||
dwfamily->Release();
|
uiprivFontCollectionFree(collection);
|
||||||
gdi->Release();
|
dwfamily->Release();
|
||||||
|
gdi->Release();
|
||||||
return font;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue