SFML community forums

Help => General => Topic started by: Tigre Pablito on November 05, 2017, 02:10:06 am

Title: Problem with Text class
Post by: Tigre Pablito on November 05, 2017, 02:10:06 am
Hello!

I'm having problems with Text class, I'm trying to use a wrapper to handle writting on the screen easier, and my app frequently ends up with a "Access violation exception: Attempting to read or write from the protected memory. Often this says that there is another memory damaged".

I think remember having read something about this issue a time ago, like that the problem is in the Font.
I'm creating the Font from a Byte[] array (my assets are packed into a file).

I don't know if writting this

Text text = new Text(string, new Font( byte[] array ));

or making the Font as an attribute of the class

Can anyone please help me or tell me where is the answer?
Thanks
Title: Re: Problem with Text class
Post by: Laurent on November 05, 2017, 07:32:43 am
Is this C#?
Title: Re: Problem with Text class
Post by: Tigre Pablito on November 05, 2017, 02:03:17 pm
Yes, it is. And SFML.Net 2.2
Title: Re: Problem with Text class
Post by: Laurent on November 05, 2017, 03:37:45 pm
Are you sure that you use the correct CSFML 2.2 binaries?
Title: Re: Problem with Text class
Post by: Tigre Pablito on November 05, 2017, 05:06:31 pm
I have just overwritten them to ensure ...

And the issue persists ...

Now I made a static class for writting text on the screen, and on debugging I saw the GelLocalBounds().Height of the text that didn't appear was 0, not so the Width ... cos I'm aligning to the center some text

So some text appears and other doesn't
Title: Re: Problem with Text class
Post by: Tigre Pablito on November 05, 2017, 06:35:00 pm
I don't know what to do ... it seems the problem is on the font ... I see with the debugger that some internal attributes of it are null and 0 ... some texts are drawn and others are not ... it seems this has no sense ... I don't think it is a bug, because it would have been found much before, I suppose

I tried both

text = new Text ( string, new Font ( byte[] array) );

and

text.Font = MyStaticClass.font;

and it's the same dislike

I can't understand why some texts are drawn and others are not, and always the same ones
Title: Re: Problem with Text class
Post by: Tigre Pablito on November 05, 2017, 07:37:58 pm
Hey, Laurent, I was wrong. The issue is solved

I found out that, the same as with the Music class, if you load a Font from a byte[] array, that buffer has to remain in memory because SFML doesn't load the entire Font (or Music) into memory. (If loaded from a disk file it's less probable that the file disappears)

Title: Re: Problem with Text class
Post by: Laurent on November 05, 2017, 08:42:53 pm
Yes, this is explained in the documentation by the way.
Title: Re: Problem with Text class
Post by: Tigre Pablito on November 06, 2017, 12:35:47 am
Yep, I knew that but about the Music class (cos I had run into the same issue), but I didn't read about Text or Font classes ... fortunately my poor brain made me associate the issues