mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
Use ImFontPtr in SeStringDrawState
This commit is contained in:
parent
a36e11574b
commit
1d1db04f04
1 changed files with 8 additions and 8 deletions
|
|
@ -76,7 +76,7 @@ public unsafe ref struct SeStringDrawState
|
||||||
this.splitter = default;
|
this.splitter = default;
|
||||||
this.GetEntity = ssdp.GetEntity;
|
this.GetEntity = ssdp.GetEntity;
|
||||||
this.ScreenOffset = new(MathF.Round(this.ScreenOffset.X), MathF.Round(this.ScreenOffset.Y));
|
this.ScreenOffset = new(MathF.Round(this.ScreenOffset.X), MathF.Round(this.ScreenOffset.Y));
|
||||||
this.FontSizeScale = this.FontSize / this.Font->FontSize;
|
this.FontSizeScale = this.FontSize / this.Font.FontSize;
|
||||||
this.LineHeight = MathF.Round(ssdp.EffectiveLineHeight);
|
this.LineHeight = MathF.Round(ssdp.EffectiveLineHeight);
|
||||||
this.LinkUnderlineThickness = ssdp.LinkUnderlineThickness ?? 0f;
|
this.LinkUnderlineThickness = ssdp.LinkUnderlineThickness ?? 0f;
|
||||||
this.Opacity = ssdp.EffectiveOpacity;
|
this.Opacity = ssdp.EffectiveOpacity;
|
||||||
|
|
@ -106,7 +106,7 @@ public unsafe ref struct SeStringDrawState
|
||||||
public Vector2 ScreenOffset { get; }
|
public Vector2 ScreenOffset { get; }
|
||||||
|
|
||||||
/// <inheritdoc cref="SeStringDrawParams.Font"/>
|
/// <inheritdoc cref="SeStringDrawParams.Font"/>
|
||||||
public ImFont* Font { get; }
|
public ImFontPtr Font { get; }
|
||||||
|
|
||||||
/// <inheritdoc cref="SeStringDrawParams.FontSize"/>
|
/// <inheritdoc cref="SeStringDrawParams.FontSize"/>
|
||||||
public float FontSize { get; }
|
public float FontSize { get; }
|
||||||
|
|
@ -256,7 +256,7 @@ public unsafe ref struct SeStringDrawState
|
||||||
/// <param name="offset">Offset of the glyph in pixels w.r.t. <see cref="ScreenOffset"/>.</param>
|
/// <param name="offset">Offset of the glyph in pixels w.r.t. <see cref="ScreenOffset"/>.</param>
|
||||||
internal void DrawGlyph(scoped in ImGuiHelpers.ImFontGlyphReal g, Vector2 offset)
|
internal void DrawGlyph(scoped in ImGuiHelpers.ImFontGlyphReal g, Vector2 offset)
|
||||||
{
|
{
|
||||||
var texId = this.Font->ContainerAtlas->Textures.Ref<ImFontAtlasTexture>(g.TextureIndex).TexID;
|
var texId = this.Font.ContainerAtlas.Textures.Ref<ImFontAtlasTexture>(g.TextureIndex).TexID;
|
||||||
var xy0 = new Vector2(
|
var xy0 = new Vector2(
|
||||||
MathF.Round(g.X0 * this.FontSizeScale),
|
MathF.Round(g.X0 * this.FontSizeScale),
|
||||||
MathF.Round(g.Y0 * this.FontSizeScale));
|
MathF.Round(g.Y0 * this.FontSizeScale));
|
||||||
|
|
@ -313,7 +313,7 @@ public unsafe ref struct SeStringDrawState
|
||||||
|
|
||||||
offset += this.ScreenOffset;
|
offset += this.ScreenOffset;
|
||||||
offset.Y += (this.LinkUnderlineThickness - 1) / 2f;
|
offset.Y += (this.LinkUnderlineThickness - 1) / 2f;
|
||||||
offset.Y += MathF.Round(((this.LineHeight - this.FontSize) / 2) + (this.Font->Ascent * this.FontSizeScale));
|
offset.Y += MathF.Round(((this.LineHeight - this.FontSize) / 2) + (this.Font.Ascent * this.FontSizeScale));
|
||||||
|
|
||||||
this.SetCurrentChannel(SeStringDrawChannel.Foreground);
|
this.SetCurrentChannel(SeStringDrawChannel.Foreground);
|
||||||
this.DrawList.AddLine(
|
this.DrawList.AddLine(
|
||||||
|
|
@ -340,9 +340,9 @@ public unsafe ref struct SeStringDrawState
|
||||||
internal readonly ref ImGuiHelpers.ImFontGlyphReal FindGlyph(Rune rune)
|
internal readonly ref ImGuiHelpers.ImFontGlyphReal FindGlyph(Rune rune)
|
||||||
{
|
{
|
||||||
var p = rune.Value is >= ushort.MinValue and < ushort.MaxValue
|
var p = rune.Value is >= ushort.MinValue and < ushort.MaxValue
|
||||||
? this.Font->FindGlyph((ushort)rune.Value)
|
? (ImFontGlyphPtr)this.Font.FindGlyph((ushort)rune.Value)
|
||||||
: this.Font->FallbackGlyph;
|
: this.Font.FallbackGlyph;
|
||||||
return ref *(ImGuiHelpers.ImFontGlyphReal*)p;
|
return ref *(ImGuiHelpers.ImFontGlyphReal*)p.Handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets the glyph corresponding to the given codepoint.</summary>
|
/// <summary>Gets the glyph corresponding to the given codepoint.</summary>
|
||||||
|
|
@ -375,7 +375,7 @@ public unsafe ref struct SeStringDrawState
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return MathF.Round(
|
return MathF.Round(
|
||||||
this.Font->GetDistanceAdjustmentForPair(
|
this.Font.GetDistanceAdjustmentForPair(
|
||||||
(ushort)left.Value,
|
(ushort)left.Value,
|
||||||
(ushort)right.Value) * this.FontSizeScale);
|
(ushort)right.Value) * this.FontSizeScale);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue