Feature request #3284

Wrapping long labels

Added by Michael Douchin almost 14 years ago. Updated almost 13 years ago.

Status:Closed
Priority:Low
Assignee:Nathan Woodrow
Category:Labelling
Pull Request or Patch supplied:No Resolution:fixed
Easy fix?:No Copied to github as #:13344

Description

Sometimes labels are very long, such as "River of the Big Dry Blue Reef". UMN Mapserver offers a way to wrap labels based on 2 parameters :

  • a max length (integer)
  • a wrap character, space by default

See http://mapserver.org/mapfile/label.html for more information.

I do not know how hard it is to implement this feature in the new label engine (considering curves, etc.)

Associated revisions

Revision f57892c7
Added by Nathan Woodrow almost 13 years ago

[FEATURE] Add label wrapping on character. Semi Fixes #3284

History

#1 Updated by Alister Hood almost 14 years ago

I guess it would also be good if they could wrap to avoid collisions with features or other labels, instead of wrapping at a specified length :)

#2 Updated by Alister Hood almost 14 years ago

There is already a wrapping option.
But I have never figured out how to actually get layers to wrap. How is it supposed to work?

#3 Updated by Alister Hood almost 14 years ago

There is already a wrapping option. But I have never figured out how to actually get layers to wrap. How is it supposed to work?

Oh, I remember now. The User Guide says multiline labels work with a true line return. I'm not sure how you're supposed to enter a true line return though (on windows).

#4 Updated by Alister Hood almost 14 years ago

Aha, here's the answer from the mailing list:

You have to enter a "real" newline. If you want to enter multiline labels in
QGIS you need to assign a TextEdit instead of LineEdit as edit widget in the
vector layer properties' attributes tab.

Of course this feature request is still valid, as it is about automatic wrapping, not wrapping with a manual line break.

#5 Updated by Michael Douchin about 13 years ago

I think this request if no longer needed since the implementation of expression based labelling : http://woostuff.wordpress.com/2011/10/27/expression-based-labeling/

#6 Updated by Nathan Woodrow about 13 years ago

  • Pull Request or Patch supplied set to No
  • Assignee deleted (nobody -)

I wouldn't close it just yet as the expression labeling thing doesn't really expose a function to wrap strings. It's on the todo list and shouldn't be to hard to add.

#7 Updated by Giovanni Manghi almost 13 years ago

  • Target version changed from Version 1.7.0 to Version 1.7.4

#8 Updated by Anonymous almost 13 years ago

  • % Done changed from 0 to 100
  • Status changed from Open to Closed

#9 Updated by Nathan Woodrow almost 13 years ago

  • Resolution set to fixed
  • Category changed from Map Canvas to Labelling
  • Assignee set to Nathan Woodrow

I have added the ability to wrap labels based on a character, check on the advanced tab on the label dialog. Max length isn't done yet but it shouldn't be too hard to add.

#10 Updated by Michael Douchin almost 13 years ago

Nathan Woodrow wrote:

I have added the ability to wrap labels based on a character, check on the advanced tab on the label dialog. Max length isn't done yet but it shouldn't be too hard to add.

Thanks !

#11 Updated by Nathan Woodrow almost 13 years ago

How would you like max length handled. I was just thinking of copying how MapServer does it http://mapserver.org/mapfile/label.html#maxlength

#12 Updated by Michael Douchin almost 13 years ago

I think it makes sense. This way users won't have problem to use it if they come from mapserver.
Plus I think this is the easiest yet effective way to handle this issue

#13 Updated by Alister Hood almost 13 years ago

Nathan Woodrow wrote:

How would you like max length handled. I was just thinking of copying how MapServer does it http://mapserver.org/mapfile/label.html#maxlength

Just to clarify: are you proposing actually doing it in the expression builder?

#14 Updated by Alister Hood almost 13 years ago

While I can see the benefits of doing it the same way as other software, the mapserver way isn't particularly intuitive. Especially things like this:

If maxlength > 0 and wrap = ‘char’, insert a newline at the FIRST wrap character AFTER maxlength characters

I would think that users would expect it to wrap at the LAST wrap character BEFORE maxlength characters (assuming there is one).

And I don't see why they have two ways of achieving "hard wrap (always break at exactly MAXLENGTH characters)". Perhaps when there is "no wrap", they mean to truncate at MAXLENGTH characters, not to "hard wrap".

#15 Updated by Nathan Woodrow almost 13 years ago

Alister Hood wrote:

Just to clarify: are you proposing actually doing it in the expression builder?

No. The plan is to add another control to the label dialog for wrapping properties e.g. max length, wrap character etc

This is a general labeling thing not really just for expressions.

Also available in: Atom PDF