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

Author Topic: Code crashes upon using font.loadFromFile  (Read 5853 times)

0 Members and 1 Guest are viewing this topic.

taliebram

  • Newbie
  • *
  • Posts: 7
    • View Profile
Code crashes upon using font.loadFromFile
« on: June 22, 2021, 03:20:10 pm »
Hello,


I'm currently working on a project, and until now I have not had any issues with the SFML library. I am currently trying to add some text to my window, but loading in any font results in an instant crash. I have double-checked the linking of the libraries to make sure that I am using -d as I am in debug mode.

I have also tried adding the full path, but that also results in a crash. Using the sf::Text without loading in any font just results in a single pixel being drawn.

I have also tried using different fonts, but that also did not work.

I can add a code snippet, but I have tried it in a small test script where it also fails. I am using the ImGUI::SFML combination, but I don't see how that could be of any influence. I have tried everything I could find online, but I can't find any solution.


Anybody who could help me, I have been stuck for almost a whole day on this now?

This is the error I get when running it in debug mode:
Quote
Unhandled exception at 0x00007FFEC332A1CB (ucrtbased.dll) in OnlineSpikes.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

I am using Visual Studio 2017. and using SFML 2.5.1



Below are the library dependencies I have:

« Last Edit: June 23, 2021, 09:16:54 am by taliebram »

kojack

  • Sr. Member
  • ****
  • Posts: 343
  • C++/C# game dev teacher.
    • View Profile
Re: Code crashes upon using font.loadFromFile
« Reply #1 on: June 22, 2021, 08:40:49 pm »
You have only a single back slash between src and Roboto.
A single backslash will attach to the next character (the R) and change it, so the name is invalid.

taliebram

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Code crashes upon using font.loadFromFile
« Reply #2 on: June 23, 2021, 09:21:16 am »
Oh that was a mistype from me, but I already tried about all input configurations (I changed the screenshot).

 The code also just instantly crashes, and you would expect the code just to continue, it does not matter what kind of input I give the font.loadFromFile() function. I did do some reading and everyone who had the same problem could fix it by using the correct dependencies, but I am already doing that (I think, see first screenshot).

So I do not know what to do, anybody who can help me?

taliebram

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Code crashes upon using font.loadFromFile
« Reply #3 on: June 23, 2021, 11:51:11 am »
I do not know what the problem is, but for now I bypassed the loadingfromfile, by loading in form memory. This works fine, but now when I pass a std::string to text.setString() the program crashes. I also tried converting a std::string to a sf::string, which also resulted in a crash. It does not crash when it gets char arrays.

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: Code crashes upon using font.loadFromFile
« Reply #4 on: June 23, 2021, 01:19:36 pm »
i'm going to ask same thing expl0it3r always does:  ;D
what SFML package did you download? are you sure you downloaded the correct version for your architecture (64 / 32 bits)?
Visit my game site (and hopefully help funding it? )
Website | IndieDB

taliebram

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Code crashes upon using font.loadFromFile
« Reply #5 on: June 24, 2021, 09:36:47 am »
Yes, I even redownloaded it to make sure (2017 MVS 64 bit version), but still did not fix the problem. However, I did bypass it by using the loadfromMemory, and apparently the setString() does work with c strings, so I made it work.

Doesn't seem like a long term solution, but my relatively simple program is almost finished so I am also less inclined to stop looking for a solution.
« Last Edit: June 24, 2021, 10:48:06 am by taliebram »

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: Code crashes upon using font.loadFromFile
« Reply #6 on: June 24, 2021, 12:37:20 pm »
well, that doesn't seems like a solution.
maybe we can help if you put the code.
and does it work when loading textures from file?
Visit my game site (and hopefully help funding it? )
Website | IndieDB

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Code crashes upon using font.loadFromFile
« Reply #7 on: June 24, 2021, 01:01:51 pm »
i'm going to ask same thing expl0it3r always does:  ;D
what SFML package did you download? are you sure you downloaded the correct version for your architecture (64 / 32 bits)?
Hehe, that's a good hint ;)

Even though you said, you downloaded the 64bit version, are you also using the 64 compiler in Visual Studio?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

taliebram

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Code crashes upon using font.loadFromFile
« Reply #8 on: June 25, 2021, 01:50:59 pm »
I'm fairly new to c++ and MVS, but I assume I am if these are enabled:



eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Code crashes upon using font.loadFromFile
« Reply #9 on: June 25, 2021, 03:55:30 pm »
Please provide the verbose built output: https://www.sfml-dev.org/faq.php#tr-grl-verbose-ide
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything