Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

Underscores not rendered in Monospace 11/12 font #2449

Closed
lathiat opened this issue Apr 8, 2020 · 24 comments · Fixed by #2500
Closed

Underscores not rendered in Monospace 11/12 font #2449

lathiat opened this issue Apr 8, 2020 · 24 comments · Fixed by #2500
Labels

Comments

@lathiat
Copy link

lathiat commented Apr 8, 2020

I am finding that underscores don't render, appearing as spaces, when using the default Monospace 11 or Monospace 12 font on Ubuntu 20.04 (Focal, development beta, but due to be released this month). This occurs in both the package of 2.14.3-3 and the current master branch as of today.

Increasing to Monospace 13 causes them to appear and they work in some other fonts at various sizes. I suspect most likely that the calculated bounding box for the row is being incorrectly calculated somehow to be too short.

I imagine most likely this is either in xtext or an interaction with one of it's rendering dependencies but I'm not really sure where to start on debugging it. I'm happy to do any testing or even work towards solving it but somewhere to start would be great!

@TingPing
Copy link
Member

TingPing commented Apr 9, 2020

Monospace is not a font. I believe fc-match Monospace will tell the actual font.

Anyway I think this is a font problem. xtext queries the line height from the font.

@konomikitten
Copy link

konomikitten commented Apr 13, 2020

While I don't know what font the reporter is using I can confirm that I am seeing this in hexchat v2.14.3 also with the following font. Oh I forgot to mention changing fonts does make this issue go away. But the issue isn't present in my terminal emulator when using the same font settings.

$ fc-match monospace
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"

Screenshots:

Hexchat (DejaVu Sans Mono 9)
hexchat

Hexchat (IBM Plex Mono weight=453 9)
hexchat imb plex

Kitty Terminal and Weechat (DejaVu Sans Mono 9)
screenshot

Kitty Terminal and Weechat (IBM Plex Mono Medium 10)
kitty weechat

@jpiszcz
Copy link

jpiszcz commented Apr 13, 2020

The 'g' is also particularly impacted:
Capture

DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"

This change appeared to occur in the past ~14 days.. (running Debian testing)

@TingPing
Copy link
Member

@jpiszcz Could you find out if the pango package has updated recently and test older versions of it?

@jpiszcz
Copy link

jpiszcz commented Apr 14, 2020

That was it! Everything is rendering perfectly once again!

The workaround is to downgrade these packages to the following versions:
dpkg -i libpango-1.0-0_1.42.4-7~deb10u1_amd64.deb libpangoxft-1.0-0_1.42.4-7~deb10u1_amd64.deb libpangocairo-1.0-0_1.42.4-7~deb10u1_amd64.deb libpangoxft-1.0-0_1.42.4-7~deb10u1_amd64.deb gir1.2-pango-1.0_1.42.4-7~deb10u1_amd64.deb libpangoft2-1.0-0_1.42.4-7~deb10u1_amd64.deb

I found the old versions here:
http://http.us.debian.org/debian/pool/main/p/pango1.0/

fix

@TingPing
Copy link
Member

