This commit is contained in:
Niklas Mischkulnig 2018-06-04 13:42:40 +02:00
parent 9561e87d49
commit 0b14022655
4 changed files with 13 additions and 8 deletions

View File

@ -218,7 +218,7 @@ void uiDrawLoadDefaultFont(uiFontDescriptor *f)
CTFontRef ctfont;
CTFontDescriptorRef ctdesc;
ctfont = (CTFontRef) [NSFont systemFontOfSize:0];
ctfont = (CTFontRef) [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSControlSizeRegular]];
ctdesc = CTFontCopyFontDescriptor(ctfont);
uiprivFontDescriptorFromCTFontDescriptor(ctdesc, f);
CFRelease(ctdesc);

View File

@ -101,11 +101,10 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p)
int useSystemFont = uiCheckboxChecked(systemFont);
params.String = attrstr;
if(useSystemFont) {
if (useSystemFont)
uiDrawLoadDefaultFont(&defaultFont);
} else {
else
uiFontButtonFont(fontButton, &defaultFont);
}
params.DefaultFont = &defaultFont;
params.Width = p->AreaWidth;
params.Align = (uiDrawTextAlign) uiComboboxSelected(alignment);

View File

@ -86,7 +86,7 @@ void uiDrawLoadDefaultFont(uiFontDescriptor *f)
GtkStyleContext *style;
PangoFontDescription *fontdesc;
widget = g_object_ref_sink(gtk_drawing_area_new());
widget = g_object_ref_sink(gtk_label_new(""));
style = gtk_widget_get_style_context(widget);
gtk_style_context_get(style, GTK_STATE_FLAG_NORMAL,
"font", &fontdesc, NULL);

View File

@ -541,14 +541,15 @@ void uiDrawLoadDefaultFont(uiFontDescriptor *f)
IDWriteGdiInterop *gdi;
IDWriteFont *dwfont;
IDWriteFontFamily *dwfamily;
NONCLIENTMETRICS metrics;
NONCLIENTMETRICSW metrics;
HDC dc;
WCHAR *family;
double size;
int pixels;
HRESULT hr;
metrics.cbSize = sizeof(metrics);
if (!SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0))
if (!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0))
logLastError(L"error getting non-client metrics");
hr = dwfactory->GetGdiInterop(&gdi);
if (hr != S_OK)
@ -564,7 +565,10 @@ void uiDrawLoadDefaultFont(uiFontDescriptor *f)
collection = uiprivLoadFontCollection();
family = uiprivFontCollectionFamilyName(collection, dwfamily);
pixels = GetDeviceCaps(GetDC(NULL), LOGPIXELSY);
dc = GetDC(NULL);
if (dc == NULL)
logLastError(L"error getting DC");
pixels = GetDeviceCaps(dc, LOGPIXELSY);
if (pixels == 0)
logLastError(L"error getting device caps");
size = abs(metrics.lfMessageFont.lfHeight) * 72 / pixels;
@ -577,4 +581,6 @@ void uiDrawLoadDefaultFont(uiFontDescriptor *f)
uiprivFontCollectionFree(collection);
dwfamily->Release();
gdi->Release();
if (ReleaseDC(NULL, dc) == 0)
logLastError(L"error releasing DC");
}