Interestingly enough, if I just load from local file into a byte array, I get the same result. You can clearly see the scope in this example.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SFML;
using SFML.Graphics;
namespace MInimalExample
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Press ESC key to close window");
var window = new SimpleWindow();
window.Run();
Console.WriteLine("All done");
}
}
class SimpleWindow
{
public void Run()
{
byte[] bytes = System.IO.File.ReadAllBytes("FLAPHEAD.TTF");
Font font = new Font(bytes);
Text text = new Text("Hello, World", font);
var mode = new SFML.Window.VideoMode(800, 600);
var window = new SFML.Graphics.RenderWindow(mode, "SFML works!");
window.Closed += Window_Closed;
// Start the game loop
while (window.IsOpen)
{
window.Clear();
// Process events
window.DispatchEvents();
text.DisplayedString = $"Hi {DateTime.Now}";
window.Draw(text);
// Finally, display the rendered frame on screen
window.Display();
}
}
private void Window_Closed(object sender, EventArgs e)
{
var window = (SFML.Window.Window)sender;
window.Close();
}
}
}