Загрузка пользовательского TTF-шрифта из ресурсов

Как загрузить пользовательский TTF-шрифт из встроенных ресурсов.

Импортируйте отсюда: https://eyeauras.net/share/S20251017150828zhuomztM9lbi

Загрузка шрифта в ImGui через embedded resources

В этом примере мы загружаем шрифт Roboto в ImGui с помощью embedded resources.

Example of embedded resource

Imgui with updated font

csharp
#r "nuget:EyeAuras.ImGuiSdk, 0.1.17" //EyeAuras v8825+ is required

using EyeAuras.ImGuiSdk; //root ImGuiSdk namespace needed to add registrations (see below)
using ImGuiNET; //that namespace is needed to get access to ImGui itself

var osd = GetService<IImGuiExperimentalApi>() //create ImGui API - this will show empty OSD
    .AddTo(ExecutionAnchors); //ensure that you'll hide OSD when script stops or gets stopped

var fontData = GetService<IScriptFileProvider>()
    .ReadAllBytes("Roboto-Regular.ttf"); //loading font data from resources

osd.AddFontFromMemoryTTF(fontData); //loading the font itself

osd.AddRenderer(() =>
{
    //this method will be called many-many times per second
    //you can put any logic here
    ImGui.ShowDemoWindow();
});

//wait until script stops or gets stopped
cancellationToken.WaitHandle.WaitOne();