News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

patch for [debug windows]

Started by srm2000, October 11, 2025, 06:32:33 AM

Previous topic - Next topic

srm2000

The font size of debug windows might be to small too see it clearly.  Too much complaints from the students。
I make a patch. The debug windows' fonts inherit from the editor. Then you can change the fonts at your will.
In the future, a seperated font setting dialog might be added in the debugger configuration window.

Index: src/src/backtracedlg.cpp
===================================================================
--- src/src/backtracedlg.cpp   (rev 13745)
+++ src/src/backtracedlg.cpp   (patched)
@@ -62,6 +62,14 @@
     SetAutoLayout(true);
     SetSizer(bs);

+    // use the same font as editor's
+    const wxString fontstring(Manager::Get()->GetConfigManager("editor")->Read("/font", wxEmptyString));
+    wxNativeFontInfo fontInfo;
+    fontInfo.FromString(fontstring);
+    wxFont font(fontInfo);
+
+    m_list->SetFont(font);
+
     m_list->InsertColumn(0, _("Nr"), wxLIST_FORMAT_RIGHT);
     m_list->InsertColumn(1, _("Address"), wxLIST_FORMAT_LEFT);
     m_list->InsertColumn(2, _("Function"), wxLIST_FORMAT_LEFT);
Index: src/src/breakpointsdlg.cpp
===================================================================
--- src/src/breakpointsdlg.cpp   (rev 13745)
+++ src/src/breakpointsdlg.cpp   (patched)
@@ -76,6 +76,14 @@
     SetAutoLayout(TRUE);
     SetSizer(bs);

+    // use the same font as editor's
+    const wxString fontstring(Manager::Get()->GetConfigManager("editor")->Read("/font", wxEmptyString));
+    wxNativeFontInfo fontInfo;
+    fontInfo.FromString(fontstring);
+    wxFont font(fontInfo);
+
+    m_pList->SetFont(font);
+
     wxWindow* parent = Manager::Get()->GetAppWindow();
     const double scaleFactor = cbGetContentScaleFactor(*parent);
     const int targetHeight = wxRound(12 * scaleFactor);
Index: src/src/cpuregistersdlg.cpp
===================================================================
--- src/src/cpuregistersdlg.cpp   (rev 13745)
+++ src/src/cpuregistersdlg.cpp   (patched)
@@ -27,7 +27,12 @@
     SetSizer(sizer);
     Layout();

-    wxFont font(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
+    // use the same font as editor's
+    const wxString fontstring(Manager::Get()->GetConfigManager("editor")->Read("/font", wxEmptyString));
+    wxNativeFontInfo fontInfo;
+    fontInfo.FromString(fontstring);
+    wxFont font(fontInfo);
+
     m_pList->SetFont(font);

     Clear();
Index: src/src/examinememorydlg.cpp
===================================================================
--- src/src/examinememorydlg.cpp   (rev 13745)
+++ src/src/examinememorydlg.cpp   (patched)
@@ -38,7 +38,12 @@
         return;
     m_pText = XRCCTRL(*this, "txtDump", wxTextCtrl);

-    wxFont font(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
+    // use the same font as editor's
+    const wxString fontstring(Manager::Get()->GetConfigManager("editor")->Read("/font", wxEmptyString));
+    wxNativeFontInfo fontInfo;
+    fontInfo.FromString(fontstring);
+    wxFont font(fontInfo);
+
     m_pText->SetFont(font);

     ConfigManager *c = Manager::Get()->GetConfigManager(wxT("debugger_common"));
Index: src/src/threadsdlg.cpp
===================================================================
--- src/src/threadsdlg.cpp   (rev 13745)
+++ src/src/threadsdlg.cpp   (patched)
@@ -44,8 +44,14 @@
     SetAutoLayout(true);
     SetSizer(bs);

-    wxFont font(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
+    // use the same font as editor's
+    const wxString fontstring(Manager::Get()->GetConfigManager("editor")->Read("/font", wxEmptyString));
+    wxNativeFontInfo fontInfo;
+    fontInfo.FromString(fontstring);
+    wxFont font(fontInfo);
+
     m_list->SetFont(font);
+
     m_list->InsertColumn(0, _("Active"), wxLIST_FORMAT_LEFT, 64);
     m_list->InsertColumn(1, _("Number"), wxLIST_FORMAT_RIGHT, 64);
     m_list->InsertColumn(2, _("Info"), wxLIST_FORMAT_LEFT);
Index: src/src/watchesdlg.cpp
===================================================================
--- src/src/watchesdlg.cpp   (rev 13745)
+++ src/src/watchesdlg.cpp   (patched)
@@ -403,6 +403,14 @@
     SetAutoLayout(TRUE);
     SetSizer(bs);

+    // use the same font as editor's
+    const wxString fontstring(Manager::Get()->GetConfigManager("editor")->Read("/font", wxEmptyString));
+    wxNativeFontInfo fontInfo;
+    fontInfo.FromString(fontstring);
+    wxFont font(fontInfo);
+
+    m_grid->SetFont(font);
+
     if (!watchesPropertyEditor)
         watchesPropertyEditor = wxPropertyGrid::RegisterEditorClass(new cbTextCtrlAndButtonTooltipEditor, true);

@@ -1337,9 +1345,12 @@
     m_grid->SetExtraStyle(extraStyles);
     m_grid->SetDropTarget(new WatchesDropTarget);

+    // use the same font as editor's
+    const wxString fontstring(Manager::Get()->GetConfigManager("editor")->Read("/font", wxEmptyString));
     wxNativeFontInfo fontInfo;
-    fontInfo.FromString(cbDebuggerCommonConfig::GetValueTooltipFont());
+    fontInfo.FromString(fontstring);
     wxFont font(fontInfo);
+
     m_grid->SetFont(font);

     m_grid->SetColumnCount(3);

Miguel Gimenez

Patch (modified to take HiDPI into account) applied in r13747, thank you.

srm2000

Quote from: Miguel Gimenez on October 11, 2025, 10:17:36 AM
Patch (modified to take HiDPI into account) applied in r13747, thank you.

The new patch of r13747 makes the fonts of debugging windows especially large. It doesn't match well with the GUI's font at all.

So, my suggestion is,  calling SetFont in the released patch such as,
m_pText->SetFont(font.Scaled(cbGetContentScaleFactor(*this)));
might be much better like this, just as my original patch.
m_pText->SetFont(font);

The users can change the editor's font to ensure the debugging windows' font size is right.

Miguel Gimenez

What scale factor are you using?.

srm2000


Miguel Gimenez

I have reverted the commit, as the original version only fixed your use case.

Now the dialogs are using the default control font (usually proportional) multiplied by the scale factor; This should fix the issue for all users.

ollydbg

#6
One thing to mention.

When I try to build the code under wx3.3, I have to add the include file:

#include <wx/fontutil.h>

Otherwise, it will report that the wxNativeFontInfo is not complete. Strange that I haven't see this kinds of build error before.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

ollydbg

@srm2000

Next time when you post the code, you should use the code format, which is when you click the "#" in your webpage's editor toolbar.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Miguel Gimenez

I have removed the FontInfo stuff in a second commit, so the include should not be necessary, if it is feel free to add it (I currently cannot).