-1

Failed to load font "textures/myfont.tff" (failed to create the font face)

 Font font = new Font("textures/myfont.tff");
 menu[0].Style = Text.Styles.Bold;
 menu[0].Color = Color.Red;
 menu[0] = new Text("Play", font);
 menu[0].Position = new Vector2f(width / 2.0f, height / 2.0f);

I am pretty sure it is situated in good place because textures that I load occured similar problem and I've solved it by moving textures directory to other place. Is it possible that something is wrong with code or any other ideas?

  • Possible duplicate of [Loading a font directly from a file in C#](https://stackoverflow.com/questions/24022411/loading-a-font-directly-from-a-file-in-c-sharp) – PaulF Apr 25 '18 at 09:56
  • Hoping that Environment.CurrentDirectory is set correctly is always a mistake. Generate the full path of the file, c:\foo\bar\baz.ext. Use Path.Combine() and Assembly.GetEntryAssembly().Location to get the c:\foo\bar part of the name. – Hans Passant Apr 25 '18 at 10:55

1 Answers1

0

The file is not in the place you gave. Maybe because you have a different idea of where your current working directory is than your running executable. Test it by hard-coding the full path, it will work. Then work from there to make sure you have the correct relative path.

Sorry that this reply is short and somewhat unhelpful, but only you can figure out where on your disk the file is.

nvoigt
  • 75,013
  • 26
  • 93
  • 142