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

[Doc] QDirStat Font Size #268

Closed
shundhammer opened this issue Apr 25, 2024 · 4 comments
Closed

[Doc] QDirStat Font Size #268

shundhammer opened this issue Apr 25, 2024 · 4 comments
Labels

Comments

@shundhammer
Copy link
Owner

shundhammer commented Apr 25, 2024

Received via mail from Justin A. justin.xxx@xxx.com:

I’ve been a fan and user of qdirstat for a little while now. I recently switched to a 4K monitor and when I run qdirstat now, the fonts that are used for the menus and other text is so small that it is not readable, even on my fairly large monitor.

I cannot figure out how to configure the fonts and other gui features of qdirstat. I’ve tried to google search and looked through the github documentation but I don’t see any information there.

My setup is that I’m using SUSE x86-64_linux_4.12_ImageSLES12SP5 , with the “XFCE4” window manager. The window manager settings for fonts/sizes don’t have any effect on the menu/text fonts of the qdirstat application.

Moved to this issue tracker to share the answer with other users who have the same question.

@shundhammer
Copy link
Owner Author

shundhammer commented Apr 25, 2024

Default: Using the Desktop Environment's Font Settings

QDirStat is a Qt 5 -based application; it behaves just the same as other applications using the Qt libs.

That means that by default, it uses the settings of your desktop environment, if possible. This works at least for the major desktop environments like KDE Plasma, GNOME, Xfce.

So in most cases, it should work to simply use your desktop's settings configuration dialog or applet where you can change the font settings.

If you don't know where that is, check the desktop's menu; most of those menus and configuration programs have a search box. Type "fonts' there.

Xfce4

When I do that in my Xfce4, it gives me one search result, Xfce4's "Appearance" applet:

xfce4-appearance-tab-1-style

In this first tab named "Style" you can select a desktop theme. Those usually come with some initial font settings.

xfce4-appearance-tab-2-fonts

In the third tab "Fonts" you can make very detailed selections for the base font (typically a proportional font) and a monospace font that is typically used for constant-width texts such as terminal windows.

DPI

Be aware that the DPI (Dots Per Inch) setting may also influence how large those fonts might appear; it overrides the monitor's hardware settings with that value.

Scale Factor

xfce4-appearance-tab-4-settings

Modern desktops also let you configure a scale factor. This is useful if you either have a very high-resolution ("HiDPI") monitor or a small laptop monitor with high resolution, or if you are vision impaired:

Here you can select to up-scale everything in a window, from fonts and icons (!) to the general size of user interface elements ("widgets").

Notice that sometimes this is restricted to non-fractional (integer) numbers like 1, 2, 3; sometimes multiples of 0.25 can be used like 1.25, 1.5, 1.75; sometimes all fractional numbers (1.83, 2.47) can be used. Try what works in your environment.

Apply to Non-Native Applications

In some cases, a desktop has a setting named something like "apply settings to non-native applications"; that means that KDE Plasma will try to use those font sizes and theme settings to non-KDE applicatoins as well. Similar for GNOME and non-Gtk (non-GNOME) applications.

KDE Plasma, Gnome

It's very similar in most other modern desktop environments. The dialogs look different, but the principles are very much the same.

@shundhammer
Copy link
Owner Author

shundhammer commented Apr 25, 2024

qt5ct

qt5ct is a standalone graphical configuration program for all Qt 5 applications on your machine:

qt5ct-tab-1-appearance

qt5ct-tab-2-fonts

qt5ct-tab-3-icons

qt5ct-tab-4-interface

Installing qt5ct

  • openSUSE Leap 15.x / Tumbleweed / SLE-15-SPx / SLES-12-SPx:

     sudo zypper in qt5ct
    
  • Ubuntu / Kubuntu / Xubuntu / Debian:

    sudo apt install qt5ct
    