So ideally somebody could bisect the code to see what caused the regression. But I guess you can just open an issue against Pango with the exact version where the line height of a font no longer seems accurate (this isn't exactly verified to be the exact problem).

@jpiszcz
Copy link

jpiszcz commented Apr 14, 2020

Someone also submitted a Debian bug report:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=956633

Will submit these two links to the pango issues section.
https://gitlab.gnome.org/GNOME/pango/-/issues/471

@s7sost
Copy link

s7sost commented Apr 25, 2020

I tried downgrading by following the instructions posted above (since my issue was exactly as reported in this thread), but then I encountered the following issues:

dpkg: error processing package libpango-1.0-0:amd64 (--install):
 package libpango-1.0-0:amd64 1.42.4-7~deb10u1 cannot be configured because libpango-1.0-0:i386 is at a different version (1.44.7-2ubuntu4)
dpkg: dependency problems prevent configuration of libpangoxft-1.0-0:amd64:
 libpangoxft-1.0-0:amd64 depends on libpango-1.0-0 (>= 1.22.0); however:
  Package libpango-1.0-0:amd64 is not configured yet.
 libpango-1.0-0:i386 (1.44.7-2ubuntu4) breaks libpangoxft-1.0-0 (<< 1.44.7) and is broken due to postinst failure.
  Version of libpangoxft-1.0-0:amd64 to be configured is 1.42.4-7~deb10u1.

dpkg: error processing package libpangoxft-1.0-0:amd64 (--install):
 dependency problems - leaving unconfigured
dpkg: error processing package libpangocairo-1.0-0:amd64 (--install):
 package libpangocairo-1.0-0:amd64 1.42.4-7~deb10u1 cannot be configured because libpangocairo-1.0-0:i386 is at a different version (1.44.7-2ubuntu4)
dpkg: dependency problems prevent configuration of gir1.2-pango-1.0:amd64:
 gir1.2-pango-1.0:amd64 depends on libpango-1.0-0 (>= 1.42.0); however:
  Package libpango-1.0-0:amd64 is not configured yet.
 gir1.2-pango-1.0:amd64 depends on libpangocairo-1.0-0 (>= 1.22.0); however:
  Package libpangocairo-1.0-0:amd64 is not configured yet.
 gir1.2-pango-1.0:amd64 depends on libpangoxft-1.0-0 (>= 1.14.0); however:
  Package libpangoxft-1.0-0:amd64 is not configured yet.

dpkg: error processing package gir1.2-pango-1.0:amd64 (--install):
 dependency problems - leaving unconfigured
dpkg: error processing package libpangoft2-1.0-0:amd64 (--install):
 package libpangoft2-1.0-0:amd64 1.42.4-7~deb10u1 cannot be configured because libpangoft2-1.0-0:i386 is at a different version (1.44.7-2ubuntu4)
Processing triggers for libc-bin (2.31-0ubuntu9) ...
Errors were encountered while processing:
 libpango-1.0-0:amd64
 libpangoxft-1.0-0:amd64
 libpangocairo-1.0-0:amd64
 gir1.2-pango-1.0:amd64
 libpangoft2-1.0-0:amd64

On top of that, when trying to do apt-get install -f or apt --fix-broken install, it refuses to reinstall the previous (updated) versions to revert the process. This is just one of the many issues I've had since upgrading to Ubuntu 20.04, but at least this one seems to have a clear (albeit unsuccessful for me) solution.

Edit: This also broke my packages altogether, so I cannot upgrade or do anything with it, nor purge them. Here's the output of apt-get install -f:

The following additional packages will be installed:
  libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0
The following packages will be upgraded:
  libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0
3 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
9 not fully installed or removed.
Need to get 0 B/222 kB of archives.
After this operation, 5,120 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 347461 files and directories currently installed.)
Preparing to unpack .../libpangocairo-1.0-0_1.44.7-2ubuntu4_amd64.deb ...
Unpacking libpangocairo-1.0-0:amd64 (1.44.7-2ubuntu4) over (1.42.4-7~deb10u1
) ...
dpkg: error processing archive /var/cache/apt/archives/libpangocairo-1.0-0_1
.44.7-2ubuntu4_amd64.deb (--unpack):
 trying to overwrite shared '/usr/share/doc/libpangocairo-1.0-0/copyright', 
which is different from other instances of package libpangocairo-1.0-0:amd64
Preparing to unpack .../libpangoft2-1.0-0_1.44.7-2ubuntu4_amd64.deb ...
Unpacking libpangoft2-1.0-0:amd64 (1.44.7-2ubuntu4) over (1.42.4-7~deb10u1) 
...
dpkg: error processing archive /var/cache/apt/archives/libpangoft2-1.0-0_1.4
4.7-2ubuntu4_amd64.deb (--unpack):
 trying to overwrite shared '/usr/share/doc/libpangoft2-1.0-0/copyright', wh
ich is different from other instances of package libpangoft2-1.0-0:amd64
Preparing to unpack .../libpango-1.0-0_1.44.7-2ubuntu4_amd64.deb ...
Unpacking libpango-1.0-0:amd64 (1.44.7-2ubuntu4) over (1.42.4-7~deb10u1) ...
dpkg: error processing archive /var/cache/apt/archives/libpango-1.0-0_1.44.7
-2ubuntu4_amd64.deb (--unpack):
 trying to overwrite shared '/usr/share/doc/libpango-1.0-0/NEWS.gz', which i
s different from other instances of package libpango-1.0-0:amd64
Errors were encountered while processing:
 /var/cache/apt/archives/libpangocairo-1.0-0_1.44.7-2ubuntu4_amd64.deb
 /var/cache/apt/archives/libpangoft2-1.0-0_1.44.7-2ubuntu4_amd64.deb
 /var/cache/apt/archives/libpango-1.0-0_1.44.7-2ubuntu4_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

@jpiszcz
Copy link

jpiszcz commented Apr 25, 2020

Ubuntu 20.04

The instructions were for Debian Testing (x86_64) arch, for Ubuntu or other distributions you will need to determine how to downgrade and then once done make sure you pin the packages so they don't break again.

system:/etc/apt# cat preferences
# pin packages here

# 2020-04-14 pin pango related packages otherwise the fonts look bad
Package: libpango*
Pin: release a=testing
Pin-Priority: -1

# 2020-04-14 pin pango related packages otherwise the fonts look bad
Package: gir1.2*
Pin: release a=testing
Pin-Priority: -1

@jacob1
Copy link
Contributor

jacob1 commented May 2, 2020

Also getting the same issue (Debian testing), downgrading pango fixed it.

@s7sost Looks like you have i386 packages, so you'll also need to download and install the downgraded versions of those too.
Also, to fix --fix-broken, I had to remove all the files it complains about:
sudo rm /usr/share/doc/libpangocairo-1.0-0/copyright /usr/share/doc/libpango-1.0-0/copyright /usr/share/doc/libpango-1.0-0/changelog.Debian.gz /usr/share/doc/libpangoft2-1.0-0/copyright /usr/share/doc/libpangocairo-1.0-0/changelog.Debian.gz /usr/share/doc/libpango-1.0-0/NEWS.gz /usr/share/doc/libpangoft2-1.0-0/changelog.Debian.gz

