Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pango 1.50.0 breaks spacing #1367

Closed
marzzzello opened this issue Dec 6, 2021 · 15 comments
Closed

pango 1.50.0 breaks spacing #1367

marzzzello opened this issue Dec 6, 2021 · 15 comments

Comments

@marzzzello
Copy link
Contributor

marzzzello commented Dec 6, 2021

OS: Arch Linux

pango 1.48.10-1:
pango 1 48 10-1

pango 1.50.0-2
pango 1 50 0-2

Changelog: https://gitlab.gnome.org/GNOME/pango/-/blob/main/NEWS

@IndependentFool
Copy link

I would like to add to this as well. Same issue. Nonetheless, downgrading to pango 1.48 fixed it for me.

OS: Arch
i3status-rust: Latest version 0.20.7-1

pango 1.48.10
pango-1-48-10

pango 1.50.0
pango-1-50

@cfsmp3
Copy link
Contributor

cfsmp3 commented Dec 7, 2021

On first inspection it seems more likely to be an issue with pango (or maybe, i3) than with i3status-rs - the only thing it does about pango is escape some characters.

BTW some other totally unrelated project is complaining

https://bugs.archlinux.org/task/72939

@ammgws
Copy link
Collaborator

ammgws commented Dec 7, 2021

@ammgws ammgws closed this as completed Dec 7, 2021
@marzzzello
Copy link
Contributor Author

I guess this is the fix: https://gitlab.gnome.org/GNOME/pango/-/commit/8b46f5db285c6c661a2a7c28c5b354426a8d5c61

pango 1.50.0-3 which includes these commits doesn't fix it for me.

@ammgws ammgws reopened this Dec 7, 2021
@epixinvites
Copy link

image
i3status-rs 0.20.8 (commit 64fcdeb 2021-12-03) along with pango 1:1.50.0-3

@ghost
Copy link

ghost commented Dec 8, 2021

otf-font-awesome works for me but not ttf-font-awesome. The otf is a bit larger in size though.

@ammgws
Copy link
Collaborator

ammgws commented Dec 8, 2021

Is this happening on both sway and i3? I haven't looked too deeply but was surprised not to find other status bars/etc also complaining about this. All we do is generate JSON which is parsed by swaybar/i3bar which are what actually renders the text.

Perhaps try running a small program like this against the "good" and "bad" versions of pango and see what results you get?

Or otherwise run a git bisect on pango while testing the bar each time to find the commit that changed the behaviour.

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <stdio.h>
#include <cairo.h>
#include <pango/pangocairo.h>

int main (int argc, char **argv)
{
  if (argc != 3)
  {
     return 1;
  }
  char *text = argv[1];
  char *font = argv[2];
  cairo_surface_t *target = cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, NULL);
  cairo_t *cairo = cairo_create (target);
  PangoLayout *layout = pango_cairo_create_layout(cairo);
  PangoFontDescription *desc = pango_font_description_from_string(font);
  pango_layout_set_font_description(layout, desc);
  pango_layout_set_text(layout, text, -1);
  int text_width, text_height;
  pango_cairo_update_layout(cairo, layout);
  pango_layout_get_pixel_size(layout, &text_width, &text_height);
  char *pango_font_used = pango_font_description_to_string(desc);
  printf("Width of '%s' is %d\nUsing font: %s", text, text_width, pango_font_used);
}

EDIT: found at least one other bar with the same issue: Alexays/Waybar#1343

@ammgws
Copy link
Collaborator

ammgws commented Dec 12, 2021

You can use pango-view to test this as well, try playing around with it: pango-view --text "stuff here" --font FontAwesome

@codicodi
Copy link
Contributor

codicodi commented Dec 16, 2021

I've reported this upstream [1]. If someone has some more insight that might help pango developers understand the issue, please share.

[1] https://gitlab.gnome.org/GNOME/pango/-/issues/641

@ammgws
Copy link
Collaborator

ammgws commented Dec 17, 2021

Thanks for reporting it. Looks like it should be fixed now: https://gitlab.gnome.org/GNOME/pango/-/commit/37f22bb80ebacd834f1927e6acd7fd94aeaf1270

@ammgws ammgws closed this as completed Dec 17, 2021
@c02y
Copy link

c02y commented Dec 17, 2021

@ammgws
It seems more spacing is added comparing to the original version.
v1.48.9: 1 space
image

v1.50.1: no space
image

v1.50.2: 1.5 or 2 spaces
image

@ammgws ammgws reopened this Dec 18, 2021
@matthiasclasen
Copy link

matthiasclasen commented Dec 18, 2021

pango perspective here:

If you want control over the amount of space, use a font that has a space glyph.

All of these icon fonts are weird and deficient in various ways, and forcing a text layout system like pango to deal with them is only ever going to yield suboptimal results. Pango makes various assumptions about fonts which are quite reasonable for
text fonts, such as: the font shall have a space glyph, or at least it shall have hex digits so we can devise some reasonable
width for space by measuring those. These icon fonts I've been dealing with in the last few days don't.

@c02y
Copy link

c02y commented Dec 22, 2021

@ammgws It seems more spacing is added comparing to the original version. v1.48.9: 1 space
image

v1.50.1: no space
image

v1.50.2: 1.5 or 2 spaces image

Just update it to pango v1.50.3 (I'm using Archlinux), it seems good to me. 😃

image

@ammgws
Copy link
Collaborator

ammgws commented Dec 22, 2021

Thanks for the update, looks like it was this: https://gitlab.gnome.org/GNOME/pango/-/commit/9fe2853692bb64ded58a507d87508dc8536cd386 that fixed it. And thanks to Matthias for the persistent effort!

@marzzzello
Copy link
Contributor Author

yes, 1.50.3 fixed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants