made font protable

This commit is contained in:
MasterGordon 2022-10-05 15:18:52 +02:00
parent 942dbf3d99
commit 1120f68e93
1 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,5 @@
using static SDL2.SDL_ttf; using static SDL2.SDL_ttf;
using static SDL2.SDL; using static SDL2.SDL;
using System.Runtime.InteropServices;
class UI : Renderable class UI : Renderable
{ {
@ -9,7 +8,15 @@ class UI : Renderable
public UI() public UI()
{ {
TTF_Init(); TTF_Init();
this.font = SDL2.SDL_ttf.TTF_OpenFont("/home/gordon/git/dotnet-console/assets/font.ttf", 18); var assemblyName = this.GetType().Assembly.GetName().Name!;
var fontStream = this.GetType().Assembly.GetManifestResourceStream($"{assemblyName}.assets.font.ttf");
var fontFile = System.IO.Path.GetTempPath() + "asdlteroids-font.ttf";
using (var fileStream = System.IO.File.Create(fontFile))
{
fontStream!.CopyTo(fileStream);
}
this.font = SDL2.SDL_ttf.TTF_OpenFont(fontFile, 18);
} }
public void Render(Renderer renderer, double dx) public void Render(Renderer renderer, double dx)