Add font ranges
This commit is contained in:
parent
52172d3d73
commit
38ea69977c
28
MainUI.cs
28
MainUI.cs
|
@ -1,5 +1,6 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
using Raylib_cs;
|
||||||
|
|
||||||
namespace Shoko;
|
namespace Shoko;
|
||||||
|
|
||||||
|
@ -37,16 +38,28 @@ static class MainUI
|
||||||
ImGui.StyleColorsDark();
|
ImGui.StyleColorsDark();
|
||||||
io.ConfigFlags |= ImGuiConfigFlags.DockingEnable;
|
io.ConfigFlags |= ImGuiConfigFlags.DockingEnable;
|
||||||
|
|
||||||
|
nint fontrange;
|
||||||
|
ImFontGlyphRangesBuilderPtr builder;
|
||||||
|
unsafe {
|
||||||
|
fixed(ushort* chars = new ushort[]{1, 0xffff, 0})
|
||||||
|
fontrange = new nint(chars);
|
||||||
|
builder = new ImFontGlyphRangesBuilderPtr(ImGuiNative.ImFontGlyphRangesBuilder_ImFontGlyphRangesBuilder());
|
||||||
|
}
|
||||||
|
builder.AddRanges(fontrange);
|
||||||
|
builder.BuildRanges(out ImVector ranges);
|
||||||
|
|
||||||
AddFontFromResource("RobotoFlex.ttf", (buf, len)=>{
|
AddFontFromResource("RobotoFlex.ttf", (buf, len)=>{
|
||||||
Font = io.Fonts.AddFontFromMemoryTTF(buf, len, 16f);
|
Font = io.Fonts.AddFontFromMemoryTTF(buf, len, 16f, null, ranges.Data);
|
||||||
HeadingFonts.Add(io.Fonts.AddFontFromMemoryTTF(buf, len, 32f));
|
HeadingFonts.Add(io.Fonts.AddFontFromMemoryTTF(buf, len, 32f, null, ranges.Data));
|
||||||
HeadingFonts.Add(io.Fonts.AddFontFromMemoryTTF(buf, len, 24f));
|
HeadingFonts.Add(io.Fonts.AddFontFromMemoryTTF(buf, len, 24f, null, ranges.Data));
|
||||||
HeadingFonts.Add(io.Fonts.AddFontFromMemoryTTF(buf, len, 20f));
|
HeadingFonts.Add(io.Fonts.AddFontFromMemoryTTF(buf, len, 20f, null, ranges.Data));
|
||||||
});
|
});
|
||||||
AddFontFromResource("RobotoMono.ttf", (buf, len)=>{
|
AddFontFromResource("RobotoMono.ttf", (buf, len)=>{
|
||||||
MonospaceFont = io.Fonts.AddFontFromMemoryTTF(buf, len, 16f);
|
MonospaceFont = io.Fonts.AddFontFromMemoryTTF(buf, len, 16f, null, ranges.Data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
io.Fonts.Build();
|
||||||
|
|
||||||
if(args.Length > 0)
|
if(args.Length > 0)
|
||||||
foreach (var arg in args)
|
foreach (var arg in args)
|
||||||
NewTab(arg);
|
NewTab(arg);
|
||||||
|
@ -54,6 +67,11 @@ static class MainUI
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void PreRender()
|
||||||
|
{
|
||||||
|
Raylib.ClearBackground(Color.WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
public static bool Render()
|
public static bool Render()
|
||||||
{
|
{
|
||||||
bool quit = true;
|
bool quit = true;
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Program
|
||||||
while(!Raylib.WindowShouldClose() && quit)
|
while(!Raylib.WindowShouldClose() && quit)
|
||||||
{
|
{
|
||||||
Raylib.BeginDrawing();
|
Raylib.BeginDrawing();
|
||||||
Raylib.ClearBackground(Color.WHITE);
|
MainUI.PreRender();
|
||||||
rlImGui.Begin();
|
rlImGui.Begin();
|
||||||
|
|
||||||
quit = MainUI.Render();
|
quit = MainUI.Render();
|
||||||
|
|
Loading…
Reference in New Issue