Bug 280896 - Some fonts get chopped with Qt 4.8
Summary: Some fonts get chopped with Qt 4.8
Status: RESOLVED UNMAINTAINED
Alias: None
Product: konsole
Classification: Applications
Component: font (show other bugs)
Version: unspecified
Platform: Compiled Sources FreeBSD
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
: 284848 284881 (view as bug list)
Depends on:
Blocks: 302520
  Show dependency treegraph
 
Reported: 2011-08-27 20:12 UTC by Raphael Kubo da Costa
Modified: 2016-12-07 19:47 UTC (History)
15 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Konsole with the Clean font (1.12 KB, image/png)
2011-08-27 20:12 UTC, Raphael Kubo da Costa
Details
Konsole with the Fixed (Sony) font (1.77 KB, image/png)
2011-08-27 20:12 UTC, Raphael Kubo da Costa
Details
Konsole with the Montecarlo font (1.01 KB, image/png)
2011-08-27 20:13 UTC, Raphael Kubo da Costa
Details
Konsole with ProggySquareTTSZ (715 bytes, image/png)
2011-08-27 20:13 UTC, Raphael Kubo da Costa
Details
konsole-text-ypos.patch (450 bytes, patch)
2011-12-28 00:34 UTC, Nikos Chantziaras
Details
Screenshot from KDE 4.10.90 (58.89 KB, image/png)
2013-06-28 14:06 UTC, Nikos Chantziaras
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Raphael Kubo da Costa 2011-08-27 20:12:08 UTC
Created attachment 63182 [details]
Konsole with the Clean font

Version:           unspecified (using Devel) 
OS:                FreeBSD

I'm using Konsole from git and qt from the 4.8 branch.

