GNOME Bugzilla – Bug 355782
Misaligned extents in pango
Last modified: 2006-10-04 22:38:52 UTC
Please describe the problem: I wrote a test program that goes through each combination of logical/ink, line/cluster/run/char, and left/center/right alignment. Several of the combinations have misaligned extents, atleast for some lines: 3: left cluster logical. First line is misaligned. 4: left cluster ink. First line is misaligned. 10: center line ink. All lines are misaligned. 11: center cluster logical. First align is misaligned. 12: center cluster ink. First line is misaligned. 18: right link ink. All lines are misaligned. I will attach the test program (which uses pygtk). Note that it demonstrates two other bugs (trailing whitespace, char crashes). I will file reports for them separately. Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
Created attachment 72701 [details] Test program
Forgot to mention, when you run the test program, hit space to see the next combination.
Very interesting test program. Thanks! I'll look into fixing all the problems. Not sure how to handle the trailing space problem. I'll look into what gtk+ is currently doing. Would you mind attaching a copyright header to your example? I think it's a great candidate to be distrubuted by pygtk...
Isn't there a bug already open about this? I think my conclusion last time I looked at this was that whitespace at the ends of a line should not contribute to line width except at the beginning and end of a paragraph. (Actually, last time my conclusion was "whitespace at the end of a line should not affect line width" but that didn't quite work out without exceptions for cursor positioning, and is otherwise inferior to the above.) (I haven't though through the above formulation for mixed bidi. I suspect it mostly works fine, but there might be corner cases.)
(In reply to comment #4) > Isn't there a bug already open about this? Can't find it other than the newly reported bug 355789. > I think my conclusion last time > I looked at this was that whitespace at the ends of a line should not > contribute to line width except at the beginning and end of a paragraph. I also think tab characters at the end of line shouldn't be removed, but that probably doesn't matter much. > (Actually, last time my conclusion was "whitespace at the end of a line should > not affect line width" but that didn't quite work out without exceptions for > cursor positioning, and is otherwise inferior to the above.) I don't quite get it. With above, still we need to handle cursor positioning at the end of lines with multiple whitespace. > (I haven't though through the above formulation for mixed bidi. I suspect it > mostly works fine, but there might be corner cases.) Agreed.
> Can't find it other than the newly reported bug 355789 Hmm, I see: http://bugzilla.gnome.org/show_bug.cgi?id=152144 (GtkTextView) But I was pretty sure there was more extensive discussion somewhere. Might have a less obvious Subject, perhaps. > I don't quite get it. With above, still we need to handle cursor positioning > at the end of lines with multiple whitespace. How should Foo Bar Look when word-wrapped and right aligned. | Foo| | Bar| Makes at least as much sense to me as: |Foo | | Bar| Or something.
Owen, agreed. As for the cluster bug, found it: @@ -4654,7 +4654,7 @@ pango_layout_iter_copy (PangoLayoutIter new->ltr = iter->ltr; new->cluster_x = iter->cluster_x; - new->cluster_width = iter->cluster_x; + new->cluster_width = iter->cluster_width; new->cluster_start = iter->cluster_start; new->next_cluster_glyph = iter->next_cluster_glyph; It's only showing up with python because python's assignment is creating a copy of the iterator. That also fixes the crash in get_char_extents.
2006-09-13 Behdad Esfahbod <behdad@gnome.org> Part of Bug 355782 – Misaligned extents in pango * pango/pango-layout.c (cluster_width): Rewrite based on is_cluster_start instead of accessing log_clusters directly. This is more robust as next_cluster uses that, so the two match now. * pango/pango-layout.c (update_cluster): Remove the cluster_start_index parameter and use iter->cluster_start instead. * pango/pango-layout.c (pango_layout_iter_copy): Fix typo in copying iter->cluster_width. * pango/pango-layout.c (pango_layout_iter_get_cluster_extents): Add an assert to make sure iter->cluster_width is correctly set. * pango/pango-layout.c (pango_layout_iter_get_char_extents): Remove assert that was readded above to check more cases.
2006-09-13 Behdad Esfahbod <behdad@gnome.org> "Thou shalt not touch code that does not fit in thy brain." * pango/pango-layout.c (update_cluster): Add cluster_start_index parameter back in.
2006-09-13 Behdad Esfahbod <behdad@gnome.org> Part of Bug 355782 – Misaligned extents in pango * pango/pango-layout.c (pango_layout_get_extents_internal), (pango_layout_get_extents), (pango_layout_iter_copy), (pango_layout_get_iter), (pango_layout_iter_get_line_extents): Add a new internal member layout_width to PangoLayoutIter. Set it up in pango_layout_get_extents_internal and use in pango_layout_iter_get_line_extents to fix misalignment of ink link extents.
Created attachment 72730 [details] more updated test case
I'd love to see it included in the pygtk examples. Better yet would be modifying it to save PNGs and include those on the website. Just let me know what kind of licensing blurb you want. You could make it easy on me and give me something that I can copy and paste in. ;)
I attached the test program to Bug 347009 – Improve docs about ink and logical extents. Lets continue there.
Created attachment 74020 [details] Example of trailing whitespace bug post-1.14.5 After reading the traffic on this bug, I'm not sure whether the resolution is meant to imply that the trailing whitespace (on center- and right-aligned mode) problem has been solved or simply deferred. This test program (written in GtkMM; I can port that to C if anybody objects to the C++) shows that as of Pango 1.14.5, which contains the patches referenced in Behdad's comments above, the trailing whitespace is still allocated. At Damon's request, I'm opening this bug again.
(In reply to comment #14) > Created an attachment (id=74020) [edit] > Example of trailing whitespace bug post-1.14.5 > > After reading the traffic on this bug, I'm not sure whether the resolution is > meant to imply that the trailing whitespace (on center- and right-aligned mode) > problem has been solved or simply deferred. No, that particular problem is not solved. But that has its own bug number: Bug 355789 > This test program (written in GtkMM; I can port that to C if anybody objects to > the C++) shows that as of Pango 1.14.5, which contains the patches referenced > in Behdad's comments above, the trailing whitespace is still allocated. At > Damon's request, I'm opening this bug again. Please don't. This bug was about something else that is fixed already.
(In reply to comment #15) > (In reply to comment #14) > > Created an attachment (id=74020) [edit] > > Example of trailing whitespace bug post-1.14.5 > > > > After reading the traffic on this bug, I'm not sure whether the resolution is > > meant to imply that the trailing whitespace (on center- and right-aligned mode) > > problem has been solved or simply deferred. > > No, that particular problem is not solved. But that has its own bug number: > Bug 355789 > > > This test program (written in GtkMM; I can port that to C if anybody objects to > > the C++) shows that as of Pango 1.14.5, which contains the patches referenced > > in Behdad's comments above, the trailing whitespace is still allocated. At > > Damon's request, I'm opening this bug again. > > Please don't. This bug was about something else that is fixed already. > Okay. Thanks for the clarification.