Ugly Horizontal Lines Displayed in Kate and Konsole with Fractional HiDPI Scaling

21,763

Solution 1

This is reported to have been resolved in QTBUG-66036 with version 5.12. As of the time I am writing this, QT on Arch Linux is version 5.11.2-1. Other common distros have also not released packages with Qt 5.12. However, when Qt 5.12 is released, the developers expect this issue to be resolved.

To check your Qt version, you can open a terminal and type:

qmake --version

The output will look similar to this

QMake version 3.1
Using Qt version 5.11.1 in /usr/lib

When you see Qt version 5.12, then you can expect a resolution. If not, let the developers know at QTBUG-66036.

In the mean time, there is a work-around, as described in the bug report below

Steps to reproduce:

  1. Displays -> Scale -> Scale Factor: 1.3 (or 1.4, etc.)
  2. Restart
  3. Open Konsole or Kate, type stuff

Workaround: set Scale Factor back to 1.0 (or to an integer such as 2 or 3).

There is a similar bug report for Konsole here

373232 – Horizontal lines with fractional HiDPI scaling
https://bugs.kde.org/show_bug.cgi?id=373232

Solution 2

Upgrading to Qt 5.12 is fine, but does not seem to fix the issue straight away. In Konsole profile settings under the advanced tab, change "Line Spacing" to 1. This has fixed the issue with horizontal lines for me.

Solution 3

As a workaround, you could change the Fonts DPI:

  1. go to Fonts, check the box Force Fonts DPI
  2. set to an appropriate value (I use 144 on a 2560x1440 screen, you may want to try 192 in 4K)
    • Higher DPI translate to bigger text in your screen
  3. Set the your display scaling factor back to 1
  4. Logout and login to your user (or restart)

At this point the horizontal lines should be gone and you should be able to read everything on your screen

Solution 4

Another workaround is setting Line Spacing to 1 under Settings -> Edit Current Profile ... -> Advanced -> Terminal Features. It's almost unnoticeable (one extra pixel between lines), but fixes the issue.

Solution 5

After following Nico's instructions about changing the system text DPI to something higher like 144, 192, etc., there is a way to turn on display scaling again and have Kate looking good. However, results may vary between desktop environments.

Set your display scaling to the desired fractional value (I happen to use 1.5x).

You can set the environment variable QT_SCREEN_SCALE_FACTORS=1 for a single call to Kate.

QT_SCREEN_SCALE_FACTORS=1 kate

And you can make a wrapper script for all calls to Kate

#!/bin/bash
cd $HOME
# Add home binaries directory & cd into it
mkdir -p bin && cd bin
# Symlink Kate executable as kate0
ln -s $(which kate) kate0
# Create the wrapper script
echo '#!/bin/bash' > kate
# This tells Kate to use a 1x scale factor, and to pass all arguments from wrapper
echo 'QT_SCREEN_SCALE_FACTORS=1 kate0 "$@"' >> kate
# Make the wrapper script executable
chmod +x kate

Then make sure that $HOME/bin is in your $PATH. If it is not, then you can add it by

export PATH="$HOME/bin:$PATH"

Add that to ~/.profile to make it permanent.

Note that in order for this to work, your home scripts must come before the path of the original Kate executable (e.g. /usr/bin) in your $PATH environment variable.

Share:
21,763
Jarek
Author by

Jarek

You may be interested in the story of SE moderator Monica Cellio and how she was unfairly treated by the corporate management of this site. More info here. An update is available. Let's hope we can cultivate a more fair environment for content creators and moderators going forward.

Updated on September 18, 2022

