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 81906 - Would be useful to have PANGO_WRAP_WORD_OR_CHAR
Would be useful to have PANGO_WRAP_WORD_OR_CHAR
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
1.0.x
Other All
: Normal enhancement
: future
Assigned To: Owen Taylor
Owen Taylor
: 70477 91784 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2002-05-15 20:25 UTC by Federico Mena Quintero
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
Patch to implement PANGO_WRAP_WORD_CHAR in PangoLayout. (5.89 KB, patch)
2002-10-01 15:04 UTC, Alexander Larsson
none Details | Review
Better patch (4.18 KB, patch)
2002-10-01 15:41 UTC, Alexander Larsson
none Details | Review
New version (8.53 KB, patch)
2002-10-02 16:23 UTC, Alexander Larsson
none Details | Review
Updated patch. (9.19 KB, patch)
2002-10-02 17:49 UTC, Alexander Larsson
none Details | Review
Updated patch (9.29 KB, patch)
2002-10-04 20:11 UTC, Alexander Larsson
none Details | Review
sigh, new version with fixed long-standing bug (i hope) (10.22 KB, patch)
2002-10-04 20:46 UTC, Alexander Larsson
none Details | Review

Description Federico Mena Quintero 2002-05-15 20:25:17 UTC
Right now PangoLayout has this behavior with PANGO_WRAP_WORD:

|This sentence|
|may not fit  |
|and words are|
|wrapped      |
|properly, but|
|long words   |
|like         |
|supercalifragilistic
|will look    |
|ugly.        |
<--- width --->

And this behavior with PANGO_WRAP_CHAR:

|This sentence|
|may not fit a|
|nd words are |
|wrapped prope|
|rly, but long|
|words like su|
|percalifragil|
|istic will lo|
|ok ugly.     |

It would be useful to have a mix of the two that wraps at word boundaries
unless there is a super-long word, where it would split it in half:

|This sentence|
|may not fit  |
|and words are|
|wrapped      |
|properly, but|
|long words   |
|like supercal|
|ifragilistic |
|will look    |
|ugly.        |
Comment 1 Chema Celorio 2002-05-15 20:27:54 UTC
We came across this while fixing a bug for gnome-icon-list
Comment 2 Matthias Clasen 2002-05-16 07:21:35 UTC
Or maybe even (with a bunch of "Underful hbox" warnings spewed to
stderr :-
)

|This sentence|
|may  not  fit|
|and words are|
|wrapped  pro-|
|perly,    
but|
|long    words|
|like superca-|
|lifragilistic|
|will     look|
|ugly.        
|

Of course, TeX's paragraph builder is not the easiest thing to duplicate...
Comment 3 Matthias Clasen 2002-05-17 13:07:48 UTC
*** Bug 70477 has been marked as a duplicate of this bug. ***
Comment 4 Dave Bordoley [Not Reading Bug Mail] 2002-08-27 18:34:03 UTC
*** Bug 91784 has been marked as a duplicate of this bug. ***
Comment 5 Alexander Larsson 2002-10-01 15:04:07 UTC
Created attachment 11336 [details] [review]
Patch to implement PANGO_WRAP_WORD_CHAR in PangoLayout.
Comment 6 Alexander Larsson 2002-10-01 15:41:45 UTC
Created attachment 11337 [details] [review]
Better patch
Comment 7 Owen Taylor 2002-10-01 21:11:06 UTC
Please change failed_first_wrap to "always_wrap_char" - 
can_break_at() shouldn't care about the algorithms in the
calling routine.

the  comment:

* If @no_break_at_start is TRUE, then BREAK_NONE_FIT will never
 * be returned, a run will be added even if inserting the minimum amount
 * will cause the line to overflow. This is used when we've discovered
 * we can't break the line at all and have to backtrack and try again
 * allowing overflow.

needs some fixing (before your changes) - since we don't backtrack
in this case any more (if we ever did).

I think @no_break_at_start problem should be renamed to 
@force_fit, since, if I'm not mistaken, you actually should
be returning NONE_FIT for WORD_CHARS when nothing fits when
@no_break_is_start is TRUE. This is to handle the case
where the first character of the new item causes overflow.

(I think to clarify this, it might be best to add another 
result type EMPTY_FIT to distinguish NOTHING_FIT but it was
an OK end of the line)
Comment 8 Owen Taylor 2002-10-01 21:14:11 UTC
Also, could you reverse first_try and call it retrying_with_char_breaks?
Comment 9 Alexander Larsson 2002-10-02 16:23:33 UTC
Created attachment 11359 [details] [review]
New version
Comment 10 Alexander Larsson 2002-10-02 16:27:26 UTC
The new patch fixes all your comments, and removes the break_at_start
variable in process_line.
Comment 11 Alexander Larsson 2002-10-02 17:49:30 UTC
Created attachment 11363 [details] [review]
Updated patch.
Comment 12 Alexander Larsson 2002-10-02 17:51:07 UTC
This new patch fixes can_break_in to look at offset 0 too.
It also handles the 2-pixel wide layout case by not breaking on char 0
if there are no previous runs.
Comment 13 Owen Taylor 2002-10-03 18:13:38 UTC
As I mentioned yesterday on IRC, the sequence:

  if (width <= state->remaining_width && !no_break_at_end)
    {
      state->remaining_width -= width;
      insert_run (line, state, layout->text, item, TRUE);

      return BREAK_ALL_FIT;
    }

also needs adjustment for the num_chars == 1 && !line->runs
case or a single character item at the start of the line
will cause infinite looping for the 2-pixel case.
b

Comment 14 Alexander Larsson 2002-10-04 20:11:06 UTC
Created attachment 11406 [details] [review]
Updated patch
Comment 15 Alexander Larsson 2002-10-04 20:12:39 UTC
New patch. This adds what you wanted and fixes a longstanding bug if
the first item ALL_FITS, but is wider than the remaining width.
Comment 16 Alexander Larsson 2002-10-04 20:46:53 UTC
Created attachment 11407 [details] [review]
sigh, new version with fixed long-standing bug (i hope)
Comment 17 Alexander Larsson 2002-10-04 21:34:11 UTC
2002-10-04  Alexander Larsson  <alexl@redhat.com>

	* pango/pango-layout.[ch]:
	* docs/tmpl/layout.sgml:
	Add, implement and document PANGO_WRAP_WORD_CHAR