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