Interface IFontHandle
Represents a reference counting handle for fonts.
Not intended for plugins to implement.
Assembly: Dalamud.dll​
public interface IFontHandle : IDisposable
Properties​
LoadException​
Gets the load exception, if it failed to load. Otherwise, it is null.
Exception? LoadException { get; }
Available​
Gets a value indicating whether this font is ready for use.
bool Available { get; }
Remarks​
Use Dalamud.Interface.ManagedFontAtlas.IFontHandle.Push() directly if you want to keep the current ImGui font if the font is not ready.
Alternatively, use Dalamud.Interface.ManagedFontAtlas.IFontHandle.WaitAsync() to wait for this property to become true.
Methods​
TryLock(out string?)​
Attempts to lock the fully constructed instance of Dalamud.Bindings.ImGui.ImFontPtr corresponding to the this
Dalamud.Interface.ManagedFontAtlas.IFontHandle, for use in any thread.
Modification of the font will exhibit undefined behavior if some other thread also uses the font.
ILockedImFont? TryLock(out string? errorMessage)
Returns​
Dalamud.Interface.ManagedFontAtlas.ILockedImFont: An instance of Dalamud.Interface.ManagedFontAtlas.ILockedImFont that must be disposed after use on success;
null with <code class="paramref">errorMessage</code> populated on failure.
Parameters​
| Type | Name | Description |
|---|---|---|
System.String | errorMessage | The error message, if any. |
Lock()​
Locks the fully constructed instance of Dalamud.Bindings.ImGui.ImFontPtr corresponding to the this
Dalamud.Interface.ManagedFontAtlas.IFontHandle, for use in any thread.
Modification of the font will exhibit undefined behavior if some other thread also uses the font.
ILockedImFont Lock()
Returns​
Dalamud.Interface.ManagedFontAtlas.ILockedImFont: An instance of Dalamud.Interface.ManagedFontAtlas.ILockedImFont that must be disposed after use.
Exceptions​
System.InvalidOperationException
If Dalamud.Interface.ManagedFontAtlas.IFontHandle.Available is false.
Remarks​
Calling Dalamud.Interface.ManagedFontAtlas.IFontHandle.System.IDisposable.Dispose will not unlock the Dalamud.Bindings.ImGui.ImFontPtr
locked by this function.
Push()​
Pushes the current font into ImGui font stack, if available.
Use Dalamud.Bindings.ImGui.ImGui.GetFont to access the current font.
You may not access the font once you dispose this object.
IDisposable Push()
Returns​
System.IDisposable: A disposable object that will pop the font on dispose.
Exceptions​
System.InvalidOperationException
If called outside the main thread.
Remarks​
<p>This function uses Dalamud.Bindings.ImGui.ImGui.PushFont(Dalamud.Bindings.ImGui.ImFontPtr), and may do extra things.
Use System.IDisposable.Dispose or Dalamud.Interface.ManagedFontAtlas.IFontHandle.Pop() to undo this operation.
Do not use Dalamud.Bindings.ImGui.ImGui.PopFont.</p>
Examples​
Push a font with using clause.
using (fontHandle.Push())
ImGui.Text("Test"u8);
Push a font with a matching call to Dalamud.Interface.ManagedFontAtlas.IFontHandle.Pop().
fontHandle.Push();
ImGui.Text("Test 2"u8);
fontHandle.Pop();
Push a font between two choices.
using ((someCondition ? myFontHandle : dalamudPluginInterface.UiBuilder.MonoFontHandle).Push())
ImGui.Text("Test 3"u8);
Pop()​
Pops the font pushed to ImGui using Dalamud.Interface.ManagedFontAtlas.IFontHandle.Push(), cleaning up any extra information as needed.
void Pop()
WaitAsync()​
Waits for Dalamud.Interface.ManagedFontAtlas.IFontHandle.Available to become true.
Task<IFontHandle> WaitAsync()
Returns​
System.Threading.Tasks.Task<Dalamud.Interface.ManagedFontAtlas.IFontHandle>: A task containing this Dalamud.Interface.ManagedFontAtlas.IFontHandle.
WaitAsync(CancellationToken)​
Waits for Dalamud.Interface.ManagedFontAtlas.IFontHandle.Available to become true.
Task<IFontHandle> WaitAsync(CancellationToken cancellationToken)
Returns​
System.Threading.Tasks.Task<Dalamud.Interface.ManagedFontAtlas.IFontHandle>: A task containing this Dalamud.Interface.ManagedFontAtlas.IFontHandle.
Parameters​
| Type | Name | Description |
|---|---|---|
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Events​
ImFontChanged​
Called when the built instance of Dalamud.Bindings.ImGui.ImFontPtr has been changed.
This event can be invoked outside the main thread.
event IFontHandle.ImFontChangedDelegate ImFontChanged
Event Type​
Dalamud.Interface.ManagedFontAtlas.IFontHandle.ImFontChangedDelegate