mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 12:23:39 +01:00
Add kerned text draw helper
This commit is contained in:
parent
17c77e6bfd
commit
3026eb6fa8
3 changed files with 468 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
|||
using System;
|
||||
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.GameFonts
|
||||
|
|
@ -43,7 +43,59 @@ namespace Dalamud.Interface.GameFonts
|
|||
/// </summary>
|
||||
public FdtReader FdtReader => this.manager.GetFdtReader(this.fontStyle.FamilyAndSize);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new GameFontLayoutPlan.Builder.
|
||||
/// </summary>
|
||||
/// <param name="text">Text.</param>
|
||||
/// <returns>A new builder for GameFontLayoutPlan.</returns>
|
||||
public GameFontLayoutPlan.Builder LayoutBuilder(string text)
|
||||
{
|
||||
return new GameFontLayoutPlan.Builder(this.ImFont, this.FdtReader, text);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose() => this.manager.DecreaseFontRef(this.fontStyle);
|
||||
|
||||
/// <summary>
|
||||
/// Draws text.
|
||||
/// </summary>
|
||||
/// <param name="text">Text to draw.</param>
|
||||
public void Text(string text)
|
||||
{
|
||||
if (!this.Available)
|
||||
{
|
||||
ImGui.TextUnformatted(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.LayoutBuilder(text)
|
||||
.Build()
|
||||
.Draw(ImGui.GetWindowDrawList(), ImGui.GetWindowPos() + ImGui.GetCursorPos(), ImGui.GetColorU32(ImGuiCol.Text));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws text in given color.
|
||||
/// </summary>
|
||||
/// <param name="col">Color.</param>
|
||||
/// <param name="text">Text to draw.</param>
|
||||
public void TextColored(Vector4 col, string text)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, col);
|
||||
this.Text(text);
|
||||
ImGui.PopStyleColor();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws disabled text.
|
||||
/// </summary>
|
||||
/// <param name="text">Text to draw.</param>
|
||||
public void TextDisabled(string text)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
this.TextColored(*ImGui.GetStyleColorVec4(ImGuiCol.TextDisabled), text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue