4

For one of my label layers I am using a font that contains typographic ligatures for certain letter pairs. If I increase the letter spacing in Layer Properties, the ligature is retained as a single character, so the spacing between the pair of letters does not increase (see image for example—note the double T ligature).

Is there a Python expression, or another way to disable or override these ligatures, so that the individual characters are displayed instead?Massachusetts Bay label

1

Method 1: Use a data-defined expression to change the font of labels that contain ligatures

Step 1: Find a font similar to the original font, but without typographic ligatures. We'll call these 'original font' and 'similar font.'

Step 2: Use an expression to select the original font for labels without typographic ligatures, and the similar font for labels with typographic ligatures. enter image description here

Open the label dialog > click the epsilon button next to Font > select Edit > input this expression:

CASE

WHEN regexp_match( "label_field" , TT) THEN 'similar font'

ELSE 'original font'

END

Substitute the field name that you're using for your labels. If the original font contains more than one typographic ligature, repeat the line that starts with "WHEN" and substitute the additional ligature where it says "TT".

Method 2: Use a font without typographic ligatures for all the labels

This method is self-explanatory.

  • That's the workaround I'm already using (Method 1, that is—Method 2 is basically giving up; a non-solution). Another workaround I thought of is to insert spaces between each letter (and then adjust the word spacing setting accordingly). But i'm really looking for an actual solution for the question, assuming it's possible. I believe it's program-specific; for example, Abode programs have settings to turn off ligatures, and there's also a CSS command that can do it. Anything in Python, maybe, for QGIS? – Nathan Jan 25 '18 at 5:46
0

I've got my answer: according to the QGIS tracker, this is a known issue and will be solved in QGIS 3.0; so the solution will be to use that when it is released.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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