Comments

  • Jarek
    Jarek over 1 year

    Here is a picture of the problem:

    enter image description here

    Notice that all lines of text have horizontal lines similar to underlining. However, this is a plain text editor (Kate) and it does not do underlining. There is no formatting applied to this text.

    I selected the text so the lines would show up better in a photo. But the lines exist even without selecting the text. Sometimes they are much thicker and darker. Sometimes they are light. Sometimes they won't be there at all, only to come back at random.

    Konsole has the same issue. With white text on a black background, Konsole sometimes show multi-colored horizontal lines. Sometimes every line in Konsole has this ugly and distracting underlining. Sometimes only a portion of the lines have it.

    Sometimes the lines are so dense and overwhelming that it is hard to read the text. Other times the lines are mild, as in the attached photograph.

    I first saw this issue about a ten months ago on a desktop computer. I thought the user had just done something really crazy in font settings. But now I am seeing the issue on a new laptop without any significant settings changes from default.

    Both systems run a fully updated Arch Linux KDE. On this laptop, I reset all font settings (in System Settings) to default values. I also reset the Konsole profile appearance to default settings (even though settings were already at default values).

    However, the horizontal lines will not go away.

    The applications work correctly (other than sometimes being hard to read text). Copied text does not include the horizontal lines. Commands in Konsole are not affected by the appearance of horizontal lines. It seems to be a display glitch, but it is not specific to any GPU (affects Intel or nvidia) or to any display screen (I tested different monitors on the desktop) or to anything else I can determine.

    I tried various fixes on the affected desktop over the last ten months and I have not resolved it on that machine either.

    I have multiple other Arch KDE computers that do not have the problem.

    Does anyone have a clue as to what might cause this? Has else anyone seen it?

    Edit: Please see the KDE bug report for Konsole:
    373232 – Horizontal lines with fractional HiDPI scaling

    • drinor
      drinor over 4 years
      Temporary solution: QT_SCREEN_SCALE_FACTORS=1 konsole. You can create a desktop application link with this command.
  • tomasb
    tomasb almost 6 years
    that workaround is absurd on 4k+ btw
  • BugBuddy
    BugBuddy almost 6 years
    Yes, I agree that the workaround is terrible. Looking forward to a proper fix.
  • tomasb
    tomasb almost 6 years
    found that integer factors work well (e.g. 2.0, 3.0, ...)
  • Jarek
    Jarek almost 6 years
    please add a comment to the bug report: bugs.kde.org/show_bug.cgi?id=373232
  • BugBuddy
    BugBuddy almost 6 years
    @tomasb - my answer has been updated with your info. As MountainX said, please add your comment to the bug report.
  • tomasb
    tomasb almost 6 years
    @Bugger I'm sorry I do not have login there, feel free to add the comment by yourself
  • BugBuddy
    BugBuddy over 5 years
    @tomasb - If you want this fixed, please consider creating a login so you can let the developers know it affects you. If you are too lazy to do even that, you have no right to complain about the workaround (or anything else) being "absurd". If you use open source, please find ways to contribute, even if by only voting or commenting on bug reports -- anything. Be part of the community.
  • tomasb
    tomasb over 5 years
    @Bugger I am not lazy I have no time nowadays and yes I have the right still even when II don't want zillion of logins. If I offended anybody I am sorry.
  • User1291
    User1291 about 5 years
    had to increase it to 5, but worked fine. thank you.
  • Johan Boulé
    Johan Boulé almost 5 years
    @tomasb The workaround mentions integer scaling factors work fine, so it's not absurd on 4K, where you may use 2x to get good old Full HD DPI. Now, there are a lot more problems than this and KDE is unfortunately not looking good at all when the scale factor is not 1x. For example, text everywhere on widgets is looking ugly at 4K scale 2x compared to FHD 1x. I believe it's the font renderer that's doing a bad job with the extra pixels.
  • tiguchi
    tiguchi almost 5 years
    This is the only solution that works at the moment, and it will also adjust the scale of UI elements (not just font size). The dedicated "Scale Display" feature is still broken and causes several KDE applications to render with line artifacts.
  • WeKa
    WeKa over 4 years
    The option "Line Spacing" is not available in Konsole version 19.8.
  • ooXei1sh
    ooXei1sh over 4 years
    Right Click > Edit Current Profile... > Appearance > Miscellaneous > Line spacing
  • misantroop
    misantroop over 4 years
    I can change line spacing up to 8 but there's still lines sometimes. It's not a functional fix at all as the spacing ruins the interface.
  • Tatsh
    Tatsh over 4 years
    I was having this problem with Konsole, but I was also having a problem where Dolphin and Konsole would both have huge font size, effectively applying the 1.5x scale AND the 144 DPI. Setting the scale back to 1 but keeping 144 DPI fixed my issue.
  • Chris Holt
    Chris Holt over 3 years
    Since kate is the only application suffering from this bug for me, the "QT_SCREEN_SCALE_FACTORS=1" is the perfect solution. I'll just add that to an alias for kate and problem solved!! Thank you!
  • tbjgolden
    tbjgolden over 3 years
    Line spacing 1 didn't work for me, but line spacing 2 did; this bug seems like it's something not dividing nicely with the dpi - so it may need you to mess around with the line spacing to force the row height to be a "nice" height for your display/scaling