From 1120f68e9329fa405c55634481a3a2e973271a83 Mon Sep 17 00:00:00 2001 From: MasterGordon Date: Wed, 5 Oct 2022 15:18:52 +0200 Subject: [PATCH] made font protable --- src/entities/UI.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/entities/UI.cs b/src/entities/UI.cs index 5197323..9c93d8d 100644 --- a/src/entities/UI.cs +++ b/src/entities/UI.cs @@ -1,6 +1,5 @@ using static SDL2.SDL_ttf; using static SDL2.SDL; -using System.Runtime.InteropServices; class UI : Renderable { @@ -9,7 +8,15 @@ class UI : Renderable public UI() { 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)