Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ugly RPC Console Output on macOS #273

Closed
jarolrod opened this issue Apr 6, 2021 · 3 comments
Closed

Ugly RPC Console Output on macOS #273

jarolrod opened this issue Apr 6, 2021 · 3 comments
Labels
macOS UI All about "look and feel"

Comments

@jarolrod
Copy link
Member

jarolrod commented Apr 6, 2021

Edit: This is a macOS specific issue. A monospace font is used on Linux and windows, but not on macOS. Add to the list of reasons to embed a regular monospace font.

The help output for any RPC command is formatted differently in the macOS GUI console versus a Linux GUI console.

With the Linux GUI console, the type/descriptions for an argument/result are shown at a uniform distance from the argument/result itself, thanks to the use of a monospace font.

With the macOS GUI console, the type/descriptions do not line up because a monospace font is not used. This leads to 'ugly' output.

Example: help setwalletflag

macOS GUI RPC Console
Screen Shot 2021-04-06 at 7 07 06 PM

Linux GUI RPC Console
Screen Shot 2021-04-08 at 11 49 15 AM

@jarolrod jarolrod added the Bug Something isn't working label Apr 6, 2021
@jarolrod jarolrod changed the title Ugly RPC Console Help Output Ugly RPC Console Output on macOS Apr 8, 2021
@hebasto
Copy link
Member

hebasto commented Apr 10, 2021

A monospace font is used on Linux and windows, but not on macOS.

Actually, the font family in the default stylesheet

gui/src/qt/rpcconsole.cpp

Lines 805 to 817 in f0fa324

// Set default style sheet
QFontInfo fixedFontInfo(GUIUtil::fixedPitchFont());
ui->messagesWidget->document()->setDefaultStyleSheet(
QString(
"table { }"
"td.time { color: #808080; font-size: %2; padding-top: 3px; } "
"td.message { font-family: %1; font-size: %2; white-space:pre-wrap; } "
"td.cmd-request { color: #006060; } "
"td.cmd-error { color: red; } "
".secwarning { color: red; }"
"b { color: #006060; } "
).arg(fixedFontInfo.family(), QString("%1pt").arg(consoleFontSize))
);

is set correctly to .AppleSystemUIFontMonospaced.

But this approach (using styleesheets) does not work on macOS. Probably, the reason of such behavior is the fact that .AppleSystemUIFontMonospaced is a private font family.

UPDATE. From Qt Style Sheets docs:

However, this wasn't guaranteed to work for all styles, because style authors are restricted by the different platforms' guidelines and (on Windows and macOS) by the native theme engine.

@hebasto
Copy link
Member

hebasto commented Apr 10, 2021

Maybe, the following patch

diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 34d055e5a..1acfaa3b2 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -803,7 +803,7 @@ void RPCConsole::clear(bool clearHistory)
     }
 
     // Set default style sheet
-    QFontInfo fixedFontInfo(GUIUtil::fixedPitchFont());
+    QFontInfo fixedFontInfo(GUIUtil::fixedPitchFont(true));
     ui->messagesWidget->document()->setDefaultStyleSheet(
         QString(
                 "table { }"

is a step to fix this issue?

@hebasto hebasto added UI All about "look and feel" and removed Bug Something isn't working Design labels May 8, 2021
hebasto added a commit that referenced this issue Nov 25, 2021
b9f0aff qt: monospaced output in Console on macOS (randymcmillan)

Pull request description:

  This PR addresses issue #273
  A monospace font is used on Linux and Windows for the console output - but not on MacOS.
  This change forces the MacOS GUI to use the embedded RobotoMono-Bold.ttf font,
  which is defined as the GUIUtil::fixedPitchFont()

ACKs for top commit:
  hebasto:
    ACK b9f0aff, Tested on macOS Big Sur 11.6.1 (20G224) + Homebrew's Qt 5.15.2:
  shaavan:
    reACK b9f0aff
  jarolrod:
    tACK b9f0aff

Tree-SHA512: 53e6635a0189e133681c85d442c6c9c4a10438151e4bf7da5bbd62abca7ab55685caf2c9a75ff200aadea771c1602902e6ab14afdc4f411e1b3013dd49625dbc
@hebasto
Copy link
Member

hebasto commented Nov 25, 2021

Closing via #477.

@hebasto hebasto closed this as completed Nov 25, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this issue Nov 25, 2021
b9f0aff qt: monospaced output in Console on macOS (randymcmillan)

Pull request description:

  This PR addresses issue bitcoin-core/gui#273
  A monospace font is used on Linux and Windows for the console output - but not on MacOS.
  This change forces the MacOS GUI to use the embedded RobotoMono-Bold.ttf font,
  which is defined as the GUIUtil::fixedPitchFont()

ACKs for top commit:
  hebasto:
    ACK b9f0aff, Tested on macOS Big Sur 11.6.1 (20G224) + Homebrew's Qt 5.15.2:
  shaavan:
    reACK b9f0aff
  jarolrod:
    tACK b9f0aff

Tree-SHA512: 53e6635a0189e133681c85d442c6c9c4a10438151e4bf7da5bbd62abca7ab55685caf2c9a75ff200aadea771c1602902e6ab14afdc4f411e1b3013dd49625dbc
@bitcoin-core bitcoin-core locked and limited conversation to collaborators Nov 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
macOS UI All about "look and feel"
Projects
None yet
Development

No branches or pull requests

2 participants