I _think_ this started when I switched from qt 4.7 to 4.8. Depending on the font I use (especially non-TTF ones), they get chopped off (as if each character was supposed to fit in a small square but didn't). I have attached screenshots of a few fonts (such as Montecarlo, Clean, Fixed and Profont).

If that matters, I have anti-aliasing disabled in Konsole.

Reproducible: Always

Steps to Reproduce:
- (Possibly) Use qt 4.8.
- Select a non-ttf font in Konsole.
- Type 'p' or 'j' and notice how the characters are not displayed correctly.


Expected Results:  
- The characters are shown correctly.
Comment 1 Raphael Kubo da Costa 2011-08-27 20:12:35 UTC
Created attachment 63183 [details]
Konsole with the Fixed (Sony) font
Comment 2 Raphael Kubo da Costa 2011-08-27 20:13:06 UTC
Created attachment 63184 [details]
Konsole with the Montecarlo font
Comment 3 Raphael Kubo da Costa 2011-08-27 20:13:43 UTC
Created attachment 63185 [details]
Konsole with ProggySquareTTSZ

This is actually a TTF font.
Comment 4 Christoph Feck 2011-08-28 19:48:36 UTC
Does Konsole use QFontMetrics::height() or QFontMetrics::lineSpacing()?
Comment 5 Luca Beltrame 2011-10-10 07:29:40 UTC
I have noticed that at least on my system, changing font hinting from "slight" to "full" in System Settings work-arounds the issue (at the expense of reduced font quality if properly TTF hinted fonts are installed).
Comment 6 Luca Beltrame 2011-10-10 07:43:33 UTC
To answer Cristoph: by digging a bit into the source, I found use of at least QFontMetrics:height() (TerminalDisplay.cpp, line 213). I didn't have time to look more in detail.
Comment 7 Raphael Kubo da Costa 2011-10-16 17:33:06 UTC
(In reply to comment #5)
> I have noticed that at least on my system, changing font hinting from "slight"
> to "full" in System Settings work-arounds the issue (at the expense of reduced
> font quality if properly TTF hinted fonts are installed).

Hmm, I tried changing the "hintstyle" option in my ~/.fonts.conf to "hintfull", but it didn't have any effect.
Comment 8 Jekyll Wu 2011-10-24 07:31:17 UTC
One recent commit by Christoph should have fixed this problem(at least for me). See https://git.reviewboard.kde.org/r/102899/ for more info.
Comment 9 András Manţia 2011-10-24 09:40:07 UTC
Does changing the bi-di rendering in konsole's setting helps, like I described in bug 284848 ?
Comment 10 Christoph Feck 2011-10-24 10:23:13 UTC
My commit should only affect horizontal metrics, but this bug is about vertical clipping.
Comment 11 Luca Beltrame 2011-10-24 14:51:45 UTC
I'm however unable to see the problem again since a few couple of days (updated both Qt and KDE).
Comment 12 Christoph Feck 2011-10-24 17:07:21 UTC
*** Bug 284881 has been marked as a duplicate of this bug. ***
Comment 13 Jekyll Wu 2011-10-25 04:48:08 UTC
(In reply to comment #9)
> Does changing the bi-di rendering in konsole's setting helps, like I described
> in bug 284848 ?

I do not use the "Misc Console" font, but enabling BiDi does eliminate the problem with the "Fixed Sony" font in comment #1 and "Terminus" font in bug #284881(including the floating cursor problem) for me.
Comment 14 Christoph Feck 2011-10-25 10:54:09 UTC
On a second look, the commit also affects the vertical metrics handling. If the actual metrics is "15.7 pixels", then QFontMetrics::height() will round that down to "15 pixels" causing the cropped appearance because the rendered pixmap will be 16 pixels tall.

Fixed in master with http://commits.kde.org/konsole/de5ef9484a253795002d0e6accc86cc3cb1b5c71
Comment 15 András Manţia 2011-10-25 11:29:19 UTC
Ok, but it certainly doesn't fix bug 284848, so that has another cause in that case.
Comment 16 Jekyll Wu 2011-10-25 12:30:36 UTC
Well, after observing how "Terminus" and "Fixed (Sony)" are rendered before and after that commit by Christoph, it seems that commit actually does not influence this problem or fix it. The results are the same: chopped when Bi-Di is disabled, while OK when Bi-Di is enabled.

I haven't repeated that observation on other mentioned fonts which I do not have. Can someone confirm my observation? If that is the case, then this report is actually the same as bug 284848.
Comment 17 Jeffrey Bastian 2011-10-25 15:54:28 UTC
The patch in comment 14 does not fix the problem with the Terminus font: it still chops off the bottoms of letters like q and g.
Comment 18 Raphael Kubo da Costa 2011-10-25 21:11:10 UTC
I can confirm that enabling Bi-Di in the profile fixes the issue with all the issues I have reported (comment #14 indeed does not have any effect).
Comment 19 Jekyll Wu 2011-10-26 08:13:50 UTC
[quoted from bug 284848]

Using Misc Console as Konsole's font, the fonts seems to be shifted down and
the last line is not rendered. This happens with Qt 4.8, but not with 4.7 and
only when Bi-di rendering is disabled in the konsole profile.
See https://bugreports.qt.nokia.com/browse/QTBUG-22270 .

I tried to reproduce with a simple 
 const QChar LTR_OVERRIDE_CHAR( 0x202D );
    p.drawText( r, 0, LTR_OVERRIDE_CHAR + text);

in a QWidget's paint event, but could not, probably Konsole does something else
as well.
Comment 20 Jekyll Wu 2011-10-26 08:14:14 UTC
*** Bug 284848 has been marked as a duplicate of this bug. ***
Comment 21 András Manţia 2011-10-26 09:16:12 UTC
Of course I also tried to reproduce with a Qt test app, but couldn't :( Even printed out all QFontMetrics data with Qt 4.8/4.7 using that font and got the same output. And I can't find any other code in Konsole that is affected by the bidi rendering, just the addition of that control character.
Comment 22 Petr Burian 2011-11-08 09:13:37 UTC
Enabling Bi-Di doesn't help with Terminus font - especially cursor highlight problem is still there. KDE 4.7.3.
Comment 23 Raphael Kubo da Costa 2011-11-10 02:07:34 UTC
(In reply to comment #22)
> Enabling Bi-Di doesn't help with Terminus font - especially cursor highlight
> problem is still there. KDE 4.7.3.

I don't understand what you mean by cursor highlight problem. Terminus + Bi-Di looks OK here with master and Qt 4.8.
Comment 24 Andrea Scarpino 2011-12-20 10:37:34 UTC
I can confirm that "Enabling Bi-Directional text rendering" fixes the issue for the Terminus font, but doesn't for the Monaco TTF font.

Arch Linux. Qt 4.8.0 here.
Comment 25 Andrea Scarpino 2011-12-20 11:15:51 UTC
(In reply to comment #24)
> I can confirm that "Enabling Bi-Directional text rendering" fixes the issue for
> the Terminus font, but doesn't for the Monaco TTF font.
> 
> Arch Linux. Qt 4.8.0 here.
Forgot it. Seems to work in kopete 4.7.90
Comment 26 tuxfusion 2011-12-25 11:41:43 UTC
Worked like a charm enabling bi-di rendering in Arch Linux. How about set it standard ? It was a bit of a hassle to find this bug report actually as one can hardly describe the issue ...
Comment 27 Daniel Eklöf 2011-12-25 12:00:21 UTC
Enabling bi-di is just a workaround, and thus enabling it by default not a real solution.

Besides, at least on my system, enabling bi-di causes a noticeable rendering performance hit.
Comment 28 Nikos Chantziaras 2011-12-27 20:13:57 UTC
Non-integer metrics were introduced in Qt 4.7, not 4.8, so this is probably not the problem, especially since setting ForceIntegerMetrics does not help.
Comment 29 Nikos Chantziaras 2011-12-28 00:34:57 UTC
Created attachment 67173 [details]
konsole-text-ypos.patch

I'm attaching a patch that fixes this (it's against 4.7.4).  It's trivial; it just sets the Qt::AlignBottom flag when calling drawText().
Comment 30 Rex Dieter 2011-12-28 02:28:53 UTC
and should that same flag be set in the _bidiEnabled case too?  If not, why not?
Comment 31 Nikos Chantziaras 2011-12-28 02:47:54 UTC
(In reply to comment #30)
> and should that same flag be set in the _bidiEnabled case too?  If not, why
> not?

I can be applied.  It just doesn't seem to change the result.  As to why, I don't know; didn't look to deep.  Could be a bug in Qt, since I don't see why drawing the 0x202D character (LTR_OVERRIDE_CHAR) should affect text alignment.
Comment 32 Daniel Eklöf 2011-12-28 08:27:43 UTC
(In reply to comment #29)
> Created an attachment (id=67173) [details]
> konsole-text-ypos.patch
> 
> I'm attaching a patch that fixes this (it's against 4.7.4).  It's trivial; it
> just sets the Qt::AlignBottom flag when calling drawText().

Thanks, works for me!
Comment 33 Daniel Eklöf 2012-01-06 09:28:15 UTC
(In reply to comment #29)
> Created an attachment (id=67173) [details]
> konsole-text-ypos.patch

This patch doesn't appear to be in 4.8rc2. Is there someone who can commit it?
Comment 34 Rex Dieter 2012-01-06 14:21:05 UTC
I can confirm the patch from comment #29 works as advertised (with several confirmations from others as well).
Comment 35 Rex Dieter 2012-01-06 14:24:23 UTC
interesting side-effect, testing with terminus, that I see some characters get chopped at the top, ones like ~ and ^
Comment 36 Rex Dieter 2012-01-06 14:29:16 UTC
Followup, seems to only happen using terminus @ 11pt
Comment 37 Christoph Feck 2012-01-11 01:44:00 UTC
The other workaround is to set _lineSpacing to 1, which I prefer, because it exactly restores the line height on my system.

The freetype shipped with Qt 4.8 seems to sometimes makes fonts smaller, see also bug 279490.
Comment 38 Kurt Hindenburg 2012-01-11 15:35:10 UTC
It doesn't look like I'm going to get a system w/ Qt4.8 + the above fonts installed by the tagging day.

Jekyll,  have you happened to look at this issue?
Comment 39 Rex Dieter 2012-01-31 19:33:47 UTC
So, Christoph, pardon my ignorance, but it is unclear to me how your suggestion to set _lineSpacing to 1 translates into something I can test.  Will that require patching the code too, or is it some configuration option?
Comment 40 Christoph Feck 2012-01-31 23:44:54 UTC
This is what I use:

diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp
index da2fb38..351afc4 100644
--- a/src/TerminalDisplay.cpp
+++ b/src/TerminalDisplay.cpp
@@ -304,7 +304,7 @@ TerminalDisplay::TerminalDisplay(QWidget* parent)
     , _resizeTimer(0)
     , _flowControlWarningEnabled(false)
     , _outputSuspendedLabel(0)
-    , _lineSpacing(0)
+    , _lineSpacing(1)
     , _colorsInverted(false)
     , _blendColor(qRgba(0, 0, 0, 0xff))
     , _filterChain(new TerminalImageFilterChain())
Comment 41 Rex Dieter 2012-02-01 00:05:08 UTC
Thanks!  OK, I can confirm that a combination of setting Qt::AlignBottom fixes the descender problem and setting _lineSpacing(1) fixes the ascender case.
Comment 42 Kurt Hindenburg 2012-02-04 21:23:30 UTC
Git commit 47f504785f1855e0dbe81197ed1b5496ca641a0f by Kurt Hindenburg.
Committed on 04/02/2012 at 22:21.
Pushed by hindenburg into branch 'master'.

A quick fix to get fonts to look OK w/ Qt4.8 and bidi off

Hopefully a temp fix for this issue.  It would be better to find out
what happened with Qt4.8 font rendering.

Thanks to people on bug report for research and info.

M  +9    -1    src/TerminalDisplay.cpp
M  +8    -0    src/TerminalDisplay.h

http://commits.kde.org/konsole/47f504785f1855e0dbe81197ed1b5496ca641a0f
Comment 43 Kurt Hindenburg 2012-03-31 00:58:23 UTC
Git commit bf3e57e94b54c1c4337d7960e0fda0ef98156451 by Kurt Hindenburg.
Committed on 31/03/2012 at 02:55.
Pushed by hindenburg into branch 'KDE/4.8'.

A quick fix to get fonts to look OK w/ Qt4.8 and bidi off

    Hopefully a temp fix for this issue.  It would be better to find out
    what happened with Qt4.8 font rendering.

    Thanks to people on bug report for research and info.

M  +11   -3    src/TerminalDisplay.cpp
M  +11   -1    src/TerminalDisplay.h

http://commits.kde.org/konsole/bf3e57e94b54c1c4337d7960e0fda0ef98156451
Comment 44 András Manţia 2012-03-31 08:44:34 UTC
FYI, Nokia closed the upstream bug report https://bugreports.qt-project.org/browse/QTBUG-22270 because of lack of feedback(I didn't have time to make a Qt only test case).
Comment 45 Lars Doelle 2012-06-02 16:35:20 UTC
> --- Comment #43 from Kurt V. Hindenburg <kurt.hindenburg@gmail.com> ---
> Git commit bf3e57e94b54c1c4337d7960e0fda0ef98156451 by Kurt Hindenburg.
> Committed on 31/03/2012 at 02:55.

Applying the patch on konsole-4.7.4 (debian unstable) i can report
it makes the konsole usable again with pcf fonts, but still the rendering
has a wrong idea about the font metric.

Visually guessing, two extra pixels are added to the ascent.

In undecorated fullscreen mode, i get

$ stty size
66 239

while on the linux console with the same resolution i have

# stty size
75 240

Note that this is (basically) the same font (console8x16.pcf.gz
and the linux console font) having an 8/16 geometry, meaning
9 lines and one columns are lost.

# fbset
                                                                                                                                                                                                                                               
mode "1920x1200"
    geometry 1920 1200 1920 1200 32
    timings 0 0 0 0 0 0 0
    accel true
    rgba 8/16,8/8,8/0,0/0
endmode

Thus 1200/16=75 and 1920/8 = 240.

The konsole underestimates the size of the screen due to an older glitch
in the size calculation perhaps not taking the frame into account, so it
would "normally" (i.e. without the current problem) show

$ stty size
74 239

Thus (1200-1)/(16+2) gives 66.61.. confirming my visual guess.

Please let me know if i can help along further.

-lars


> --- Comment #43 from Kurt V. Hindenburg <kurt.hindenburg@gmail.com> ---
> Git commit bf3e57e94b54c1c4337d7960e0fda0ef98156451 by Kurt Hindenburg.
> Committed on 31/03/2012 at 02:55.
> Pushed by hindenburg into branch 'KDE/4.8'.
> 
> A quick fix to get fonts to look OK w/ Qt4.8 and bidi off
Comment 46 Nikos Chantziaras 2013-06-28 14:06:08 UTC
Created attachment 80835 [details]
Screenshot from KDE 4.10.90

When I updated KDE from 4.10.4 to 4.10.80 (and now 4.10.90), I get some characters that are chopped again. Attaching screenshot. Doesn't happen all the time and not on all text lines.

Should I open a new bug about this, or can this be considered the same issue as this bug?
Comment 47 Christoph Feck 2016-12-07 19:47:11 UTC
The Qt4 version of Konsole is no longer maintained. This issue could be fixed in the master branch, see bug 371687.

Please followup there.