Bug 307824 - Wrong character spacing makes text unreadable
Summary: Wrong character spacing makes text unreadable
Status: REPORTED
Alias: None
Product: konqueror
Classification: Unclassified
Component: khtml renderer (show other bugs)
Version: 4.9.2
Platform: unspecified Linux
: NOR normal with 60 votes (vote)
Target Milestone: ---
Assignee: Konqueror Developers
URL: http://www.phoronix.com/scan.php?page...
Keywords:
: 312197 322451 334489 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-10-04 10:57 UTC by Laurent Bonnaud
Modified: 2014-12-12 21:25 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Screenshot (7.40 KB, image/png)
2012-10-04 11:50 UTC, Laurent Bonnaud
Details
Screenshot from http://kde.org (30.59 KB, image/png)
2012-11-02 17:31 UTC, Graeme Hewson
Details
Screenshot of Akregator rendering http://commit-digest.org/issues/2012-09-30/ (218.85 KB, image/png)
2012-11-04 18:26 UTC, Graeme Hewson
Details
Test case (2.07 KB, text/html)
2012-11-13 17:29 UTC, Graeme Hewson
Details
Screenshot of test case (111.06 KB, image/png)
2012-11-13 17:30 UTC, Graeme Hewson
Details
Screenshot of test case on Debian jessie/sid with anti-aliasing = System Settings (93.16 KB, image/png)
2014-01-11 17:07 UTC, Graeme Hewson
Details
Screenshot of test case on Debian jessie/sid with sub-pixel rendering enabled (104.10 KB, image/png)
2014-01-11 17:08 UTC, Graeme Hewson
Details
Disable subpixel positioning in KHTML (841 bytes, patch)
2014-01-15 02:17 UTC, Lukáš Turek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent Bonnaud 2012-10-04 10:57:15 UTC
When I look at this page in akregator and konqueror with KHTML, the sentence "as reflected by the meeting minutes" is hardly readable because the space between "by" and "the" is negative and both words overlap.

This bug does not exist in konqueror with WebKit.

If akregator allowed to use webkit, then this bug would be less of a problem.


Reproducible: Always

Steps to Reproduce:
1. Load the page in konqueror with KHTML view mode
2. Try to read the text

Actual Results:  
Text difficult to read because of incorrect spacing.


Expected Results:  
Text easily readable.
Comment 1 Christoph Feck 2012-10-04 11:34:07 UTC
See also bug 290485.
Comment 2 Laurent Bonnaud 2012-10-04 11:50:32 UTC
Created attachment 74333 [details]
Screenshot
Comment 3 Graeme Hewson 2012-11-02 17:31:39 UTC
Created attachment 74941 [details]
Screenshot from http://kde.org
Comment 4 Graeme Hewson 2012-11-02 17:33:04 UTC
The problem is not only on phoronix.com, and not only with crowded spacing. The problem occurs on many sites, and mostly (IME) produces too much spacing. Too much extraneous spacing makes text difficult to read, as well as crowded spacing.

I'm attaching a screenshot from the home page of http://kde.org, where I've mouse-selected a line. KHTML has rendered it so it seems there are spaces in front of the commas (as in "providing major updates to KDE Plasma Workspaces , KDE Applications , and the"). However, if I paste the line into Konsole, with a fixed-pitch font, this shows there are not really extra spaces.

Note the breaks in the mouse selection. Before the commas, the HTML has "</a>" end tags. Could KHTML be mistakenly allowing space for these tags? There's also a small gap in the following line between "KDE Platform" and the "." (not mouse-selected).

These problems started happening with 4.9.2.
Comment 5 Graeme Hewson 2012-11-04 18:26:36 UTC
Created attachment 75006 [details]
Screenshot of Akregator rendering http://commit-digest.org/issues/2012-09-30/

Adding attachment showing Akregator rendering http://commit-digest.org/issues/2012-09-30/. Notice the poor layout of the contributors at the top. The Commit Summary is unreadable.
Comment 6 Graeme Hewson 2012-11-13 17:29:05 UTC
Created attachment 75226 [details]
Test case
Comment 7 Graeme Hewson 2012-11-13 17:30:35 UTC
Created attachment 75227 [details]
Screenshot of test case