Usage

  • Start it and set fonts (and widget themes and whatever else you'd like to set):

    qt5ct
    

    (with your normal user account, not with sudo!)

  • Set this environment variable to tell the Qt libs to use those settings, not the settings from your desktop environment:

    export QT_QPA_PLATFORMTHEME="qt5ct"
    
  • Put that environment variable in your shell startup scripts (~/.bashrc or ~/.zshrc or ~/environment)

  • If you use QDirStat as root, or with sudo, do the same for root.

Config File Location

The values are stored at

~/.config/qt5ct/qt5ct.conf

Unfortunately the relevant part here is stored as a QByteArray, i.e. in a very much unreadable hexdump-like binary format:

[Fonts]
fixed=@Variant(\0\0\0@\0\0\0 \0\x44\0\x65\0j\0\x61\0V\0u\0 \0S\0\x61\0n\0s\0 \0M\0o\0n\0o@$\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10)
general=@Variant(\0\0\0@\0\0\0\x14\0\x44\0r\0o\0i\0\x64\0 \0S\0\x61\0n\0s@&\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10)

[Appearance]
color_scheme_path=/usr/share/qt5ct/colors/airy.conf
custom_palette=false
icon_theme=Adwaita
standard_dialogs=default
style=Fusion

But you can simply copy that file to the root user's home directory (with sudo, of course).

@shundhammer
Copy link
Owner Author

shundhammer commented Apr 25, 2024

Qt Environment Variables

QT_SCALE_FACTOR

This is very similar to that "Window Scaling" factor that some desktops have, but it's limited to Qt applications. You can set it generally for all Qt applications, e.g. in your shell startup files (~/.bashrc or ´~/zshrc` etc.):

export QT_SCALE_FACTOR=1.5

(It may depend on your exact Qt version if fractional numbers are supported)

...or you can add it to each individual command line:

QT_SCALE_FACTOR=2  qdirstat

Tip: Add it to the .desktop File

You can do that specifically for QDirStat if you edit the command line in the qdirstat.desktop file. One caveat is that a .desktop file executes the binary directly, not wrapped into an extra shell instance, so you can't just use the above command there; you have to wrap it in a shell invocation:

sh -c "QT_SCALE_FACTOR=2  qdirstat %f"

So the whole .desktop file looks like this:

[Desktop Entry]
Type=Application
Name=QDirStat
Exec=sh -c "QT_SCALE_FACTOR=2 qdirstat %f"
Icon=qdirstat
GenericName=QDirStat Directory Statistics
Terminal=false
MimeType=inode/directory;inode/mount-point;
Categories=Qt;System;Filesystem;
Keywords=directory;tree;size;statistic;disk;space;

QT_SCALE_FACTOR_ROUNDING_POLICY

This indicates how to treat fractional factors. Values:

  • PassThrough: Use the value as-is.
  • Round: Round to the next integer number
  • Ceil: Round up
  • Floor: Round down
  • RoundPreferFloor: Round up for 0.75 and above

See also https://doc.qt.io/qt-5/qt.html#HighDpiScaleFactorRoundingPolicy-enum

The default for this may be different between Qt versions.

Example

export QT_SCALE_FACTOR_ROUNDING_POLICY=PassThrough
QT_SCALE_FACTOR=1.41 qdirstat

QT_SCREEN_SCALE_FACTORS

This is meant to be used for a multi-screen setup where each screen has a different resolution or physical size, so you need a different scale factor for each one:

QT_SCREEN_SCALE_FACTORS="1.5;2" qdirstat

Notice the quotes " to protect the semicolon ; from the shell.

Further Reading

There are many more environment variables that can be used with Qt, but that can get complicated quickly, and it might depend on the exact Qt 5.x version on your system.

For more information, see https://doc.qt.io/qt-5/highdpi.html#high-dpi-support-in-qt.

@shundhammer
Copy link
Owner Author

This is intended as documentation.

If you have a problem in this area, please open a new GitHub issue.

@shundhammer shundhammer changed the title QDirStat Font Size [Doc] QDirStat Font Size Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant