special characters in panda?

Hello
I’m trying to put special characters (ñ) on the screen using OnscreenText, but not how. The first line of my py file is # - * - coding: utf-8 - * - and in my Config.prc file I have utf8 text-encoding. Someone could help me with the following code? Thank you.

from direct.showbase.ShowBase import ShowBase
from direct.gui.OnscreenText import OnscreenText



class App(ShowBase):

  def __init__(self):

    ShowBase.__init__(self)
    texto = 'contraseña'
    OnscreenText(bg = (0,0,0,47.0/255), text = texto, 
        fg = (246.0/255, 205.0/255, 11.0/255, 1),pos = (0,0), scale = 0.1)
   
App().run()

Maybe the default font is missing that glyph? Try to use a font that has these extra characters.

thanks for your reply. Using the BebasNeue.ttf font which contains the character ‘ñ’, I still have the same problem. here is the code:

# -*- coding: utf-8 -*-
from direct.showbase.ShowBase import ShowBase
from direct.gui.OnscreenText import OnscreenText



class App(ShowBase):

  def __init__(self):

    ShowBase.__init__(self)
    self.fontBebas = loader.loadFont('BebasNeue.ttf')
    texto = 'contraseña'
    OnscreenText(bg = (0,0,0,47.0/255), text = texto, 
        fg = (246.0/255, 205.0/255, 11.0/255, 1),pos = (0,0), scale = 0.1,
        font = self.fontBebas)
   
App().run()

a image of ‘contraseña’

casimages.es/i/131215101714959850.png.html

I know I was using non-ascii leters in direct gui and dgui uses the TextNode just like on screen text, so it should work. I’ll check what I did to make sure on the morrow, one more thing that comes to mind is to try the text as explicit unicode:
u’contraseña’

I only found BebasNeue in OTF format, but it worked as long as the script was saved as utf-8

Are you sure your editor is not saving the file as ANSI or something like that? Many do (like notepad++) by default.

Thank you for your help. Yes!, the problem was NetBeans not kept my file in utf8. Problem solved,thanks.