The test case has five numbered paragraphs, basically all the same (with extra lines in paragraphs 3 and 4), of different font sizes. It demonstrates that text spacing varies, becoming too much or too little according to the font size, the length of the sentence and particular character combinations. This sounds as though it might be something to do with kerning, but the problems happen with a fixed-pitch font as well as a proportional font. In the screenshot I show Courier, but I've also tested with Palatino, Liberation Sans and other proportional fonts.
Comment 8 Graeme Hewson 2012-11-15 17:39:27 UTC
It's not really a rendering problem with commit-digest.org. The bunched-up effect is due to the use of fixed-size elements to construct the bar chart, etc.

I found the rendering problem proper goes away if I turn on sub-pixel rendering through System Settings / Application Appearance / Fonts.

See also bug 225040.
Comment 9 Christoph Feck 2013-07-17 11:53:58 UTC
*** Bug 322451 has been marked as a duplicate of this bug. ***
Comment 10 Lukáš Turek 2014-01-10 13:31:41 UTC
It seems the bug is fixed in KDE 4.11 - at least in Konqueror and some other apps that can display HTML (Kmail, Krusader). However, it's still present in Akregator: only there the HTML is rendered with subpixel positioning enabled. Any idea how is that possible? QtWebKit itself disables subpixel positioning by setting QFont::ForceIntegerMetrics. Switching to KHTML kpart makes no difference in both Konqueror and Akregator (but it works - User-Agent changes). Does anybody know how the bug was fixed in Konqueror in the first place? I'm now looking for any clue in Akregator source, so any pointers would be appreciated.
Comment 11 Christoph Feck 2014-01-10 16:54:42 UTC
It's not fixed on my system (KHTML 4.12.1), so what you see might be specific to your system.
Comment 12 Lukáš Turek 2014-01-10 17:20:07 UTC
That makes it even more mysterious... I'm using stable Gentoo system with KWebKitPart (but there's no difference with plain KHTML kpart).
Comment 13 Graeme Hewson 2014-01-10 17:37:13 UTC
It's OK on my system, Kubuntu 13.10 with the KDE PPA updates. libkhtml5 is version 4:4.12.0-0ubuntu1~ubuntu13.10~ppa1.
Comment 14 Graeme Hewson 2014-01-10 17:44:31 UTC
I forgot to check sub-pixel rendering. I don't see a setting for it now in System Settings, though. How can I check/change the setting?
Comment 15 Lukáš Turek 2014-01-10 18:25:46 UTC
I don't have subpixel rendering enabled, I don't like it, it reminds me of chromatic abberation in photos... I have this settings in .config/fontconfig/fonts.conf (fontconfig before 2.10 used ~/.fonts.conf):

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
 <dir>~/.fonts</dir>
 <match target="font" >
  <edit mode="assign" name="rgba" >
   <const>none</const>
  </edit>
 </match>
 <match target="font" >
  <edit mode="assign" name="hinting" >
   <bool>true</bool>
  </edit>
 </match>
 <match target="font" >
  <edit mode="assign" name="hintstyle" >
   <const>hintslight</const>
  </edit>
 </match>
 <match target="font" >
  <edit mode="assign" name="antialias" >
   <bool>true</bool>
  </edit>
 </match>
</fontconfig>

Just to prevent potential confusion: subpixel rendering and subpixel positioning are completely different concepts. Subpixel rendering means taking advantage of the fact that LCD display usually consists of rows of alternating red, green and blue pixels to achieve three times higher horizontal resolution - if you don't mind the color artifact on letter edges. While subpixel positioning means that position of each letter is calculated with split-pixel precision. When enabled, the same letter is rendered differently each time, which is most apparent in strings like these: iiiiiiiiiii ooooooo. With hinting in place you can no longer calculate the horizontal size of a block of text as a sum of the horizontal sizes of letters. Subpixel positioning is enabled by default since QT 4.8 and it seems there's no way to disable it in configuration, only in code by setting font.setStyleStrategy(QFont::ForceIntegerMetrics). That's what QtWebKit does, unconditionally, and that's why I'm so puzzled by this bug.
Comment 16 Graeme Hewson 2014-01-10 20:47:26 UTC
OK, I found the setting in System Settings / Application Appearance / Fonts / Anti-aliasing / Configure.

