Skip to content

Commit

Permalink
Add ProggyClean as resizable font;
Browse files Browse the repository at this point in the history
  • Loading branch information
onepiecefreak3 committed Sep 29, 2024
1 parent 96273f8 commit 1c03889
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
20 changes: 18 additions & 2 deletions ImGui.Forms/Factories/FontFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@

namespace ImGui.Forms.Factories
{
public class FontFactory
public static class FontFactory
{
private const string DefaultFontName_ = "ProggyClean";
private const string DefaultFontResourceName_ = "ProggyClean.ttf";

private static readonly Dictionary<string, FontMetaData> _fontCache = new();
private static readonly Dictionary<FontData, ImFontPtr> _fontPointers = new();

private static readonly Queue<FontData> _fontRegistrationQueue = new();

private FontFactory() { }
static FontFactory()
{
RegisterFromResource(DefaultFontName_, Assembly.GetExecutingAssembly(), DefaultFontResourceName_, FontGlyphRange.Latin);
}

#region Registration

Expand Down Expand Up @@ -60,6 +66,16 @@ public static void RegisterFromResource(string name, Assembly assembly, string r

#region Get fonts

public static FontResource GetDefault(int size, FontResource fallbackFont)
{
return Get(DefaultFontName_, size, fallbackFont);
}

public static FontResource GetDefault(int size)
{
return Get(DefaultFontName_, size);
}

public static FontResource Get(string name, int size, FontResource fallbackFont)
{
// If font with that name is already loaded, return
Expand Down
4 changes: 4 additions & 0 deletions ImGui.Forms/ImGui.Forms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
</PropertyGroup>

<ItemGroup>
<None Remove="Resources\Fonts\ProggyClean.ttf" />
<None Remove="Resources\Images\error.png" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\Fonts\ProggyClean.ttf">
<LogicalName>ProggyClean.ttf</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="Resources\Images\error.png">
<LogicalName>error.png</LogicalName>
</EmbeddedResource>
Expand Down
2 changes: 1 addition & 1 deletion ImGui.Forms/ImGui.Forms.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Imgui.Forms</id>
<version>1.1.0</version>
<version>1.1.1</version>
<description>A WinForms-inspired object-oriented framework around Dear ImGui (https://github.com/ocornut/imgui)</description>

<authors>onepiecefreak</authors>
Expand Down
Binary file added ImGui.Forms/Resources/Fonts/ProggyClean.ttf
Binary file not shown.

0 comments on commit 1c03889

Please sign in to comment.