3

The answer to this question tells us how to wrap labels on spaces. Is it possible to wrap labels on defined spaces? For example, wrap on just the first space or on just the second space.

Secondly, is there a way of controlling the amount of vertical space inserted when wrapping labels? Wrapping on a character (or on a control-character) inserts too much vertical space.

Nick.

nhopton
  • 6,983
  • 1
  • 19
  • 36

2 Answers2

3

No you can't do any of those thing yet. Feel free to open a ticket for it on hub.qgis.org

Nathan W
  • 34,706
  • 5
  • 97
  • 148
  • 1
    Is it possible now? – Albert Jan 24 '17 at 07:31
  • Controlling vertical space is (using Line Height in label settings), but not which space to wrap on, apparently. The non-breaking space character does not seem to be honored for label wrap purposes (despite that being its sole purpose). – Nathan Mar 02 '19 at 19:22
2

You can use a conditional expression to match the second space using regular expression. Supposing your layer has a name field:

  1. Go to Layer Properties > Formatting
  2. Click the Expression button (E) beside Wrap on character > click Edit

Layer properties

  1. Add the following expression, then click OK:

if(regexp_match("name",'^[^ ]+ [^ ]+ '),' ','')

Wrap on character expression window

Make sure that no invisible characters/whitespace is inserted in the Wrap on character field as it will override the expression.

JAT86
  • 932
  • 5
  • 17