1

I am trying to define the font for features based on values in the attribute table. This is what I have tried in the Expression String Builder next to the Font dropdown in Layer Properties/Labels/Text:

CASE WHEN "descriptio" = 'LABAYKU' THEN Arial ELSE Times_New_Roman END 

The Expression Builder doesn't report an error, but returns Null and the font of the labels doesn't change. I tried putting brackets around the name of the font but that results in an error. I have been able to define the font size using an expression, but haven't been able to find an example of an expression that lets you customize the font itself. What would be a valid expression?

1 Answer 1

5

The font names need to be quoted.
Also Times New Roman needs spaces not underscores (tested in QGIS 2.18.14).

Try this:

CASE WHEN "descriptio" = 'LABAYKU' THEN 'Arial' ELSE 'Times New Roman' END 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.