4

QGIS currently does not have a way to set a default font to be used for labelling, and being lazy I'm getting tired of having to set our house font styling for every layer I create or use (see change default font of labels in QGIS for someone else equally frustrated, and the bug report for it).

I've looked at the QGIS code changes required and it's not easy, so now I'm trying for an interim fix by writing a plugin that will either apply a default qml style file or directly set it via the api.

A couple of approaches I'm contemplating are:

  • A legend context menu entry (easy to do, expandable to choosing from a list of house styles, but still a manual process)
  • Catching the layerAdded signal, checking if the new layer has a style already set, and if not setting the font (more complex but fully automatic)

Before I do this, can anyone suggest a simpler hack, or something obvious I'm missing? Something using project templates, default styles, layer definition files, or something similar?

(I'm aware this won't work when using rule-based labeling, but for most use cases it will make life easier).

2
  • Have you seen the answer provided by @SaultDon in your linked post?
    – Joseph
    Commented Mar 24, 2016 at 10:48
  • Yes, and it doesn't make it any quicker, you're still having to choose a value from a drop-down, just a shorter one, and you still have to choose size and style too. A single click or no click solution would be better.
    – odysseus
    Commented Mar 24, 2016 at 16:55

1 Answer 1

2

One workaround I've found is to open up the .qgs project file in a text editor (they're in a sort of plain-text xml type format) after the fact and batch change all the font declarations with regex - I think they should ALL be in the .qgs file, unless perhaps there are some plug-ins that store them elsewhere.

Sorry I don't remember exactly what they look like in the text as haven't used QGIS for a little while but they should be obvious - if you don't know how to use regex let me know.

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.