Bug 303553 - [PATCH] rendering of indentation lines is ugly
Summary: [PATCH] rendering of indentation lines is ugly
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: part (show other bugs)
Version: unspecified
Platform: Debian unstable Linux
: HI normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-15 12:42 UTC by nfxjfg
Modified: 2013-07-18 20:57 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.12


Attachments
Antialiasing switched off (15.43 KB, image/png)
2012-07-16 12:28 UTC, Christoph Feck
Details

Note You need to log in before you can comment on or make changes to this bug.
Description nfxjfg 2012-07-15 12:42:35 UTC
After installing kate 4.8.4-1, I noticed that indentation lines are rendered exceedingly ugly. They are two pixels thick and in gray color. They used to be rendered as dotted lines. I had to revert to kate 4.7.2-1 to get acceptable rendering. (I'm using the Debian package version numbers here. I'm not sure if that is correct. The about dialog shows something else.)

Here is a screenshot of the new, bogus rendering: http://ompldr.org/vZXIwZQ
Same with the old, better rendering: http://ompldr.org/vZXIxYg

It seems there might actually be two issues:
- dotted line rendering was replaced with a solid line
- solid line rendering doesn't turn out as intended (?)

Reproducible: Always

Steps to Reproduce:
-
Actual Results:  
Gray, thick indentation line.

http://ompldr.org/vZXIwZQ


Expected Results:  
Thin, dotted indentation line.

http://ompldr.org/vZXIxYg

When trying kate versions between the two mentioned, there were some versions which rendered the line inconsistently, either as gray thick solid line or thing black solid line in the same view.

It seems this commit triggered this issue: https://projects.kde.org/projects/kde/kde-baseapps/kate/repository/revisions/c7348650f659209d30f28b1508e96db26a7fb1c8

I certainly don't agree that it looks "fine", and the old method never seemed to cause any slowness, even though my computer is getting old. While the old method of drawing a dotted line wasn't particularly elegant, I'm sure there's something better in the KDE rendering API that kate could use.
Comment 1 Christoph Feck 2012-07-16 12:28:02 UTC
Created attachment 72556 [details]
Antialiasing switched off

Using "QPainter::Antialiasing = false" does wonders (only 1 pixel thick now). The other problem is that the line is not positioned correctly. The metrics calculation Kate uses does not follow the metrics calculation Qt uses.

Screen shot attached.
Comment 2 Christoph Feck 2012-07-16 12:30:32 UTC
On the other hand, on very high DPI displays, a single-pixel line might be too thin. I suggest to use the same line thickness as the "underline". See QFontMetricsF::lineWidth().
Comment 3 Christoph Feck 2012-07-16 12:40:19 UTC
Ah, Kate uses QFontMetrics, instead of QFontMetricsF... To compute the width of eight spaces, you either have to use

    QFontMetrics::width("        ");

or use

    8 * QFontMetricsF.width(' ');
Comment 4 Christoph Cullmann 2012-10-24 13:59:10 UTC
Git commit 18afabd3cf527e8ce987b25c74eb8ee6dbf7ed96 by Christoph Cullmann.
Committed on 24/10/2012 at 15:45.
Pushed by cullmann into branch 'master'.

use fontmetricsF
that fixes positioning (and using qreal for calc)
new style without dotted lines is wanted

M  +6    -6    part/render/katerenderer.cpp
M  +3    -8    part/render/katerenderer.h
M  +3    -3    part/utils/kateconfig.cpp
M  +3    -3    part/utils/kateconfig.h
M  +1    -1    part/view/kateviewhelpers.cpp

http://commits.kde.org/kate/18afabd3cf527e8ce987b25c74eb8ee6dbf7ed96
Comment 5 nfxjfg 2013-06-02 14:10:08 UTC
After having used 4.7 for a long time (because Debian was keeping 4.8 and 4.8 is broken), I tried 4.10. Well, the indentation lines are still ugly and 2 pixels wide. They are thicker than the underline thickness of the normal font too. The lighter color makes it look better than on 4.8, though. (Not sure where that color comes from, I didn't change any settings when upgrading though.)

Assuming this commit is included in 4.10, I'm reopening the bug.

Here's a screenshot that contains both indentation line and underline: http://www.abload.de/img/scra7upt.png
Comment 6 Dominik Haumann 2013-06-02 14:18:52 UTC
Settings > Configure Kate > Fonts & Colors. There you have "Indentation Lines" as entry. You can change the color to your liking.

Would the Dottet style on http://qt-project.org/doc/qt-4.8/qpen.html#pen-style work for you?
Comment 7 nfxjfg 2013-06-02 14:32:18 UTC
Qt::DotLine has too much spacing between the dots (looks like a 2-1-2-1 pattern), but with "pen.setDashPattern( QVector<qreal>() << 1 << 1 );" an even pattern with a 1 pixel dot followed by 1 pixel space.

Thanks for caring about this!
Comment 8 Joseph Wenninger 2013-07-18 11:26:12 UTC
Git commit 46022a0ca69fdd1901d912f7828613baea8a4f8a by Joseph Wenninger.
Committed on 18/07/2013 at 09:11.
Pushed by jowenn into branch 'master'.

experimental in master. Show dots again instead of a solid line, can't promise that it will stay in

M  +8    -2    part/render/katerenderer.cpp

http://commits.kde.org/kate/46022a0ca69fdd1901d912f7828613baea8a4f8a
Comment 9 Dominik Haumann 2013-07-18 14:25:19 UTC
Given jowenn's commit, close this report.
Comment 10 nfxjfg 2013-07-18 17:32:26 UTC
Thank you. But unfortunately, it's still not right. The dots are not quadratic: they are 1 pixel high (good), but 2 pixels wide (bad). Also, the last dot before an empty line starts is slightly lighter. Not a problem by itself, but maybe it gives a hint what goes wrong when rendering. Note that the word wrap marker line has the correct width (1 pixel).

Here's a screenshot: http://www.abload.de/img/shot9zahp.png 

(For some reason, the font rendering looks worse than on the screen. I used imagemagick import to take this screenshot and I'm not sure what's going wrong. But it still conveys the basic idea what's wrong.)
Comment 11 Christoph Feck 2013-07-18 18:11:39 UTC
Yep, the actual problem is not fixed. To fix it, either anti-aliasing (see comment #1) could be switched off, or line coordinates rounded to nearest integer.
Comment 12 Milian Wolff 2013-07-18 19:51:10 UTC
Git commit c66be2a73282275819aed69dd9421e83c4be9f26 by Milian Wolff.
Committed on 18/07/2013 at 19:50.
Pushed by mwolff into branch 'master'.

Disable antialiasing for the indentation lines.

Since the lines are now not washed out anymore, the contrast should
probably be decreased by default.

M  +5    -0    part/render/katerenderer.cpp

http://commits.kde.org/kate/c66be2a73282275819aed69dd9421e83c4be9f26
Comment 13 nfxjfg 2013-07-18 20:10:57 UTC
I tried it, and I think it looks pretty good now!
Comment 14 nfxjfg 2013-07-18 20:57:59 UTC
Sometimes it looks a bit odd, though: http://abload.de/img/shot22wuir.png

(Again, font rendering looks broken on the screenshot, but looks fine on actual display for unknown reason. The indention lines look the same, though.)