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 452361 - set_width() and set_ellipsize() misbehaving with very large lines
set_width() and set_ellipsize() misbehaving with very large lines
Status: RESOLVED OBSOLETE
Product: pango
Classification: Platform
Component: general
1.16.x
Other All
: Normal normal
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2007-06-29 20:28 UTC by Guillaume Chazarain
Modified: 2018-05-22 12:29 UTC
See Also:
GNOME target: ---
GNOME version: 2.17/2.18


Attachments
Screenshot with SIZE = 1000 => OK (14.17 KB, image/png)
2007-06-29 20:32 UTC, Guillaume Chazarain
  Details
Screenshot with SIZE = 20000 => BAD (17.57 KB, image/png)
2007-06-29 20:34 UTC, Guillaume Chazarain
  Details
working patch (8.17 KB, patch)
2007-12-11 18:50 UTC, Behdad Esfahbod
needs-work Details | Review

Description Guillaume Chazarain 2007-06-29 20:28:16 UTC
Please describe the problem:
I display a large amount of text in a restricted space, so I use set_width() and set_ellipsize() to let pango cut the text. It works fine, except when the line is very large, then the text escapes its boundaries.

Steps to reproduce:
Here is a minimal testcase in pygtk:

import gtk
import pango
from random import random
import cairo

#SIZE = 1000 # Good
SIZE = 15000 # Bad

class Widget(gtk.DrawingArea):
    def __init__(self):
        gtk.DrawingArea.__init__(self)
        self.connect('expose-event', type(self).expose_event)
        self.modify_font(pango.FontDescription('Monospace 24'))

    def expose_event(self, event):
        context = self.window.cairo_create()
        text = '<' + str(random()) * SIZE + '>'
        pl = self.create_pango_layout(text)
        pl.set_width(int(self.allocation.width * pango.SCALE))
        pl.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
        context.set_source_rgb(random(), random(), random())
        context.show_layout(pl)
        return False

win = gtk.Window()
box =  gtk.HBox()
for i in xrange(4):
    box.add(Widget())
win.add(box)
win.show_all()
gtk.main()


Actual results:
With, the SIZE set to 1000, it works fine. Resizing the window show the ellipsize effect. With SIZE set to 15000, the display is garbled. By the way, in both cases, the speed is quite slow. It is expected, because of the size of the buffer, but I wouldn't mind if it was faster ;-)

Expected results:
With SIZE set to 15000, the display should be similar to the one with SIZE set to 1000.

Does this happen every time?
Yes.

Other information:
Comment 1 Guillaume Chazarain 2007-06-29 20:32:35 UTC
Created attachment 90902 [details]
Screenshot with SIZE = 1000 => OK
Comment 2 Guillaume Chazarain 2007-06-29 20:34:43 UTC
Created attachment 90903 [details]
Screenshot with SIZE = 20000 => BAD

Actually, with SIZE = 20000 instead of 15000, not only the text is not between '<' and '>' it superposes with garbage.
Comment 3 Behdad Esfahbod 2007-06-29 20:43:08 UTC
Thanks, I can reproduce it here.  Will look into it.
Comment 4 Behdad Esfahbod 2007-12-11 18:50:31 UTC
Created attachment 100776 [details] [review]
working patch

Worked on this a bit last night.  Patch doesn't fix it yet, it's obviously just the start...
Comment 5 GNOME Infrastructure Team 2018-05-22 12:29:57 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pango/issues/81.