2

I want to label my polygons with information, and I want the labels to be in two rows - name on row 1 och volume on row 2. My problem is, that I get an extra "quare" at the end of row 1? That has never happened before.

EDIT: Here is the expression I wroght: enter image description here

And, it works, I just get that extra quare, like this:enter image description here

I use QGIS 2.10 and Windows 10, could it be because of the Windows 10? I never had this problem on Windows 8.

EDIT 2: I realize that I need to clarify my question, I have two different columns. I want the information in column 1 to be in the first row and the information from column 2 to be in the second row of the labels. But, my expression makes the labels with an extra square at the end of row 1.

I use encoding windows-1252.

5
  • Can you write the complete label expression. What do you use as 'Wrap on character' in the labels setting for breaking the line?
    – Jakob
    Commented Nov 4, 2015 at 8:49
  • I realize that my question was a bit unclear, I didn't break the line, I have two columns that I want to use on different rows in the labels.
    – SoS
    Commented Nov 4, 2015 at 9:45
  • Could it perhaps be an encoding issue? Those type of squares appear quite often if QGIS doesn't recognise certain symbols. As QGIS uses the system encoding by default, try changing the layer's Data source encoding (Layer Properties > General) to one such as UTF-16?
    – Joseph
    Commented Nov 4, 2015 at 11:40
  • @Joseph I tried to change the encoding like you suggested, to UTF-16, but then the names of the columns looks like chinese? And I upgraded to QGIS 2.12.1, but the squares are still there.
    – SoS
    Commented Dec 3, 2015 at 9:40
  • @SoS - Could you perhaps share your data (or make a copy and delete most of the attributes if you have sensitive data) on a public server so that others could test it?
    – Joseph
    Commented Dec 3, 2015 at 12:42

1 Answer 1

2

The expression editor lets you wrap text from one line to the next.

I think the square may be part of a newline. In Windows, newline is two characters (\r\n), on Linux it's one (\n). What you did works on Linux (in QGIS 2.12 at least). Not sure why it would work in Windows 8 - perhaps this was in an earlier version of QGIS which may have handled newlines differently?

An easier way - as Jakob mentioned - is to choose a special character to break the text over lines. This can be any character - just make sure that it's one that won't appear in your label text. Here, I've chosen *. I've put this after "FASTIGHET" - that seems to be where you want the split.

"FASTIGHET" || '*' || CASE WHEN "Blad1_Field1" is '' THEN '' ELSE 'Volym (m3sk)' || ' ' || "Blad1_Field2" END

You can now use the Formatting > Wrap on Character setting, and your label should appear over two lines.

wrap on character

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.