Bug 378152 - The SemiCondensed Fixed font isn't handled correctly by Konsole
Summary: The SemiCondensed Fixed font isn't handled correctly by Konsole
Status: CONFIRMED
Alias: None
Product: konsole
Classification: Applications
Component: font (show other bugs)
Version: 21.08.2
Platform: RedHat Enterprise Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL: https://bugreports.qt.io/browse/QTBUG...
Keywords: regression
Depends on:
Blocks:
 
Reported: 2017-03-27 10:42 UTC by David Howells
Modified: 2021-11-15 07:04 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
workaround patch (740 bytes, patch)
2021-11-11 05:47 UTC, Jiri Slaby
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Howells 2017-03-27 10:42:12 UTC
The SemiCondensed Fixed font (that used by xterm) isn't handled correctly by Konsole.  You can select it and it will be used, but if you exit the konsole process and create a new one, although the font selection dialogue shows that the font has been remembered, what appears is something else with the wrong character spacing set.

The Fixed SC font can be reapplied by going into the font selection box and hitting OK.  As mentioned, it does seem to remember that it should be using the Fixes SC font.

Note that creating a new terminal window by hitting Ctrl+Shift+N from within an extant terminal shows a new window with the correct font and the correct width, but a height based on whatever the font was when the program was opened initially.
Comment 1 David Howells 2019-09-13 14:25:59 UTC
Now Konsole won't allow use of the SemiCondensed Fixed font at all.  You can use the normal fixed font.  You can also select the SemiCondensed variant, but it will ignore the setting and just use the normal one.  It kind of worked up till relatively recently (Fedora 29 worked; 30 does not).
Comment 2 Mariusz Glebocki 2019-09-14 12:47:37 UTC
Still happens on master.
For me, selecting "semicondensed" makes Konsole use some variant with square characters, but it is also wrong.

Few observations:
* The font preview (the one with font name) in profile settings (not font selection window):
  - uses right variant just after selection
  - uses "regular" after Konsole restart - this applies to all variants, not only SC
* The config stores "Font=Fixed [Misc],10,-1,5,57,0,0,0,0,0,SemiCondensed", which looks OK.

So we have a problem with loading font from config + regression which makes SemiCondensed variant not available in TerminalDisplay.

To anyone who wants to test it:
If you dont see 'fixed' font, try enabling bitmap fonts:

mkdir -p ~/.config/fontconfig/conf.d
cat > ~/.config/fontconfig/conf.d/69-fixed-bitmaps.conf <<EOF
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <!-- Enabled Fixed bitmap fonts -->
  <selectfont>
    <acceptfont>
      <pattern>
        <patelt name="family">
          <string>Fixed</string>
        </patelt>
      </pattern>
    </acceptfont>
  </selectfont>
</fontconfig>
EOF
Comment 3 Jiri Slaby 2021-11-10 07:15:29 UTC
Still happens. For me on openSUSE with 21.08.2.
Comment 4 Jiri Slaby 2021-11-10 09:34:20 UTC
It's because QFont::fromString(const QString &descrip) doesn't OR the QFont::resolve_mask with QFont::StyleNameResolved the same as QFont::setStyleName(const QString &styleName) does. So this is an upstream (Qt) bug. Reproducer:
================
$ cat main.cpp
#include <QApplication>
#include <QDebug>
#include <QLabel>
#include <QDialog>

static void setLabelFont(QLabel &label, const QFont &font)
{
        qDebug() << __func__ << font <<
                    "style" << font.style() << "stylename" << font.styleName()
                 << "resolve" << QString::number(font.resolve(), 16);
        label.setFont(font);
        label.setText(font.toString());
}

int main(int argc, char *argv[])
{
        QApplication a(argc, argv);
        QDialog w;
        QLabel label1(&w), label2(&w);

        QFont font1;
        font1.fromString("Misc Fixed,10,-1,5,57,0,0,0,0,0,SemiCondensed");
        auto font2 = font1;
#if 1
        font2.resolve(font2.resolve() | QFont::ResolveProperties::StyleNameResolved);
#else
        font2.setStyleName("SemiCondensed");
#endif
        setLabelFont(label1, font1);
        setLabelFont(label2, font2);

        w.show();

        label2.move(0, label1.size().height() + 5);
        w.resize(label1.size().width(), label2.pos().y() + label2.size().height());

        return a.exec();
}
================
$ cat Makefile 
COMPONENTS=Qt5Core Qt5Gui Qt5Widgets
CXXFLAGS=$(shell pkg-config --cflags $(COMPONENTS)) -Wall -Og -g
LDLIBS=$(shell pkg-config --libs $(COMPONENTS)) -flto

all: main
================

Both labels are with the same font, the latter sets the resolve_mask and is shown correctly.
Comment 5 Jiri Slaby 2021-11-10 09:39:31 UTC
So this is already known:
https://bugreports.qt.io/browse/QTBUG-80952
Comment 6 Ahmad Samir 2021-11-10 17:48:32 UTC
I am not sure it's the same issue as that upstream bug; the code in Konsole sets the styleName to an empty string https://invent.kde.org/utilities/konsole/-/blob/master/src/terminalDisplay/TerminalFonts.cpp#L91:
    // "Draw intense colors in bold font" feature needs to use different font weights. StyleName
    // property, when set, doesn't allow weight changes. Since all properties (weight, stretch,
    // italic, etc) are stored in QFont independently, in almost all cases styleName is not needed.
Comment 7 Jiri Slaby 2021-11-11 05:47:21 UTC
Created attachment 143440 [details]
workaround patch

(In reply to Ahmad Samir from comment #6)
> I am not sure it's the same issue as that upstream bug; the code in Konsole
> sets the styleName to an empty string

Confirmed. The qt fix doesn't help (obviously; but is a bug too). Commenting out the line (patch attached) indeed helps.
Comment 8 Ahmad Samir 2021-11-11 07:25:29 UTC
Commenting out that line breaks the "draw intense colours in bold fonts" option, very tricky stuff :)
Comment 9 Ahmad Samir 2021-11-11 08:51:53 UTC
A side point, it looks like semicondensed monospace fonts are a rare thing, even Noto fonts, which have more weight/styles than any other font family I've ever seen, doesn't have a semicondensed monospace font.
Comment 10 Jiri Slaby 2021-11-11 10:07:32 UTC
(In reply to Ahmad Samir from comment #8)
> Commenting out that line breaks the "draw intense colours in bold fonts"
> option, very tricky stuff :)

Sure, that's why the patch is marked as a workaround, not a fix :).

(In reply to Ahmad Samir from comment #9)
> A side point, it looks like semicondensed monospace fonts are a rare thing,
> even Noto fonts, which have more weight/styles than any other font family
> I've ever seen, doesn't have a semicondensed monospace font.

Misc Fixed which I am using over a decade in xterm and which I wanted to teach konsole to use... One more thing: konsole picks /usr/share/fonts/misc/6x13-ISO8859-1.pcf.gz instead of /usr/share/fonts/misc/6x13.pcf.gz. I have to delete the former to have proper unicode support using the same font...
Comment 11 Ahmad Samir 2021-11-11 10:34:44 UTC
I see misc fixed, but it has a maximum size of 8pt, so I've never really used it.
Comment 12 Jiri Slaby 2021-11-15 07:04:48 UTC
(In reply to Jiri Slaby from comment #7)
> Confirmed. The qt fix doesn't help (obviously; but is a bug too). Commenting
> out the line (patch attached) indeed helps.

I actually need both changes in both libqt and konsole.