New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve label WRAP #5613

olt opened this Issue Jun 15, 2018 · 4 comments


None yet
3 participants

olt commented Jun 15, 2018

We want to improve label wrapping in MapServer so that road labels can be wrapped at space and dashes.

It goes into the same direction as #3266 and

MapServer only allows a single WRAP character. A possible solution would be to wrap at Unicode ZERO WIDTH SPACE (0x200b) and let the user insert this everywhere a wrap is possible. ZERO WIDTH SPACE is not rendered by Mapserver. This character can be inserted with PostgreSQL replace(replace(name, ' ', E' \u200b'), '-', E'-\u200b') for example.

However, WRAP is a char and does not support Unicode. Instead of changing this type (and opening a whole can of new issues), I suggest that we allow to insert an ASCII control character as a marker for ZERO WIDTH SPACE. RECORD SEPARATOR or UNIT SEPARATOR for example.

It's difficult to insert these chars for most endusers, maybe we can add a keyword for this and replace it internally with the ASCII control char? I don't know how the Mapfile parsing works and how this would be implemented.

Another idea would be to accept that wrapping at space is a common use case and change the default behavior to automatically wrap at SPACE and ZERO WIDTH SPACE. I would prefer this. ZERO WIDTH SPACE should be so uncommon that backwards compatibility should not be an issue.

The msLayoutTextSymbol function needs to be changed to wrap at the provided WRAP char or at ZERO WIDTH SPACE if that char is RECORD SEPARATOR. This change is required anyhow (see #5612).

I have a working prototype and I can provide a PR.
Any opinions, suggestions, +1s?


This comment has been minimized.


sdlime commented Jun 15, 2018

I'm all for something that improves labeling and is easier for users. I'm having a hard time visualizing how these options would manifest themselves in a mapfile. What does your prototype do?


This comment has been minimized.


olt commented Jun 18, 2018

I use WRAP with RECORD SEPARATOR (ctrl-v x1e in Vim ;-) ) and replace this char with ZERO WIDTH SPACE in msLayoutTextSymbol. I place ZERO WIDTH SPACEs in my data everywhere a line break is OK (see PostgreSQL replace above). Like My <Z>Long <Z>Name and My-<Z>-Other-<Z>Name (where <Z> is \u200b).

Mapserver can then break both labels at every <Z>, spaces and dashes are kept, even where it was wrapped. For example My Long \nName, My \nLong \nName, My-\nOther-Name, My-\nOther-\nName.

I would much prefer to make this the default behavior, inserting a RECORD SEPARATOR into a Mapfile is everything but easy for users.


This comment has been minimized.


olt commented Jul 31, 2018

There is an implementation in #5634, together with a test case and two test images.

sdlime added a commit that referenced this issue Aug 30, 2018

Merge pull request #5634 from olt/label-wrap-fix
Fix label wrap (#5612) and wrap at ZERO WIDTH SPACE (#5613)

This comment has been minimized.


geographika commented Sep 25, 2018

Added to 7.2 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment