Skip to main content
Version: 14.x (API 14) [Legacy]

Struct SafeFontConfig

Managed version of Dalamud.Bindings.ImGui.ImFontConfig, to avoid unnecessary heap allocation and use of unsafe blocks.

Assembly: Dalamud.dll
Declaration
public struct SafeFontConfig

Properties

FontNo

Gets or sets the font face index within a TrueType Collection (TTC) file.

Declaration
public int FontNo { get; set; }
Remarks

This property only applies to Dalamud.DalamudAsset.NotoSansCjkRegular and Dalamud.DalamudAsset.NotoSansCjkMedium, which are TTC fonts bundling multiple language-specific CJK glyph sets (Japanese, Traditional Chinese, Simplified Chinese, Korean) into a single file.

The index corresponds to the font face order in the TTC:

<ul><li>0 = Japanese</li><li>1 = Traditional Chinese</li><li>2 = Simplified Chinese</li><li>3 = Korean</li></ul>

This value is ignored for all other Dalamud.DalamudAsset entries. Only one glyph set can be active at a time. In most cases, you can omit this— Dalamud automatically selects the appropriate face based on the UI language.

SizePx

Gets or sets the desired size of the new font, in pixels.

Effectively, this is the line height.

Value is tied with Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.SizePt.

Declaration
public float SizePx { get; set; }

SizePt

Gets or sets the desired size of the new font, in points.

Effectively, this is the line height.

Value is tied with Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.SizePx.

Declaration
public float SizePt { get; set; }

OversampleH

Gets or sets the horizontal oversampling pixel count.

Rasterize at higher quality for sub-pixel positioning.

Note the difference between 2 and 3 is minimal so you can reduce this to 2 to save memory.

Read https://github.com/nothings/stb/blob/master/tests/oversample/README.md for details.

Declaration
public int OversampleH { get; set; }

OversampleV

Gets or sets the vertical oversampling pixel count.

Rasterize at higher quality for sub-pixel positioning.

This is not really useful as we don't use sub-pixel positions on the Y axis.

Declaration
public int OversampleV { get; set; }

PixelSnapH

Gets or sets a value indicating whether to align every glyph to pixel boundary.

Useful e.g. if you are merging a non-pixel aligned font with the default font.

If enabled, you can set Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.OversampleH and Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.OversampleV to 1.

Declaration
public bool PixelSnapH { get; set; }

GlyphExtraSpacing

Gets or sets the extra spacing (in pixels) between glyphs.

Only X axis is supported for now.

Effectively, it is the letter spacing.

Declaration
public Vector2 GlyphExtraSpacing { get; set; }

GlyphOffset

Gets or sets the offset all glyphs from this font input.

Use this to offset fonts vertically when merging multiple fonts.

Declaration
public Vector2 GlyphOffset { get; set; }

GlyphRanges

Gets or sets the glyph ranges, which is a user-provided list of Unicode range. Each range has 2 values, and values are inclusive.

The list must be zero-terminated.

If empty or null, then all the glyphs from the font that is in the range of UCS-2 will be added.

Declaration
public ushort[]? GlyphRanges { readonly get; set; }

GlyphMinAdvanceX

Gets or sets the minimum AdvanceX for glyphs.

Set only Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.GlyphMinAdvanceX to align font icons.

Set both Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.GlyphMinAdvanceX/Dalamud.Interface.ManagedFontAtlas.SafeFontConfig.GlyphMaxAdvanceX to enforce mono-space font.

Declaration
public float GlyphMinAdvanceX { get; set; }

GlyphMaxAdvanceX

Gets or sets the maximum AdvanceX for glyphs.

Declaration
public float GlyphMaxAdvanceX { get; set; }

RasterizerMultiply

Gets or sets a value that either brightens (>1.0f) or darkens (<1.0f) the font output.

Brightening small fonts may be a good workaround to make them more readable.

Declaration
public float RasterizerMultiply { get; set; }

RasterizerGamma

Gets or sets the gamma value for fonts.

Declaration
public float RasterizerGamma { get; set; }

EllipsisChar

Gets or sets a value explicitly specifying unicode codepoint of the ellipsis character.

When fonts are being merged first specified ellipsis will be used.

Declaration
public char EllipsisChar { get; set; }

Name

Gets or sets the desired name of the new font. Names longer than 40 bytes will be partially lost.

Declaration
public string Name { get; set; }

MergeFont

Gets or sets the desired font to merge with, if set.

Declaration
public ImFontPtr MergeFont { get; set; }

Fields

Raw

The raw config.

Declaration
public ImFontConfigPtr Raw

Methods

ThrowOnInvalidValues()

Throws System.ArgumentException with appropriate messages, if this Dalamud.Interface.ManagedFontAtlas.SafeFontConfig has invalid values.

Declaration
public readonly void ThrowOnInvalidValues()