I confirm the problem is not apparent now, whether or not sub-pixel rendering is enabled, or whether or not anti-aliasing is enabled. I tested the phoronix.com page reported initially, and my test case in comment 6.

(Wow, it really looks horrible with anti-aliasing disabled altogether!)
Comment 17 Lukáš Turek 2014-01-10 21:34:33 UTC
Could you also try Akregator?(In reply to comment #16)
> I confirm the problem is not apparent now, whether or not sub-pixel
> rendering is enabled, or whether or not anti-aliasing is enabled. I tested
> the phoronix.com page reported initially, and my test case in comment 6.
Could you also try Akregator as in comment 5? And maybe also look closely at the testcase in Konqueror to make sure subpixel positioning is really disabled? Best would be to take a screenshot and magnify it in Kolourpaint or something, all those dots should look exactly the same, pixel for pixel.
Comment 18 Graeme Hewson 2014-01-11 17:02:48 UTC
I still have the same article in my Akregator archive as in the screenshot in comment 5, and now it's rendering fine. As I said in comment 8, though, I don't think the original problem there was due to the bug we're discussing here. I suspect there have been some changes to the stylesheet, or something else server-side.

I've also run the test case on Debian jessie/sid with KDE 4.11.3. Anti-aliasing was set to "System Settings" with this .config/fontconfig/fonts.conf:

<?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
 <match target="font">
  <edit mode="assign" name="rgba">
   <const>none</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hinting">
   <bool>true</bool>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hintstyle">
   <const>hintmedium</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="antialias">
   <bool>true</bool>
  </edit>
 </match>
 </match>
</fontconfig>

That rendered OK, as it did when I set sub-pixel rendering on. GIMP shows that sub-pixel rendering really was off in the first case. I'll upload screen shots.

BTW, bug 225040 is still present for me.
Comment 19 Graeme Hewson 2014-01-11 17:07:19 UTC
Created attachment 84571 [details]
Screenshot of test case on Debian jessie/sid with anti-aliasing = System Settings
Comment 20 Graeme Hewson 2014-01-11 17:08:15 UTC
Created attachment 84572 [details]
Screenshot of test case on Debian jessie/sid with sub-pixel rendering enabled
Comment 21 Christoph Feck 2014-01-11 17:27:18 UTC
This bug has nothing to do with sub-pixel (RGB) rendering, but with fractional font metrics that has been introduced in Qt 4.8 to improve the text quality. KHTML simply adds the integer widths of each character to compute the bounding boxes, instead of passing the complete string.

But PLEASE do not "fix" it by using ForceIntegerMetrics. This looks even more ugly, once you get used to fractional metrics. It's one of the reasons I still use KHTML for reading the net.
Comment 22 Graeme Hewson 2014-01-11 21:19:49 UTC
Still, as I noted in comment 8, I found (14 months ago) that turning on sub-pixel rendering made the spacing problem go away.
Comment 23 Lukáš Turek 2014-01-15 02:15:00 UTC
(In reply to comment #21)
> But PLEASE do not "fix" it by using ForceIntegerMetrics. This looks even
> more ugly, once you get used to fractional metrics. It's one of the reasons
> I still use KHTML for reading the net.
Unfortunately changing KHTML/WebKit to use fractional metrics would likely be a large amount of work and it would need someone knowledgeable with the code base. It seems ForceIntegerMetrics was added to Qt specifically for WebKit, even Qt developers weren't able to make WebKit use fractional metrics when they integrated it into Qt. The only thing I was able to do was to set ForceIntegerMetrics in KHTMLPart which makes the rendering problem in Akregator go away (because Akregator uses KHTMLPart directly, even when WebKit browser engine is selected).
Comment 24 Lukáš Turek 2014-01-15 02:17:24 UTC
Created attachment 84652 [details]
Disable subpixel positioning in KHTML
Comment 25 Christoph Feck 2014-07-15 01:14:37 UTC
*** Bug 312197 has been marked as a duplicate of this bug. ***
Comment 26 Christoph Feck 2014-12-12 21:25:35 UTC
*** Bug 334489 has been marked as a duplicate of this bug. ***