Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf.Text adding a symbol before text  (Read 17155 times)

0 Members and 2 Guests are viewing this topic.

FrozenTux

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
sf.Text adding a symbol before text
« on: May 22, 2015, 11:19:06 pm »
Hello,

I have used pySFML on python 2.7 for some time, and having recently switched to 3.4, I have started my first SFML python 3 project.

I have discovered that sfml.graphics.Text adds '\ufeff' before it's text, which then shows up as a square when rendered, as you can see on this image : http://monosnap.com/file/JBBAqDPIvQcHs9EzLTxwE1SyjQ8xZG.png .

This is not linked to the font itself or the rendering as the supplementary symbol is present in the string attribute of the Text object. Setting the text after initialisation does not fix the issue as the prefix is added again.

I have tried to pass utf-8 bytes instead of str, but it causes an error and the text is not set.

I am using :

As I never encountered this problem before, I have tried to run my program under Python 2.7 with the latest official binary, and the square did not appear (with or without using unicode)

This led me to think that the problem may be caused by my unofficial binary. I have tried to build from source with SFML 2.3, but unfortunately I am stuck at the last step with the error "unresolved external".
I have put the libs and includes in the correct folders with the compiler, and I have copied the dlls to the indicated location in the python folder, without success.
Maybe it's very simple to fix but I am not familiar with compilation and thus completely lost.

I would like to know if anyone encountered this issue and found a way to fix it.
PySFML begginer - Sorry for my english, I am french.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: sf.Text adding a symbol before text
« Reply #1 on: May 25, 2015, 08:02:36 pm »
I have the same issue. It's something with properly encoding the strings. I will soon have a look into that.

FrozenTux

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: sf.Text adding a symbol before text
« Reply #2 on: June 16, 2015, 09:33:25 pm »
Good to know it's an actual bug and not a Chair-Keyboard interface issue.
Did you make any progress concerning that problem ? Unable to modify and compile pySFML myself, I ended up falling back to python 2.7 for the time being.
PySFML begginer - Sorry for my english, I am french.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: sf.Text adding a symbol before text
« Reply #3 on: June 19, 2015, 08:36:27 am »
Unfortunately not, I'm currently busy with work stuff and won't have reasonable free time until mid/end of July. :(

Regarding building PySFML, have you tried to pip-install from the Git repository? It's what works for me all the time, and which is one of the easiest methods anyway:

Code: [Select]
pip install cython
pip install git+https://github.com/Sonkun/python-sfml

FrozenTux

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: sf.Text adding a symbol before text
« Reply #4 on: June 20, 2015, 01:42:45 am »
Unfortunately not, I'm currently busy with work stuff and won't have reasonable free time until mid/end of July. :(
No problem, we all have a lives :). I'll stick with python 2 for now, it works just fine.

Regarding building PySFML, have you tried to pip-install from the Git repository? It's what works for me all the time, and which is one of the easiest methods anyway:

Code: [Select]
pip install cython
pip install git+https://github.com/Sonkun/python-sfml

I was doing basically the same thing, that is to say cloning the repository and running setup.py install. The pip method produces the same error with less output.

More specifically, sfml.system, sfml.window and sfml.graphics build correctly, but when it reaches sfml.audio, the linker fails because there are "2 unresolved externals". I have uploaded the full output even if i don't think it tells a lot : http://hastebin.com/uwoxesebec.txt

What I have tried :
  • add and remove the sfml headers and libraries from the compiler folders
  • add and remove the sfml dlls
  • change SFML versions. I tried 2.1, 2.3 and the latest unofficial nighly builds. With SFML 2.1, the compilation fails with a link error on sfml.system, whereas with SFML 2.3 and the nightly the compilation fails later on sfml.audio. (I am obviously using the Visual C++ 2010 versions each time since this is the compiler used by the Windows SDK)

I have run out of ideas of other things to try. If you think of something I might have been doing wrong (even if it seems silly; it should be obvious by now that I don't know at all what I'm doing), feel free to push me in the right direction.

Anyway, thanks a lot for your continued support !
PySFML begginer - Sorry for my english, I am french.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: sf.Text adding a symbol before text
« Reply #5 on: June 23, 2015, 09:49:15 am »
Using a compiler which is recommended/required by Python would have been something I would have suggested to you, but you are already using that. So I'm kinda like out of ideas as well. :(

I will try to build it myself as soon as I have some time available, but like said, that can take some weeks. I guess until then, you are up on your own. ;)

GalakTozawr

  • Newbie
  • *
  • Posts: 17
  • You must create more game that oneself.
    • View Profile
    • My SFML lesson for russian language
    • Email
Re: sf.Text adding a symbol before text
« Reply #6 on: December 19, 2015, 08:46:56 am »
I have a problem problems with non-ASCII characters(russian languge). I use
#!/usr/bin/python
# -*- encoding: utf-8 -*-
import sfml as sf
import json
class draws:
    def __init__(self):
        with open('setting.json') as data_file:    
            setting = json.load(data_file)
        print
        self.window = sf.RenderWindow(sf.VideoMode(setting['window_width'],
                                                   setting['window_height']),
                                                   setting['title'])
        self.run()#bot
    def run(self):
        font = sf.Font.from_file("arial.ttf")
        text = sf.Text("Русский текст", font, 16)#this error string
        while self.window.is_open:
            for event in self.window.events:
                if type(event) is sf.CloseEvent:
                    self.window.close()
            self.window.clear(sf.Color.BLUE)
            self.window.draw(text)
            self.window.display()
if __name__ == "__main__":
    Tree = draws()
but i get error:
Console error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

I use unicode:
text = sf.Text(u"Русский текст", font, 16)#this error string
 
exelent, but wrong drawing literals. image error:


I use cp1253(russian decode)
text = sf.Text(u"Русский текст".decode('cp1253'), font, 16)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-6: ordin al not in range(128)

i use python 2.7 and pysfml 2.2 in exe installer
English text exelent draw. I now not see as this job.
You redactor replacement code, this link pastebin:
http://pastebin.com/nw04s6Ca
http://pastebin.com/Tyfae3RC

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: sf.Text adding a symbol before text
« Reply #7 on: December 19, 2015, 10:26:10 am »
Does arial.ttf support these glyphs?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

GalakTozawr

  • Newbie
  • *
  • Posts: 17
  • You must create more game that oneself.
    • View Profile
    • My SFML lesson for russian language
    • Email
Re: sf.Text adding a symbol before text
« Reply #8 on: December 19, 2015, 04:54:35 pm »
Yes, i get system font, this font support my languafe, i screen  view frontforge

I would be grateful for a solution to my problem.

Still, I can say that in front of me managed to forge change addresses of the Russian into English, but it does not solve my problem.
« Last Edit: December 19, 2015, 05:10:46 pm by GalakTozawr »