After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 322042 - Buggy RTL support in ellipsized gtklabel labels
Buggy RTL support in ellipsized gtklabel labels
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.8.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: Persian
 
 
Reported: 2005-11-21 15:58 UTC by Farzaneh Sarafraz
Modified: 2011-02-04 16:10 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12


Attachments
Sample code to demonstrate the bug (760 bytes, text/plain)
2005-11-21 15:59 UTC, Farzaneh Sarafraz
  Details
A shorter sample, using gtk_label_set_ellipsize (647 bytes, text/plain)
2006-01-23 18:36 UTC, Hooman "Messi" Mesgary
  Details
Fix. (912 bytes, patch)
2006-01-23 19:59 UTC, Behdad Esfahbod
committed Details | Review

Description Farzaneh Sarafraz 2005-11-21 15:58:10 UTC
Distribution/Version: fedora core 4

Run the sample code. Once in an RTL locale (e.g. fa_IR) and then in an LTR
locale (say en_US).
The text in the statusbar is not shown in the RTL mode.
Comment 1 Farzaneh Sarafraz 2005-11-21 15:59:49 UTC
Created attachment 55027 [details]
Sample code to demonstrate the bug
Comment 2 Felix Riemann 2006-01-14 15:26:16 UTC
The text does show up, but only if reduce the window width to about 100.

This seems to be the same problem as in bug #169390.
Comment 3 Farzaneh Sarafraz 2006-01-15 18:31:43 UTC
Although the last comment in bug #169390 seems to describe *this* bug, these two bugs don't seem to refer to the same problem. At least not quite directly.
Comment 4 Hooman "Messi" Mesgary 2006-01-23 18:36:57 UTC
Created attachment 57958 [details]
A shorter sample, using gtk_label_set_ellipsize

This is a shorter sample code to reproduce the bug.
If you set the size to (100, 100) you can see the label, but resizing the window results label going out of area.
Comment 5 Behdad Esfahbod 2006-01-23 18:59:42 UTC
Ok, seems like regardless of locale, gtklabels are misaligned if and only if they contain rtl text and ellipsize is set (to whatever START/MIDDLE/END.)

It looks like a +/- issue somewhere, or double charging the X offset...
Comment 6 Behdad Esfahbod 2006-01-23 19:59:36 UTC
Created attachment 57961 [details] [review]
Fix.

2006-01-23  Behdad Esfahbod  <behdad@gnome.org>

        * gtk/gtklabel.c (get_layout_location): Fix misalignment of RTL
        text in ellipsized GtkLabel: use layout width if set, otherwise
        fallback to ink extents width. (#322042)
Comment 7 Behdad Esfahbod 2006-01-27 19:16:27 UTC
Committed to gtk-2-8 branch too.  Should be in 2.8.12
Comment 8 Kristian Rietveld 2006-05-30 16:25:08 UTC
Reopening, since the patch does not work for all cases and breaks aligning ellipsized labels (see #332604).

For ellipsized labels the width of the layout is set to the allocation.width of the label.  The alignment/position of the layout in the label is calculated incorrectly, since this width value is being used where we actually need the width of the ink rect (which happened previously and works fine for LTR).  Note that the width of the layout still equals the allocated width of the widget and drawing the layout with an xlign of 1.0 goes fine, since we just move the layout to the right.

However this goes wrong for RTL text, since the text is drawn at the right side of the layout.  If we move the layout to the right, the text is drawn outside the area of the label.  A way of fixing this would be to move the layout to the left instead of to the right in this case.

To get this right, we'll have to figure out which direction the text in the layout uses.  Some questions:
  - Would this be the right approach?
  - What's the best way to figure out the direction of the text in the layout?
  - What would be the right behaviour if there's text with different directions in the layout?
Comment 9 Behdad Esfahbod 2006-06-12 06:21:44 UTC
Ok, in fact shortly after committing this patch I gave the problem more thought (in the context of bug 328456).  The fix is really simple, though I've not tested yet.  When we get the ink rect, we've got to further offset the layout by (-rect.x, -rect.y).  That's really all.

There's one catch to this though, if the layout contains both RTL and LTR text (and autodir is on, which is the default), we don't get centered text, instead RTL text is aligned to right, LTR to left.  This is because ink-rect is now returning full width.  This only happens with multi-paragraph labels, which should be easy to ignore?
Comment 10 Matthias Clasen 2006-12-30 04:12:08 UTC
Behdad, any update on this ?
Comment 11 Behdad Esfahbod 2007-01-04 06:09:11 UTC
From my testing, with the patch in 332604 committed now, this bug can be closed.