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

Author Topic: Problem with Text class  (Read 1903 times)

0 Members and 1 Guest are viewing this topic.

Tigre Pablito

  • Full Member
  • ***
  • Posts: 225
    • View Profile
    • Email
Problem with Text class
« 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Problem with Text class
« Reply #1 on: November 05, 2017, 07:32:43 am »
Is this C#?
Laurent Gomila - SFML developer

Tigre Pablito

  • Full Member
  • ***
  • Posts: 225
    • View Profile
    • Email
Re: Problem with Text class
« Reply #2 on: November 05, 2017, 02:03:17 pm »
Yes, it is. And SFML.Net 2.2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Problem with Text class
« Reply #3 on: November 05, 2017, 03:37:45 pm »
Are you sure that you use the correct CSFML 2.2 binaries?
Laurent Gomila - SFML developer

Tigre Pablito

  • Full Member
  • ***
  • Posts: 225
    • View Profile
    • Email
Re: Problem with Text class
« Reply #4 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

Tigre Pablito

  • Full Member
  • ***
  • Posts: 225
    • View Profile
    • Email
Re: Problem with Text class
« Reply #5 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

Tigre Pablito

  • Full Member
  • ***
  • Posts: 225
    • View Profile
    • Email
Re: Problem with Text class
« Reply #6 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)


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Problem with Text class
« Reply #7 on: November 05, 2017, 08:42:53 pm »
Yes, this is explained in the documentation by the way.
Laurent Gomila - SFML developer

Tigre Pablito

  • Full Member
  • ***
  • Posts: 225
    • View Profile
    • Email
Re: Problem with Text class
« Reply #8 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

 

anything