Implement feature to use game resource fonts

This commit is contained in:
Soreepeong 2022-02-24 18:56:34 +09:00
parent b7c47b4c97
commit f3588dfe23
9 changed files with 1137 additions and 2 deletions

View file

@ -0,0 +1,35 @@
using System;
using ImGuiNET;
namespace Dalamud.Interface.GameFonts
{
/// <summary>
/// Prepare and keep game font loaded for use in OnDraw.
/// </summary>
public class GameFontHandle : IDisposable
{
private readonly GameFontManager manager;
private readonly GameFont font;
/// <summary>
/// Initializes a new instance of the <see cref="GameFontHandle"/> class.
/// </summary>
/// <param name="manager">GameFontManager instance.</param>
/// <param name="font">Font to use.</param>
internal GameFontHandle(GameFontManager manager, GameFont font)
{
this.manager = manager;
this.font = font;
}
/// <summary>
/// Gets the font.
/// </summary>
/// <returns>Corresponding font or null.</returns>
public ImFontPtr? Get() => this.manager.GetFont(this.font);
/// <inheritdoc/>
public void Dispose() => this.manager.DecreaseFontRef(this.font);
}
}