[GRASS-user] d.text greek letters.

Hello list.

I am struggling with using the greek letter µ in my d.text from a python script:

I trying something like this

Module(‘d.text’,text=‘µ’,at=(‘85’,‘20’) charset=‘utf8’)

I know that the issue is with the encoding of the characters… but I do not know how to fix it.

In the gui i can use µ with add text layer - so I guess this is a python to grass issue.

I trying to write a png-file. I guess a could use the ps.map, but I rather not.

I using grass 7.0.4

anyone know what to do?

Martin

Hello Martin,

On Wed, May 18, 2016 at 8:30 AM, Martin Album Ytre-Eide <
Martin.Album.Ytre-Eide@nrpa.no> wrote:

I am struggling with using the greek letter µ in my d.text from a python
script:

I trying something like this

Module('d.text',text='µ',at=('85','20') charset='utf8')

you need to set GRASS_FONT to some font which supports Greek letters. Use
d.fontlist or d.font -l to get the proper names of fonts. This works for me
in command line on Ubuntu:

export GRASS_FONT=Ubuntu:Regular
d.mon wx0
d.text text=θωερτψυιοπασδφγηςκλζχξωβνμάέήίϊΐόύϋΰώ at=5,95

I know that the issue is with the encoding of the characters..... but I do
not know how to fix it.

I'm not sure which operating system you are using but on Linux, you usually
don't need to set the font, everything is UTF-8.

In the gui i can use µ with add text layer - so I guess this is a python
to grass issue.

The behavior is different (for good or bad) - in GUI, d.text is actually
not used and wxPython text drawing is used instead.

Vaclav

Great! Thanks a lot Vaclov! :slight_smile:

os.environ[‘GRASS_FONT’]=‘Ubuntu:Regular’

did the trick for me - of course I am on Ubuntu :slight_smile:

Thanks for the wxPython text explanation - I was wondering if there where some other d.text-function I might use in my scripting.

Actually d.text in the gui crashed when I tried it (several times… without any greek letters)

Thanks again!

Hope to see you in Bonn

Cheers

Martin

···

Hello Martin,

On Wed, May 18, 2016 at 8:30 AM, Martin Album Ytre-Eide Martin.Album.Ytre-Eide@nrpa.no wrote:

I am struggling with using the greek letter µ in my d.text from a python script:

I trying something like this

Module(‘d.text’,text=‘µ’,at=(‘85’,‘20’) charset=‘utf8’)

you need to set GRASS_FONT to some font which supports Greek letters. Use d.fontlist or d.font -l to get the proper names of fonts. This works for me in command line on Ubuntu:

export GRASS_FONT=Ubuntu:Regular
d.mon wx0
d.text text=θωερτψυιοπασδφγηςκλζχξωβνμάέήίϊΐόύϋΰώ at=5,95

I know that the issue is with the encoding of the characters… but I do not know how to fix it.

I’m not sure which operating system you are using but on Linux, you usually don’t need to set the font, everything is UTF-8.

In the gui i can use µ with add text layer - so I guess this is a python to grass issue.

The behavior is different (for good or bad) - in GUI, d.text is actually not used and wxPython text drawing is used instead.

Vaclav