GNOME Bugzilla – Bug 674924
buggy ZERO_WIDTH_SPACE hack, maybe should be dropped?
Last modified: 2012-04-27 19:06:28 UTC
Using nautilus 3.4 on Ubuntu precise we had some wrapping issues in the icon view which turned out to be due to nautilus hacks to insert "zero width space" in labels to help wrapping at the right place The specific bug we had is that "Install Ubuntu 12.04" would wrap after the point and show "Install Ubuntu 12. 04" the code is nautilus-icon-canvas-item.c #define ZERO_WIDTH_SPACE "\xE2\x80\x8B" #define ZERO_OR_THREE_DIGITS(p) \ (!g_ascii_isdigit (*p) || \ (g_ascii_isdigit (*(p+1)) && \ g_ascii_isdigit (*(p+2)))) ... create_label_layout (NautilusIconCanvasItem *item, if (text != NULL) { str = g_string_new (NULL); for (p = text; *p != '\0'; p++) { str = g_string_append_c (str, *p); if (*p == '_' || *p == '-' || (*p == '.' && ZERO_OR_THREE_DIGITS (p+1))) { /* Ensure that we allow to break after '_' or '.' characters, * if they are not likely to be part of a version information, to * not break wrapping of foobar-0.0.1. * Wrap before IPs and long numbers, though. */ str = g_string_append (str, ZERO_WIDTH_SPACE); }" There is one "obvious" bug, the define "g_ascii_isdigit (*p)" should be "g_ascii_isdigit (*(p))" instead the current way ZERO_OR_THREE_DIGITS (p+1) has (*p) become (*p+1), or you want (*(p+1)) there Fixing that issue resolve the initial bug I described. Still the ZERO_OR_THREE_DIGITS() hack feels wrong, nothing tell you that IPs will have 3 digits or that version numbers follow the described scheme I would suggesting drop the define and replace the code this way - if (*p == '_' || *p == '-' || (*p == '.' && ZERO_OR_THREE_DIGITS (p+1))) { + if (*p == '_' || *p == '-' || (*p == '.' && !g_ascii_isdigit(*(p+1)))) { if you want to keep the current logic to "help" wrapping
Going further I would suggest dropping that code and all and let normal text wrapping happen We got another bug on https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/986008 which seems to be due to this code Screenshot: https://launchpadlibrarian.net/102651819/Screenshot%201.png Reproducer: download https://launchpadlibrarian.net/102969878/Test%20Document%20%E0%B8%A1%E0%B8%B5%E0%B8%A0%E0%B8%B2%E0%B8%A9%E0%B8%B2%E0%B9%84%E0%B8%97%E0%B8%A2-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2.txt What I wrote on the Ubuntu bug is: "it seems like the "zero width space" is what is creating the issue, I'm unsure why that's happening though. One bug I can see is that the code is iterating over char types, and an utf8 non ascii glyph might not fit in a char, so it could insert value in the middle of an utf8 sequence and corrupt it, but that doesn't seem to be what is happening there since the "weird" glyphs are added after "_" and "."" I'm unsure at this point if the bug is a pango one or something...
Let me know if you want me to open different bugs about the different issues
Created attachment 212945 [details] [review] fixes the parenthesis issues in the defined logic
Thanks for the patch, I pushed it to git master and gnome-3-4. The issue with Thai is either a bug in Pango or in the font used...I can reproduce it here on Fedora 17, but it might use the same font as Ubuntu for Thai. Anyway, it should be investigated further and filed as a separate bug. I still think we want to keep the current wrap limit to three numeric characters after a dot.