From cc13d6b2e8572b7ea46b0400a924bde3b8253f06 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 11 Sep 2021 10:56:09 +0100 Subject: [PATCH] Try out GTK font scaling based on icon scaling architecture. wxWidgets symbolic sizes fail on HiDPI GTK screens; the dialog pixel stuff fails on non-scaled GTK screens. Fixes https://gitlab.com/kicad/code/kicad/issues/8608 --- common/widgets/ui_common.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/common/widgets/ui_common.cpp b/common/widgets/ui_common.cpp index c407357e34..f1d82a4595 100644 --- a/common/widgets/ui_common.cpp +++ b/common/widgets/ui_common.cpp @@ -33,6 +33,7 @@ #include #include #include +#include int KIUI::GetStdMargin() { @@ -94,21 +95,28 @@ wxFont KIUI::GetMonospacedUIFont() } -wxFont makeGUIFont( wxWindow* aWindow, int aDialogSize ) +wxFont makeGUIFont( wxWindow* aWindow, int aPtSize ) { wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); - // Using wxFont::SetSymbolicSize() fails on (at least) GTK with HiDPI screens, but the - // dialog pixel conversion stuff seems to work.... + // Using wxFont::SetSymbolicSize() fails on (at least) GTK with HiDPI screens (too small), + // and the dialog pixel conversion stuff fails on (at least) GTK _without_ HiDPI screens + // (too large). - int vert_size = aWindow->ConvertDialogToPixels( wxSize( 0, aDialogSize ) ).y; + int requested_scale = Pgm().GetCommonSettings()->m_Appearance.icon_scale; - font.SetPointSize( vert_size / 2 ); + if( requested_scale <= 0 ) + requested_scale = KiIconScale( aWindow ); + + font.SetPointSize( KiROUND( aPtSize * requested_scale / 4.0 ) ); #ifdef __WXMAC__ // https://trac.wxwidgets.org/ticket/19210 if( font.GetFaceName().IsEmpty() ) - font.SetFaceName( "Lucida Grande" ); + font.SetFaceName( "San Francisco" ); + // OSX 10.1 .. 10.9: Lucida Grande + // OSX 10.10: Helvetica Neue + // OSX 10.11 .. : San Francisco #endif return font; @@ -117,13 +125,13 @@ wxFont makeGUIFont( wxWindow* aWindow, int aDialogSize ) wxFont KIUI::GetControlFont( wxWindow* aWindow ) { - return makeGUIFont( aWindow, 14 ); + return makeGUIFont( aWindow, 13 ); } wxFont KIUI::GetInfoFont( wxWindow* aWindow ) { - return makeGUIFont( aWindow, 13 ); + return makeGUIFont( aWindow, 12 ); }