Currently I am writing a standalone Python script and I am trying to modify a simple point marker using font style. There are some interesting fonts with different characters that aren't exactly on a normal keyboard. Does anyone know how to use these characters?

For example, I currently have:

symbol = QgsMarkerSymbolV2.createSimple({'color': 'transparent', 'outline_color': 'transparent'})
# create the fontStyle symbol
fontStyle = {}
fontStyle['color'] = 'gray'
fontStyle['font'] = 'DejaVu Serif'
fontStyle['chr'] = '0x65'
fontStyle['size'] = '8'
# create a layer for the fontStyle
symLyr1 = QgsFontMarkerSymbolLayerV2.create(fontStyle)

I can't type in the actual character in fontStyle['chr'] but I do know the actual value pertaining to the desired character. Is there a 'value' property such that I can say something like:

fontStyle['value'] = '0x65'

You have to do this:

fontStyle['value'] = '\x65'

You can read more about the unicode here: https://docs.python.org/2/howto/unicode.html

  • Unfortunately this change doesn't seem to affect my code at all. I still just see a default print of the char 'A' instead of the character I would like to see. Jul 14 '16 at 14:19
  • Have you tried u'\x65'? It works for me, I ve got a snowflake.
    – dmh126
    Jul 14 '16 at 14:24

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.