Failed to load font (failed to create the font face)
Говорить в принципе не о чем. Логи:
Warning: Detected "Microsoft Corporation GDI Generic" OpenGL implementation
The current OpenGL implementation is not hardware-accelerated
Warning: The created OpenGL context does not fully meet the settings that were requested
Requested: version = 2.0 ; depth bits = 0 ; stencil bits = 0 ; AA level = 0 ; core = false ; debug = false ; sRGB = false
Created: version = 1.1 ; depth bits = 16 ; stencil bits = 8 ; AA level = 0 ; core = false ; debug = false ; sRGB = false
Setting vertical sync not supported
OpenGL extension SGIS_texture_edge_clamp unavailable
Artifacts may occur along texture edges
Ensure that hardware acceleration is enabled if available
Failed to load font "./resources/Roboto-Regular.ttf" (failed to create the font face)
Unhandled exception. SFML.LoadingFailedException: Failed to load font from file ./resources/Roboto-Regular.ttf
at SFML.Graphics.Font..ctor(String filename)
at reEngine.Platform.Rendering.RenderText.Start(RenderWindow window, String fontFile, String text, UInt32 fontSize, Color color, Single width, Single height, Single x, Single y) in E:\reEngine\reEngine.Platform\Rendering\RenderText.cs:line 10
at reEngine.Debug.Program.Main(String[] args) in E:\reEngine\reEngine Debug\Program.cs:line 16
Код: Program.cs
using reEngine.Platform;
using reEngine.Platform.Rendering;
using SFML.Graphics;
namespace reEngine.Debug;
class Program()
{
static void Main(string[] args)
{
RenderWindow window = Window.Create(600, 800, "reEngine Debug App");
while(window.IsOpen)
{
window.DispatchEvents();
RenderSolidBackground.Start(window, Color.Blue);
RenderText.Start(window, "./resources/Roboto-Regular.ttf", "Hello World!", 30, Color.White, 100, 100, 0f, 0f);
window.Display();
}
}
}
Window.cs
using SFML.Graphics;
using SFML.Window;
namespace reEngine.Platform;
public class Window
{
public static RenderWindow Create(uint width, uint height, string title)
{
VideoMode mode = new VideoMode(width, height);
RenderWindow window = new RenderWindow(mode, title);
window.Closed += (sender, args) => window.Close();
return window;
}
}
RenderText.cs
using SFML.Graphics;
using SFML.System;
namespace reEngine.Platform.Rendering;
public class RenderText
{
public static void Start(RenderWindow window, string fontFile, string text, uint fontSize, Color color,float width, float height, float x, float y) {
Font font = new Font(fontFile);
Text textVar = new Text("Hello World!", font) {CharacterSize = fontSize, FillColor = color};
float textWidth = width;
float textHeight = height;
float xOffset = x;
float yOffset = y;
textVar.Origin = new Vector2f(textWidth / 2f + xOffset, textHeight / 2f + yOffset);
textVar.Position = new Vector2f(window.Size.X / 2f, window.Size.Y / 2f);
window.Draw(textVar);
}
}