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 323711 - Allow overriding/tailoring the line-breaking algorithm per pango context or layout
Allow overriding/tailoring the line-breaking algorithm per pango context or l...
Status: RESOLVED OBSOLETE
Product: pango
Classification: Platform
Component: general
1.10.x
Other All
: Normal enhancement
: ---
Assigned To: pango-maint
pango-maint
: 614371 620235 (view as bug list)
Depends on:
Blocks: 300790
 
 
Reported: 2005-12-10 11:13 UTC by Christian Neumair
Modified: 2018-05-22 12:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed Nautilus patch (doesn't work) (2.01 KB, patch)
2005-12-11 16:35 UTC, Christian Neumair
none Details | Review
strlen proof-of-concept (228 bytes, text/plain)
2005-12-11 20:26 UTC, Christian Neumair
  Details

Description Christian Neumair 2005-12-10 11:13:30 UTC
Bug 300790 wants Nautilus to wrap after '_' characters. The whole wrapping code
seems to take place in Pango, though. In my opinion, in PANGO_WRAP_WORD_CHAR
mode, layouts should preferably be wrapped at '_' positions. '.' seems to be
preferred alreay.
Comment 1 Nelson Benitez 2005-12-10 12:20:36 UTC
For the record, here[1] is an email I sent to pango list to ask for some info on
how to solve this bug...

[1] http://mail.gnome.org/archives/gtk-i18n-list/2005-November/msg00026.html
Comment 2 Behdad Esfahbod 2005-12-10 21:09:53 UTC
This is hard to implement, if not impossible.  The reason is that Pango
implements the Unicode line-breaking algorithm straight.  And that's what it
does, which is in fact not quite wrong.  Underscore behaves exactly like an
alphanumeric character in most usecases.

You can get the effect you want by inserting Zero-Width Space characters at
places that you want a break to happen.
Comment 3 Christian Neumair 2005-12-11 16:35:46 UTC
Created attachment 55865 [details] [review]
Proposed Nautilus patch (doesn't work)

Thanks for your feedback!

Maybe you could tell me why the attached patch still makes Nautilus break like
thisisfoo.b
ar

Maybe I'm using the wrong character?
Comment 4 Nelson Benitez 2005-12-11 19:19:26 UTC
I can't test the patch right now, but having a look at it, I wonder if you lack a :
p += strlen(ZERO_WIDTH_SPACE);
just after the :
p = strcpy (p, ZERO_WIDTH_SPACE);



Comment 5 Behdad Esfahbod 2005-12-11 19:39:13 UTC
Yeah, what Nelson said :).
You can also use a GString here.

That may even qualify for a glib function, like g_utf8_collate_key_for_filename did.
Comment 6 Behdad Esfahbod 2005-12-11 19:40:15 UTC
I have no idea how Nautilus works, but obviously you don't want the inserted
character to show up anytime when editing the file name.  That becomes a bit
tricky...
Comment 7 Christian Neumair 2005-12-11 20:24:16 UTC
Nelson: odd, according to string.h, stcpy "return(s) the address of the
terminating '\0' in DEST". According to man stcpy, "(t)he strcpy() and strncpy()
functions return a pointer to the destination string dest.", so the right
solution is probably to not use the return value at all and use the += method
demanded by you.

However, even more odd is that strlen (ZERO_WIDTH_SPACE) returns zero.
Comment 8 Christian Neumair 2005-12-11 20:26:19 UTC
Created attachment 55869 [details]
strlen proof-of-concept
Comment 9 Behdad Esfahbod 2005-12-11 20:35:40 UTC
It's "\xE2\x80\x8B" in C, not "\0xE2\0x80\0x8B".
Comment 10 Christian Neumair 2005-12-11 20:39:47 UTC
Yes, that's what the C gurus on freenode.net told me. Thanks for also pointing
it out. I keep forgetting about these MBCs. They also claimed that strcpy
probably returns a pointer to the first char, and that string.h header docs are
useless :P.
Thanks for your efforts, it seems to work over here and I'll attach the patch at
the other bug report.
The editing widget will not break at the same positions, btw.
Comment 11 Behdad Esfahbod 2005-12-11 20:43:10 UTC
Yeah, that may be a bit annoying.  You press F2 to edit and the line-breakings
change.
Comment 12 Christian Neumair 2005-12-11 20:48:36 UTC
So you think we should also use the same rules for editing, and afterwards
filter out the zero width characters again? May they occur in filenames at all?
Comment 13 Behdad Esfahbod 2005-12-11 20:52:40 UTC
That doesn't quite work, since users will be able to move cursor around and
otherwise edit those characters, which is not what we really want.  We do need a
mechanism to tailor line-breaking I'm afraid.  Maybe leaving this bug open is a
good idea.  The idea is you provide a line-breaking function to Pango, which is
used instead of the default one.  In yours, you can call the original one, then
modify the bits to break on _ and .
Comment 14 Nelson Benitez 2006-01-06 00:49:31 UTC
Behdad, I think you mean:
PangoLayout text -> append zero width chars in text for _ and . ->  call default break function with text -> remove from the returned text the zero width chars we inserted before -> pangolayout text now has text breaked in _ and .

Is this correct?   
Comment 15 Behdad Esfahbod 2006-02-05 03:22:25 UTC
No, not quite.  That's indeed one way this can be done, but a really hard one, since you have to copy the string, etc...

You just pass string to default break function, then go over the string and for each . and _ found, you change the can_break attribute of that position to TRUE.
Comment 16 Behdad Esfahbod 2010-09-23 19:36:55 UTC
*** Bug 620235 has been marked as a duplicate of this bug. ***
Comment 17 Behdad Esfahbod 2010-09-23 19:37:46 UTC
*** Bug 614371 has been marked as a duplicate of this bug. ***
Comment 18 GNOME Infrastructure Team 2018-05-22 12:13:10 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/33.