Then --fix-broken will start working again.

@edgan
Copy link

edgan commented May 6, 2020

I had the same problem on Fedora 31 and now on Fedora 32.
The workaround for me was:
rpm -U --oldpackage pango-1.43.0-4.fc31.x86_64.rpm

Works:
pango-1.43.0-4.fc31

Broken:
pango-1.44.4-1.fc31
pango-1.44.7-2.fc32
pango-1.45.2-2.fc33

@ibahnasy

This comment has been minimized.

@Deek
Copy link

Deek commented Jul 31, 2020

Pango added the use of typographic metrics (sTypo*) and a line height attribute around then. It's possible that was the start of the problem. Locally, I "fixed" it (may not be a correct fix) by doing this:

--- src/fe-gtk/xtext.c
+++ src/fe-gtk/xtext.c
@@ -283,6 +283,7 @@ backend_font_open (GtkXText *xtext, char
 	metrics = pango_context_get_metrics (context, xtext->font->font, lang);
 	xtext->font->ascent = pango_font_metrics_get_ascent (metrics) / PANGO_SCALE;
 	xtext->font->descent = pango_font_metrics_get_descent (metrics) / PANGO_SCALE;
+	xtext->fontsize = pango_font_metrics_get_height (metrics) / PANGO_SCALE + 1;
 	pango_font_metrics_unref (metrics);
 }
 static int
@@ -3479,7 +3480,7 @@ gtk_xtext_set_font (GtkXText *xtext, cha
 	if (xtext->font == NULL)
 		return FALSE;
 
-	xtext->fontsize = xtext->font->ascent + xtext->font->descent;
+//	xtext->fontsize = xtext->font->ascent + xtext->font->descent;
 
 	{
 		char *time_str;

@TingPing
Copy link
Member

@Deek It doesn't look crazy. Could you open a PR for that and I'll ask some Pango folks to review it.

@TingPing
Copy link
Member

TingPing commented Jul 31, 2020

Ok so that is new in 1.44, put it in an #if PANGO_VERSION_CHECK(1, 44, 0)

@jlevon
Copy link
Contributor

jlevon commented Sep 3, 2020

Some more detail here: https://gitlab.gnome.org/GNOME/pango/-/issues/392

@Deek if you don't want to open a PR for this, maybe I could take a look if your fix still works?

jlevon added a commit to jlevon/hexchat that referenced this issue Sep 3, 2020
With newer versions of Pango and some fonts, the bottom of the
text is clipped (making underscores invisible). Use the correct
calculation when needed to avoid this.

Based on an original fix by Jeff Teunissen.

Closes hexchat#2449.
@Deek
Copy link

Deek commented Sep 3, 2020

The fix does still work; it could well be a bug in Pango itself causing it (that +1 I had to put in is suggestive), but it does seem to result in text that doesn't get cut off.

@jlevon
Copy link
Contributor

jlevon commented Sep 4, 2020

@Deek do you really need the +1 ? I tested both with and without, and the fix is sufficient for me to see underscores again. But I slightly prefer the additional pixel space.

@Deek
Copy link

Deek commented Sep 4, 2020

I seem to recall not adding the 1 did partially restore most underscores, but that they were still cut off a bit; adding the +1 seemed to make hexchat look just like it did before the Pango change.

@nerozero
Copy link

The issue is still present for me....

@jarnos
Copy link

jarnos commented May 9, 2021

@mapreri
Copy link
Contributor

mapreri commented Oct 4, 2021

If somebody here runs Ubuntu 20.04 focal and is affected by this bug, I've proposed a patch on https://bugs.launchpad.net/hexchat-irc/+bug/1920974 msg#4 ; I need somebody to fill in the "test plan" (i.e. how to reproduce the bug) and try out my proposed package, after which if the bug is confirmed fixed I can upload it to the main archive.

TIA!

@mapreri
Copy link
Contributor

mapreri commented Oct 4, 2021

Also sorry it took me so long to fix it on focal, it totally slipped my mind to check it there when I fixed it for Debian…

@mapreri
Copy link
Contributor

mapreri commented Oct 27, 2021

FYI, the fix has just been fully released to focal-updates, so Ubuntu 20.04 users running hexchat as present in the Ubuntu repository will now get the fix.

joebonrichie pushed a commit to solus-packages/hexchat that referenced this issue Aug 14, 2023
Summary:
- Added "Use pango_font_metrics_get_height() to calculate font height" patch. [Upstream bug](hexchat/hexchat#2449).

I did notice an improvement in font rendering with this patch applied while testing the now abandoned D10958, so I think it's deserving of being fixed. Notably chat seems less "smooshed" with a more natural spacing between lines.

Test Plan:
- Tested that Hexchat opened
- Checked that IRC was working
- Checked that font appeared to be rendering acceptably

Reviewers: #triage_team, JoshStrobl

Reviewed By: #triage_team, JoshStrobl

Subscribers: JoshStrobl, TClark77

Differential Revision: https://dev.getsol.us/D10963
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.