Skip to main content
Version: 15.x (API 15) [Current]

Interface IFontAtlasBuildToolkitPreBuild

Toolkit for use when the build state is Dalamud.Interface.ManagedFontAtlas.FontAtlasBuildStep.PreBuild.

Not intended for plugins to implement.

After Dalamud.Interface.ManagedFontAtlas.FontAtlasBuildStepDelegate returns, either Dalamud.Interface.ManagedFontAtlas.IFontAtlasBuildToolkit.Font must be set, or at least one font must have been added to the atlas using one of AddFont... functions.

Assembly: Dalamud.dll​
Declaration
public interface IFontAtlasBuildToolkitPreBuild : IFontAtlasBuildToolkit

Methods​

DisposeAfterBuild<T>(T)​

Queues an item to be disposed after the whole build process gets complete, successful or not.

Declaration
T DisposeAfterBuild<T>(T disposable) where T : IDisposable
Returns​

<T>: The same <code class="paramref">disposable</code>.

Parameters​
TypeNameDescription
<T>disposableThe disposable.
Type Parameters​
NameDescription
TDisposable type.

DisposeAfterBuild(GCHandle)​

Queues an item to be disposed after the whole build process gets complete, successful or not.

Declaration
GCHandle DisposeAfterBuild(GCHandle gcHandle)
Returns​

System.Runtime.InteropServices.GCHandle: The same <code class="paramref">gcHandle</code>.

Parameters​
TypeNameDescription
System.Runtime.InteropServices.GCHandlegcHandleThe gc handle.

DisposeAfterBuild(Action)​

Queues an item to be disposed after the whole build process gets complete, successful or not.

Declaration
void DisposeAfterBuild(Action action)
Parameters​
TypeNameDescription
System.ActionactionThe action to run on dispose.

SetFontScaleMode(ImFontPtr, FontScaleMode)​

Sets the scaling mode for the given font.

Declaration
ImFontPtr SetFontScaleMode(ImFontPtr fontPtr, FontScaleMode mode)
Returns​

Dalamud.Bindings.ImGui.ImFontPtr: <code class="paramref">fontPtr</code>.

Parameters​
TypeNameDescription
Dalamud.Bindings.ImGui.ImFontPtrfontPtrThe font, returned from Dalamud.Interface.ManagedFontAtlas.IFontAtlasBuildToolkitPreBuild.AddFontFromFile(System.String,Dalamud.Interface.ManagedFontAtlas.SafeFontConfig@) and alike.
        Note that [Dalamud.Interface.ManagedFontAtlas.IFontAtlasBuildToolkit.Font](../../Dalamud.Interface.ManagedFontAtlas/Interfaces/IFontAtlasBuildToolkit.md#font) property is not guaranteed to be automatically updated upon
calling font adding functions. Pass the return value from font adding functions, not
[Dalamud.Interface.ManagedFontAtlas.IFontAtlasBuildToolkit.Font](../../Dalamud.Interface.ManagedFontAtlas/Interfaces/IFontAtlasBuildToolkit.md#font) property. |

| Dalamud.Interface.ManagedFontAtlas.FontScaleMode | mode | The scaling mode. |

GetFontScaleMode(ImFontPtr)​

Gets the scaling mode for the given font.

Declaration
FontScaleMode GetFontScaleMode(ImFontPtr fontPtr)
Returns​

Dalamud.Interface.ManagedFontAtlas.FontScaleMode: The scaling mode.

Parameters​
TypeNameDescription
Dalamud.Bindings.ImGui.ImFontPtrfontPtrThe font.

RegisterPostBuild(Action)​

Registers a function to be run after build.

Declaration
void RegisterPostBuild(Action action)
Parameters​
TypeNameDescription
System.ActionactionThe action to run.

AddFontFromImGuiHeapAllocatedMemory(nint, int, in SafeFontConfig, bool, string)​

Adds a font from memory region allocated using Dalamud.Interface.Utility.ImGuiHelpers.AllocateMemory(nuint).

It WILL crash if you try to use a memory pointer allocated in some other way.

** Do NOT call Dalamud.Bindings.ImGui.ImGui.MemFree(System.Void*) on the <code class="paramref">dataPointer</code> once this function has been called, unless <code class="paramref">freeOnException</code> is set and the function has thrown an error. **

Declaration
ImFontPtr AddFontFromImGuiHeapAllocatedMemory(nint dataPointer, int dataSize, in SafeFontConfig fontConfig, bool freeOnException, string debugTag)
Returns​

Dalamud.Bindings.ImGui.ImFontPtr: The newly added font.

Parameters​
TypeNameDescription
System.IntPtrdataPointerMemory address for the data allocated using Dalamud.Interface.Utility.ImGuiHelpers.AllocateMemory(nuint).
System.Int32dataSizeThe size of the font file.
Dalamud.Interface.ManagedFontAtlas.SafeFontConfigfontConfigThe font config.
System.BooleanfreeOnExceptionFree <code class="paramref">dataPointer</code> if an exception happens.
System.StringdebugTagA debug tag.

AddFontFromImGuiHeapAllocatedMemory(void*, int, in SafeFontConfig, bool, string)​

Adds a font from memory region allocated using Dalamud.Interface.Utility.ImGuiHelpers.AllocateMemory(nuint).

It WILL crash if you try to use a memory pointer allocated in some other way.

** Do NOT call Dalamud.Bindings.ImGui.ImGui.MemFree(System.Void*) on the <code class="paramref">dataPointer</code> once this function has been called, unless <code class="paramref">freeOnException</code> is set and the function has thrown an error. **

Declaration
ImFontPtr AddFontFromImGuiHeapAllocatedMemory(void* dataPointer, int dataSize, in SafeFontConfig fontConfig, bool freeOnException, string debugTag)
Returns​

Dalamud.Bindings.ImGui.ImFontPtr: The newly added font.

Parameters​
TypeNameDescription
System.Void*dataPointerMemory address for the data allocated using Dalamud.Interface.Utility.ImGuiHelpers.AllocateMemory(nuint).
System.Int32dataSizeThe size of the font file.
Dalamud.Interface.ManagedFontAtlas.SafeFontConfigfontConfigThe font config.
System.BooleanfreeOnExceptionFree <code class="paramref">dataPointer</code> if an exception happens.
System.StringdebugTagA debug tag.

AddFontFromFile(string, in SafeFontConfig)​

Adds a font from a file.

Declaration
ImFontPtr AddFontFromFile(string path, in SafeFontConfig fontConfig)
Returns​

Dalamud.Bindings.ImGui.ImFontPtr: The newly added font.

Parameters​
TypeNameDescription
System.StringpathThe file path to create a new font from.
Dalamud.Interface.ManagedFontAtlas.SafeFontConfigfontConfigThe font config.

AddFontFromStream(Stream, in SafeFontConfig, bool, string)​

Adds a font from a stream.

Declaration
ImFontPtr AddFontFromStream(Stream stream, in SafeFontConfig fontConfig, bool leaveOpen, string debugTag)
Returns​

Dalamud.Bindings.ImGui.ImFontPtr: The newly added font.

Parameters​
TypeNameDescription
System.IO.StreamstreamThe stream to create a new font from.
Dalamud.Interface.ManagedFontAtlas.SafeFontConfigfontConfigThe font config.
System.BooleanleaveOpenDispose when this function returns or throws.
System.StringdebugTagA debug tag.

AddFontFromMemory(ReadOnlySpan<byte>, in SafeFontConfig, string)​

Adds a font from memory.

Declaration
ImFontPtr AddFontFromMemory(ReadOnlySpan<byte> span, in SafeFontConfig fontConfig, string debugTag)
Returns​

Dalamud.Bindings.ImGui.ImFontPtr: The newly added font.

Parameters​
TypeNameDescription
System.ReadOnlySpan<System.Byte>spanThe span to create from.
Dalamud.Interface.ManagedFontAtlas.SafeFontConfigfontConfigThe font config.
System.StringdebugTagA debug tag.

AddDalamudDefaultFont(float, ushort[]?)​

Adds the default font known to the current font atlas.

Includes Dalamud.Interface.ManagedFontAtlas.IFontAtlasBuildToolkitPreBuild.AddFontAwesomeIconFont(Dalamud.Interface.ManagedFontAtlas.SafeFontConfig@) and Dalamud.Interface.ManagedFontAtlas.IFontAtlasBuildToolkitPreBuild.AttachExtraGlyphsForDalamudLanguage(Dalamud.Interface.ManagedFontAtlas.SafeFontConfig@).

As this involves adding multiple fonts, calling this function will set Dalamud.Interface.ManagedFontAtlas.IFontAtlasBuildToolkit.Font as the return value of this function, if it was empty before.

Declaration
ImFontPtr AddDalamudDefaultFont(float sizePx, ushort[]? glyphRanges = null)
Returns​

Dalamud.Bindings.ImGui.ImFontPtr: A font returned from Dalamud.Bindings.ImGui.ImFontAtlasPtr.AddFont(Dalamud.Bindings.ImGui.ImFontConfig*).

Parameters​
TypeNameDescription
System.SinglesizePxFont size in pixels.
If a negative value is supplied,
(Dalamud.Interface.UiBuilder.DefaultFontSpec.Dalamud.Interface.FontIdentifier.IFontSpec.SizePx * <code class="paramref">sizePx</code>) will be
used as the font size. Specify -1 to use the default font size.
System.UInt16[]glyphRangesThe glyph ranges. Use Dalamud.Interface.ManagedFontAtlas.FontAtlasBuildToolkitUtilities.ToGlyphRange to build.

AddDalamudAssetFont(DalamudAsset, in SafeFontConfig)​

Adds a font that is shipped with Dalamud.

Note: if game symbols font file is requested but is unavailable, then it will take the glyphs from game's built-in fonts, and everything in <code class="paramref">fontConfig</code> will be ignored but Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.SizePx, Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.MergeFont, and Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.GlyphRanges.

Declaration
ImFontPtr AddDalamudAssetFont(DalamudAsset asset, in SafeFontConfig fontConfig)
Returns​

Dalamud.Bindings.ImGui.ImFontPtr: The added font.

Parameters​
TypeNameDescription
Dalamud.DalamudAssetassetThe font type.
Dalamud.Interface.ManagedFontAtlas.SafeFontConfigfontConfigThe font config.

AddFontAwesomeIconFont(in SafeFontConfig)​

Same with Dalamud.Interface.ManagedFontAtlas.IFontAtlasBuildToolkitPreBuild.AddDalamudAssetFont(Dalamud.DalamudAsset,Dalamud.Interface.ManagedFontAtlas.SafeFontConfig@)(Dalamud.DalamudAsset.FontAwesomeFreeSolid, ...), but using only FontAwesome icon ranges.

Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.GlyphRanges will be ignored.

Declaration
ImFontPtr AddFontAwesomeIconFont(in SafeFontConfig fontConfig)
Returns​

Dalamud.Bindings.ImGui.ImFontPtr: The added font.

Parameters​
TypeNameDescription
Dalamud.Interface.ManagedFontAtlas.SafeFontConfigfontConfigThe font config.

AddGameSymbol(in SafeFontConfig)​

Adds the game's symbols into the provided font.

Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.GlyphRanges will be ignored.

If the game symbol font file is unavailable, only Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.SizePx will be honored.

Declaration
ImFontPtr AddGameSymbol(in SafeFontConfig fontConfig)
Returns​

Dalamud.Bindings.ImGui.ImFontPtr: The added font.

Parameters​
TypeNameDescription
Dalamud.Interface.ManagedFontAtlas.SafeFontConfigfontConfigThe font config.

AddGameGlyphs(GameFontStyle, ushort[]?, ImFontPtr)​

Adds the game glyphs to the font.

Declaration
ImFontPtr AddGameGlyphs(GameFontStyle gameFontStyle, ushort[]? glyphRanges, ImFontPtr mergeFont)
Returns​

Dalamud.Bindings.ImGui.ImFontPtr: The added font.

Parameters​
TypeNameDescription
Dalamud.Interface.GameFonts.GameFontStylegameFontStyleThe font style.
System.UInt16[]glyphRangesThe glyph ranges.
Dalamud.Bindings.ImGui.ImFontPtrmergeFontThe font to merge to. If empty, then a new font will be created.

AttachWindowsDefaultFont(CultureInfo, in SafeFontConfig, int, int, int)​

Adds glyphs from the Windows default font for the given culture info into the provided font.

Declaration
void AttachWindowsDefaultFont(CultureInfo cultureInfo, in SafeFontConfig fontConfig, int weight = 400, int stretch = 5, int style = 0)
Parameters​
TypeNameDescription
System.Globalization.CultureInfocultureInfoThe culture info.
Dalamud.Interface.ManagedFontAtlas.SafeFontConfigfontConfigThe font config. If Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.MergeFont is not set, then
        [Dalamud.Interface.ManagedFontAtlas.IFontAtlasBuildToolkit.Font](../../Dalamud.Interface.ManagedFontAtlas/Interfaces/IFontAtlasBuildToolkit.md#font) will be used as the target. If that is empty too, then it will do
nothing. |

| System.Int32 | weight | The font weight, in range from 1 to 1000. 400 is regular(normal). | | System.Int32 | stretch | The font stretch, in range from 1 to 9. 5 is medium(normal). | | System.Int32 | style | The font style, in range from 0 to 2. 0 is normal. |

Remarks​

<p>May do nothing at all if <code class="paramref">cultureInfo</code> is unsupported by Dalamud font handler.</p> <p>See <a href="https://learn.microsoft.com/en-us/windows/apps/design/globalizing/loc-international-fonts"&gt;Microsoft Learn</a> for the fonts.</p>

AttachExtraGlyphsForDalamudLanguage(in SafeFontConfig)​

Adds glyphs of extra languages into the provided font, depending on Dalamud Configuration.

Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.GlyphRanges will be ignored.

Declaration
void AttachExtraGlyphsForDalamudLanguage(in SafeFontConfig fontConfig)
Parameters​
TypeNameDescription
Dalamud.Interface.ManagedFontAtlas.SafeFontConfigfontConfigThe font config. If Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.MergeFont is not set, then
        [Dalamud.Interface.ManagedFontAtlas.IFontAtlasBuildToolkit.Font](../../Dalamud.Interface.ManagedFontAtlas/Interfaces/IFontAtlasBuildToolkit.md#font) will be used as the target. If that is empty too, then it will do
nothing. |

Extension Methods​

  • Dalamud.Interface.ManagedFontAtlas.IFontAtlasBuildToolkit.Dalamud.Interface.ManagedFontAtlas.FontAtlasBuildToolkitUtilities.FindConfigPtr(Dalamud.Bindings.ImGui.ImFontPtr)
  • Dalamud.Interface.ManagedFontAtlas.IFontAtlasBuildToolkit.Dalamud.Interface.ManagedFontAtlas.FontAtlasBuildToolkitUtilities.OnPostBuild(System.Action{Dalamud.Interface.ManagedFontAtlas.IFontAtlasBuildToolkitPostBuild})
  • Dalamud.Interface.ManagedFontAtlas.IFontAtlasBuildToolkit.Dalamud.Interface.ManagedFontAtlas.FontAtlasBuildToolkitUtilities.OnPreBuild(System.Action{Dalamud.Interface.ManagedFontAtlas.IFontAtlasBuildToolkitPreBuild})