How to write subscript or superscript labels in QGIS 3.4?

Is there any function to do it without any external involvement like Character Map or etc?

I'm EXPLAINING that this is not a duplicate question and I want to use those scripts not only in MAP LAYOUT but everywhere!

For example like this below ▼ enter image description here

  • @Mapperz this is not a duplicate! Read more carefully! Am I asking about legend here? I've searched a lot and want to hear about QGIS3 and scripting in expression! I know your linked question and many others but they are not ok in my case!
    – Dan
    Commented Feb 26, 2019 at 15:17
  • 1
    Is the following link any help? gis.stackexchange.com/questions/181287/…
    – user90323
    Commented Feb 26, 2019 at 15:20
  • @carlos that script is obsolete for QGIS3!!! it works only with numbers and only superscript part. Subscript part shows errors in python console. That is not a solution...
    – Dan
    Commented Feb 26, 2019 at 15:22
  • 2
    It is not.... First off you would need to add further unicode supscript and subscript samples for the whole alphabet. Secondely to fix subscript you need to change the 'outputText += unichr(charPos + 8320)' line to 'outputText += chr(charPos + 8320)'.
    – user90323
    Commented Feb 26, 2019 at 15:30
  • 1
    There are however some letters missing in unicode so I would advise searching for a python module which can handle the whole alphabet. Maybe sympy will do the trick.
    – user90323
    Commented Feb 26, 2019 at 15:44


Browse other questions tagged or ask your own question.