mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-31 21:03:43 +01:00
Implement feature to use game resource fonts
This commit is contained in:
parent
b7c47b4c97
commit
f3588dfe23
9 changed files with 1137 additions and 2 deletions
35
Dalamud/Interface/GameFonts/GameFontHandle.cs
Normal file
35
Dalamud/Interface/GameFonts/GameFontHandle.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue