Overview
TheIFontHandle interface represents a reference counting handle for fonts. It allows you to safely use fonts across different threads and ensures proper lifecycle management.
Namespace: Dalamud.Interface.ManagedFontAtlas
Assembly: Dalamud.dll
Events
Called when the built instance of
ImFontPtr has been changed.Delegate signature:This event can be invoked outside the main thread.
Properties
Gets the load exception, if it failed to load. Otherwise, it is
null.Gets a value indicating whether this font is ready for use.Use
Push() directly if you want to keep the current ImGui font if the font is not ready.Alternatively, use WaitAsync() to wait for this property to become true.Methods
Attempts to lock the fully constructed instance of
ImFontPtr corresponding to this IFontHandle, for use in any thread.Parameters:errorMessage(out string?) - The error message, if any.
ILockedImFont that must be disposed after use on success; null with errorMessage populated on failure.Locks the fully constructed instance of
ImFontPtr corresponding to this IFontHandle, for use in any thread.Returns: An instance of ILockedImFont that must be disposed after use.Throws: InvalidOperationException if Available is false.Calling
IFontHandle.Dispose() will not unlock the ImFontPtr locked by this function.Pushes the current font into ImGui font stack, if available.Use
ImGui.GetFont() to access the current font. You may not access the font once you dispose this object.Returns: A disposable object that will pop the font on dispose.Throws: InvalidOperationException if called outside the main thread.This function uses ImGui.PushFont(ImFontPtr), and may do extra things. Use IDisposable.Dispose() or Pop() to undo this operation. Do not use ImGui.PopFont().Pops the font pushed to ImGui using
Push(), cleaning up any extra information as needed.Waits for
Available to become true.Parameters (overload):cancellationToken(CancellationToken) - The cancellation token.
IFontHandle.Usage Example
Related Types
ILockedImFont
The wrapper forImFontPtr, guaranteeing that the associated data will be available as long as this struct is not disposed.
Properties:
ImFont(ImFontPtr) - Gets the associatedImFontPtr.
NewRef()- Creates a new instance ofILockedImFontwith an additional reference to the owner.
See Also
- IUiBuilder - UI builder interface
- Font Atlas Documentation - Guide on using fonts in Dalamud