-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
[Bug]: A certain post makes the post width too big, causing posts to be cut off #1219
Comments
Thanks for the report! Unfortunately, it's a gtklabel/pango issue and any workarounds I do from my side end up breaking other things (#914 and many others). This has been reported upstream and Sergey has been working on fixing it (and uses Tuba as a test case), so it will be fixed sooner than later, but it's out of my control :( cc: @bugaevc if you need another overflowing/unwrappable post, it's this reply: https://tech.lgbt/@banaanihillo/113543742941157854 |
Hmm that's interesting, there's only a single emoji AFAICS, so it can't be that thing. I'll look into it, but if you have time before I do please check whether gtk!7936 helps with that too. |
I've narrowed it down before to the existence of pango attributes (LWW's Without your gtk patch -- with shape allocation
Without your gtk patch -- without shape allocation
With your gtk patch -- with shape allocation -- with fix-overflow-hack
With your gtk patch -- with shape allocation -- without fix-overflow-hack
The only cases that wrapped correctly are the second and fourth. Second did not have any emojis. |
Even without your patch, fix-overflow-hack seems to be the cause. I wonder if we should detect |
Try this: diff --git a/src/Widgets/LabelWithWidgets.vala b/src/Widgets/LabelWithWidgets.vala
index 25aff282..7a891f07 100644
--- a/src/Widgets/LabelWithWidgets.vala
+++ b/src/Widgets/LabelWithWidgets.vala
@@ -98,6 +98,10 @@ public class Tuba.Widgets.LabelWithWidgets : Gtk.Widget, Gtk.Buildable, Gtk.Acce
return;
}
+ unowned var layout = label.get_layout ();
+ unowned var context = layout.get_context ();
+ var metrics = context.get_metrics (null, null);
+
for (var i = 0; i < widgets.length; i++) {
Gtk.Requisition size;
Gtk.Requisition natural_size;
@@ -136,9 +140,9 @@ public class Tuba.Widgets.LabelWithWidgets : Gtk.Widget, Gtk.Buildable, Gtk.Acce
var logical_rect = Pango.Rectangle () {
x = 0,
- y = - (widgets[i].height - (widgets[i].height / 4)) * Pango.SCALE,
+ y = - metrics.get_ascent (),
width = widgets[i].width * Pango.SCALE,
- height = widgets[i].height * Pango.SCALE
+ height = metrics.get_ascent () + metrics.get_descent ()
};
var shape = Pango.AttrShape.new (logical_rect, logical_rect);
@@ -179,16 +183,16 @@ public class Tuba.Widgets.LabelWithWidgets : Gtk.Widget, Gtk.Buildable, Gtk.Acce
// int orig_y = logical_rect.y;
logical_rect.x = pango_pixels (logical_rect.x);
logical_rect.y = pango_pixels (logical_rect.y);
- // logical_rect.width = pango_pixels (orig_x + logical_rect.width, 1024) - logical_rect.x;
- // logical_rect.height = pango_pixels (orig_y + logical_rect.height, 1024) - logical_rect.y;
+ logical_rect.width = pango_pixels (logical_rect.width);
+ logical_rect.height = pango_pixels (logical_rect.height);
int offset_x;
int offset_y;
label.get_layout_offsets (out offset_x, out offset_y);
var allocation = Gtk.Allocation () {
- x = logical_rect.x + offset_x,
- y = logical_rect.y + offset_y,
+ x = logical_rect.x + offset_x - (widgets[i].width - logical_rect.width) / 2,
+ y = logical_rect.y + offset_y - (widgets[i].height - logical_rect.height) / 2,
height = widgets[i].height,
width = widgets[i].width
}; |
I don't have a stable connection rn but from what I managed to test, it still overflows. The rectangle also has similar-ish dimensions: |
(btw, instead of |
Describe the bug
Post(s?) are wider than the window causing the posts to be cut off.
Steps To Reproduce
Open this post in Tuba.
Logs and/or Screenshots
Instance Backend
GoToSocial
Operating System
Fedora Workstation 41
Package
Flatpak
Troubleshooting information
os: GNOME 46 (Flatpak runtime)
prefix: /app
flatpak: true
version: 0.8.4 (production)
gtk: 4.14.5 (4.14.4)
libadwaita: 1.5.5 (1.5.3)
libsoup: 3.4.4 (3.4.4)
libgtksourceview: 5.12.1 (5.12.1)
Additional Context
No response
The text was updated successfully, but these errors were encountered: