Feature request #9412

add a "minimum characters to wrap" option to labels

Added by Mathieu Pellerin - nIRV about 3 years ago. Updated about 3 years ago.

Status:Closed Start Date:01/22/2014
Priority:Normal Due date:
Assigned to:- % Done:

0%

Category:Labelling
Target version:Future Release - Nice to have
Platform: Resolution:
Platform version: Pull Request or Patch supplied:No
Status info: Tag:

Description

It would be really useful for label's multiple lines formatting to be able to set a minimum number of characters for wrap to occur.

When dealing with OpenStreetMap data, I often use the space character(' ') as the wrap character. It's an easy way to deal with long labels without having to go through over hundreds of polygon names and add a special wrap character. That said, it obviously is less elegant with small words (i.e. The, of, etc.). It could be remedied by setting a minimum number of characters on a given line to execute a wrap.

E.g. 'Institute of Technology of Cambodia' (see attached image) wrapped using the space character becomes:
Institute
of
Technology
of
Cambodia

If we could set a minimum number of character before wrap (should be up to user to set it), say for the sake of this example '3', the label - relying on space to wrap - would become:
Institute
of Technology
of Cambodia

Much better :)

Thoughts? Is it do-able? That sounds to me like a nice little setting to offer to users.

space_label.png (254.7 kB) Mathieu Pellerin - nIRV, 01/22/2014 11:38 pm

Associated revisions

Revision 9b71d081f1deb26193eca483ad9e7287bdc7af6b
Added by Nathan Woodrow about 3 years ago

Merge pull request #1208 from nirvn/expression_wordwrap3

[expression] implement a wordwrap function (fix #9412)

History

Updated by Mathieu Pellerin - nIRV about 3 years ago

  • Category set to Labelling

Updated by Mathieu Pellerin - nIRV about 3 years ago

An alternative to this (maybe more intuitive) would be to implement a wordwrap() function in the expression builder:
wordwrap(string = '', nb_characters = X, break, = '', cut = false[default])

A simple wordwrap(mystring,20,'\n') would trigger a wrap (insert a \n) starting at the 20th character on the next space character.

Maybe the expression function makes more sense.

Updated by Giovanni Manghi about 3 years ago

  • Target version set to Future Release - Nice to have

Updated by Nathan Woodrow about 3 years ago

  • Status changed from Open to Closed

Also available in: Atom