Bug 383922 - [PATCH] Display scaling breaks Kate's spellcheck highlighting on high DPI monitor
Summary: [PATCH] Display scaling breaks Kate's spellcheck highlighting on high DPI mon...
Status: RESOLVED WORKSFORME
Alias: None
Product: kate
Classification: Applications
Component: kwrite (show other bugs)
Version: 17.04.2
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords: usability
: 387359 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-08-23 16:51 UTC by Piotr
Modified: 2018-08-17 09:58 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr 2017-08-23 16:51:56 UTC
The highlighting of misspelled word fails for me to work in Kate when the display is scaled-up. I have a high DPI screen 3200x1800 and I am using 1.5 scaling factor for the display.

When the highlighting works:
Create a brand new user > log in to it > open Kate > type something > press Ctrl+O > red highlighting of misspelled words appears 

When it doesn't:
Go to System Settings > Display > Displays > Scale Display > change the display scale to 1.5 (one-point-five) > log out > log in > open Kate > ..... > NO highlighting :-( 

I've also checked on my original account. Changing the display scale to 1.0 brings back the highlighting (but letters in icons, texts, windows etc are to small to read comfortably).   

My system:
Qt 5.7.1
KDE Frameworks 5.35.0
kf5-config 1.0
plasmashell 5.10.2
Kate 17.04.2 , the xcb windowing system
Comment 1 Piotr 2017-08-23 17:02:11 UTC
Also, when I start Kate for the first time in session on a 1.5 scaled display I get this lines across Kate's window. They correspond to the text line density:

https://dl.dropboxusercontent.com/u/834906/Screenshot_kate.png
Comment 2 Christoph Feck 2017-08-25 12:17:49 UTC
Second issue is bug 382902. The spellchecking issue could be related, or caused by the Sonnet framework.
Comment 3 Marcin Ciosek 2017-10-04 09:55:30 UTC
I've noticed the same bug with KMail.
My screen resolution is 4k.
If I set the DPI to 192 no highlighting of spellcheck mistakes (although right click on a word that I know is wrongly typed brings up an menu with corrections suggestions).
If however I set the DPI to 144 - I get the red underlining of the misspelled words.
Going forward - DPI 144 but the scale factor 1.5 - no highlighting (naturally with 192DPI as well).
DPI 96 and scale factor 1.5 - no highlights.

Checked with a fresh account, standard Breeze style (but also with Oxygen).
System - openSUSE Leap 42.3
KMail 5.6.1
KDE Frameworks 5.38.0
Qt 5.9.1
Plasma 17.08.1
Comment 4 Nate Graham 2017-11-28 20:36:58 UTC
*** Bug 387359 has been marked as a duplicate of this bug. ***
Comment 5 nfxjfg 2017-11-28 20:46:43 UTC
I can observe that only the highlighting is broken. I didn't notice any other breakages, other than maybe the indentation line rendering being a bit rough.
Comment 6 nfxjfg 2018-02-07 13:45:56 UTC
Digging a bit deeper, it seems kate/ktexteditor don't even render this, but leave this to Qt. I also can't confirm that it has to do with HiDPI (on the other hand it's quite challenging finding the various permutations of half-broken settings at which HiDPI works or breaks).

In fact it seems kate can't render any underlined text, and trying to set the default text style to underline simply has no effect. It also sort of explains why git-cola (which also uses Qt5) had its spell checking rendering broken at the same time.

I tried to update to Qt 5.10 from Debian experimental, but then it turned out that experimental has no KDE packages built against 5.10, so it just removed all of my KDE packages. Downgrading it again was a huge pain because Debian's package management is such a pile of shitty garbage.

God, I hate the Linux desktop so much.
Comment 7 nfxjfg 2018-02-07 14:33:22 UTC
Messing with it some more, it actually seems merely SpellCheckUnderline is broken. Using WaveUnderline (and even DotLine) seems to make it work. So something like this restores spell check rendering:

--- a/src/spellcheck/ontheflycheck.cpp
+++ b/src/spellcheck/ontheflycheck.cpp
@@ -608,7 +608,7 @@ void KateOnTheFlyChecker::misspelling(const QString &word, i
nt start)                                                                                                           rangeStart + translatedEnd));
     movingRange->setFeedback(this);
     KTextEditor::Attribute *attribute = new KTextEditor::Attribute();
-    attribute->setUnderlineStyle(QTextCharFormat::SpellCheckUnderline);
+    attribute->setUnderlineStyle(QTextCharFormat::WaveUnderline);
     attribute->setUnderlineColor(KateRendererConfig::global()->spellingMistakeL
ineColor());                                                                     


This looks like it's probably a really dumb Qt bug. A quick look at the Qt repo seems to confirm this and that it was fixed:

88e6f8cff2974c46b1262f3a1a61e1440c664e0c

    Fix implementation of spell check underline styles
    
    The QTextCharFormat documentation said that the used style is based on
    QStyle::SH_SpellCheckUnderlineStyle style hint, however in fact the
    implementation (drawTextItemDecoration in qpainter.cpp) uses
    themeHint(QPlatformTheme::SpellCheckUnderlineStyle) instead since Qt 5
    (see commit 1f9ae50457a3750f).

    (...)

It looks like the fix might actually be in Qt 5.10 or Qt 5.9.3, which Debian has been too incompetent to update to so far. (My version seems to be 5.9.2 in unstable, and 5.10 with lots of broken packages in experimental.)
Comment 8 Dominik Haumann 2018-02-08 14:50:19 UTC
could you post your patch on https://phabricator.kde.org/differential/ ? Click on "Create Diff" on the top right, and upload your diff.

And best add some screenshots with drag & drop.
Comment 9 Nate Graham 2018-02-08 16:12:11 UTC
Also, I just updated the documentation for this process, which can be found at https://community.kde.org/Infrastructure/Phabricator

Hopefully that should guide you!
Comment 10 nfxjfg 2018-02-08 17:00:28 UTC
It _should_ just work with Qt 5.9.3 or 5.10, so a patch shouldn't be necessary (rather, I'd expect distros who insist not updating to apply the Qt patch I pointed out). So I don't think sending a patch would make sense. A theme could in theory change the appearance of the error line from what I understood, and the inline ktexteditor patch I posted would break it.
Comment 11 Nate Graham 2018-02-08 17:09:25 UTC
Can anyone using Qt 5.9.3 or 5.10 confirm that the issue is gone for them?
Comment 12 nfxjfg 2018-02-08 17:25:35 UTC
Unfortunately I can't test this - I'd have to rebuild the world or so, because kate depends on so many other KDE components. (Maybe I should switch to Gentoo?)

I'm pretty sure my analysis is right though. Here's a link to the Qt change;

https://github.com/qt/qtbase/commit/88e6f8cff2974c46b1262f3a1a61e1440c664e0c

As you can see it didn't SpellCheckUnderline resolve to an actual underline style, and I suspect the text renderer itself just dropped the underline.

The bug report also contains some confusing issues which I don't see:

https://bugreports.qt.io/browse/QTBUG-50499
Comment 13 Christoph Cullmann 2018-08-17 09:58:47 UTC
I have here a HiDPI screen + Qt 5.11 and Kate 18.04.
I see again the underlined stuff.
Therefore this should work again.
Sorry that this regressed :(