From 4c99efa88948fa17785d0a14062b871ea3c57e66 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Wed, 17 Apr 2024 20:26:03 +0200 Subject: [PATCH] CppKore: try parent font if current is absent This allows for setting uniform fonts on all controls, by only assigning the font once to the parent control. Else each control needs to have its own set. --- r5dev/thirdparty/cppnet/cppkore/Control.cpp | 7 ++++++- r5dev/thirdparty/cppnet/cppkore/Control.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/r5dev/thirdparty/cppnet/cppkore/Control.cpp b/r5dev/thirdparty/cppnet/cppkore/Control.cpp index e52fa063..cb977402 100644 --- a/r5dev/thirdparty/cppnet/cppkore/Control.cpp +++ b/r5dev/thirdparty/cppnet/cppkore/Control.cpp @@ -231,8 +231,13 @@ namespace Forms SetWindowLongPtrA(this->_Handle, GWLP_USERDATA, (intptr_t)this); // Setup the default font if none was previously set + if (this->_Font == nullptr) - this->_Font = std::make_unique(this->_Handle, (HFONT)GetStockObject(DEFAULT_GUI_FONT)); + if (this->_Parent && this->_Parent->_Font) + this->_Font = std::make_unique(this->_Handle, this->_Parent->_Font.get()->GetFontHandle()); + else + this->_Font = std::make_unique(this->_Handle, (HFONT)GetStockObject(DEFAULT_GUI_FONT)); + // Notify the window of the font selection SendMessageA(this->_Handle, WM_SETFONT, (WPARAM)this->_Font->GetFontHandle(), NULL); diff --git a/r5dev/thirdparty/cppnet/cppkore/Control.h b/r5dev/thirdparty/cppnet/cppkore/Control.h index 15a19e50..87ffbda7 100644 --- a/r5dev/thirdparty/cppnet/cppkore/Control.h +++ b/r5dev/thirdparty/cppnet/cppkore/Control.h @@ -146,7 +146,7 @@ namespace Forms // Retrieves the current font for this control. Drawing::Font* GetFont(); - // Retrieves the current font for this control. + // Sets the current font for this control. void SetFont(Drawing::Font* Font); // The parent of this control.