How to Enable HiDPI Display Scaling on FreeBSD Operating System

This article provides a step-by-step guide on how to enable HiDPI display scaling on FreeBSD operating system.

Introduction

High-DPI (HiDPI) displays offer significantly higher pixel density than standard displays, resulting in sharper text and clearer images. However, running a HiDPI display on FreeBSD requires manual configuration to ensure proper scaling, as the operating system does not enable automatic scaling by default. This guide provides a detailed walkthrough on enabling and optimizing HiDPI scaling on FreeBSD across different desktop environments.

Checking Display Resolution and DPI

Before configuring HiDPI scaling, determine your display’s resolution and DPI:

  1. Open a terminal and run:

    xdpyinfo | grep -B 2 resolution
    

    This command provides details about your screen resolution and DPI settings.

  2. Alternatively, use:

    xrandr | grep '*'
    

    This lists available resolutions for connected displays.

If your DPI is significantly higher than 96 (the standard baseline), scaling adjustments are necessary.

Adjusting HiDPI Scaling in Xorg

For users running Xorg, apply the following settings:

Modifying .xprofile or .xsession

  1. Edit or create ~/.xprofile (or ~/.xsession depending on your setup):

    nano ~/.xprofile
    
  2. Add the following line:

    export GDK_SCALE=2
    export GDK_DPI_SCALE=0.5
    

    This enables GTK-based application scaling.

  3. Apply the changes by logging out and logging back in.

Using Xrandr for Scaling

Xrandr provides on-the-fly scaling for Xorg. To enable scaling:

  1. Identify connected displays:

    xrandr --listmonitors
    
  2. Set a scale factor (e.g., 2x):

    xrandr --output HDMI-1 --scale 2x2
    

    Replace HDMI-1 with the correct output name.

  3. To make the changes persistent, add the command to ~/.xprofile or ~/.xsession.

Configuring HiDPI in Desktop Environments

KDE Plasma

KDE Plasma provides native HiDPI scaling:

  1. Open System Settings.
  2. Navigate to Display and Monitor > Scale Display.
  3. Adjust the scaling factor (e.g., 150% or 200%).
  4. Log out and log back in for changes to take effect.

To enable fractional scaling:

kwriteconfig5 --file kdeglobals --group KDE --key ForceFontDPI 144

GNOME

GNOME supports HiDPI scaling through its Settings application:

  1. Open Settings.
  2. Go to Displays.
  3. Under Scale, select a scaling factor (e.g., 200%).
  4. Log out and log back in.

For fractional scaling, run:

gsettings set org.gnome.mutter experimental-features "['scale-monitor-framebuffer']"

Xfce

Xfce does not natively support HiDPI but can be configured manually:

  1. Open Settings Manager.

  2. Navigate to Appearance > Fonts and set DPI to 144.

  3. Open Window Manager Tweaks > Compositor and increase UI scaling.

  4. Apply GTK scaling:

    echo 'Xft.dpi: 144' >> ~/.Xresources
    

    Then run:

    xrdb -merge ~/.Xresources
    

LXQt

LXQt requires manual scaling:

  1. Open LXQt Configuration Center > Appearance.

  2. Set font DPI to 144.

  3. Modify Qt environment variables:

    export QT_SCALE_FACTOR=2
    export QT_AUTO_SCREEN_SCALE_FACTOR=1
    

    Add these lines to ~/.xprofile for persistence.

Adjusting Fonts and UI Elements

Some applications may require additional font and UI scaling:

  • Firefox: Open about:config, search for layout.css.devPixelsPerPx, and set it to 2.0.

  • Chromium: Launch with:

    chromium --force-device-scale-factor=2
    
  • GTK Applications: Modify ~/.config/gtk-3.0/settings.ini:

    [Settings]
    gtk-font-name=Noto Sans 12
    gtk-xft-dpi=144000
    

Conclusion

Enabling HiDPI scaling on FreeBSD requires adjusting settings at various levels, including Xorg, desktop environments, and individual applications. By following the steps outlined above, you can achieve a more visually comfortable and sharp display experience on HiDPI monitors. Adjust settings as needed to balance performance and usability.