mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-31 21:03:43 +01:00
wip bindings upgrade
This commit is contained in:
parent
bd7e56850a
commit
0690cce995
272 changed files with 139041 additions and 1541 deletions
|
|
@ -5,7 +5,7 @@ using Dalamud.Interface.Utility;
|
|||
using Dalamud.Logging.Internal;
|
||||
using Dalamud.Utility;
|
||||
|
||||
using ImGuiNET;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
|
||||
namespace Dalamud.Interface.ManagedFontAtlas.Internals;
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ internal sealed class DelegateFontHandle : FontHandle
|
|||
{
|
||||
for (var i = fontCountPrevious; !found && i < fontsVector.Length; i++)
|
||||
{
|
||||
if (fontsVector[i].NativePtr == toolkitPreBuild.Font.NativePtr)
|
||||
if (fontsVector[i].Handle == toolkitPreBuild.Font.Handle)
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -223,7 +223,7 @@ internal sealed class DelegateFontHandle : FontHandle
|
|||
{
|
||||
unsafe
|
||||
{
|
||||
if (fontsVector[i].NativePtr == fontsVector[j].NativePtr)
|
||||
if (fontsVector[i].Handle == fontsVector[j].Handle)
|
||||
throw new InvalidOperationException("An already added font has been added again.");
|
||||
}
|
||||
}
|
||||
|
|
@ -247,7 +247,7 @@ internal sealed class DelegateFontHandle : FontHandle
|
|||
{
|
||||
var distinct =
|
||||
fontsVector
|
||||
.DistinctBy(x => (nint)x.NativePtr) // Remove duplicates
|
||||
.DistinctBy(x => (nint)x.Handle) // Remove duplicates
|
||||
.Where(x => x.ValidateUnsafe() is null) // Remove invalid entries without freeing them
|
||||
.ToArray();
|
||||
|
||||
|
|
@ -259,7 +259,7 @@ internal sealed class DelegateFontHandle : FontHandle
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
/// <inheritdoc/>
|
||||
public void OnPreBuildCleanup(IFontAtlasBuildToolkitPreBuild toolkitPreBuild)
|
||||
{
|
||||
// irrelevant
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ using Dalamud.Interface.Utility;
|
|||
using Dalamud.Storage.Assets;
|
||||
using Dalamud.Utility;
|
||||
|
||||
using ImGuiNET;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
|
||||
using SharpDX.DXGI;
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ internal sealed partial class FontAtlasFactory
|
|||
Log.Verbose(
|
||||
"[{name}] 0x{atlas:X}: {funcname}(0x{dataPointer:X}, 0x{dataSize:X}, ...) from {tag}",
|
||||
this.data.Owner?.Name ?? "(error)",
|
||||
(nint)this.NewImAtlas.NativePtr,
|
||||
(nint)this.NewImAtlas.Handle,
|
||||
nameof(this.AddFontFromImGuiHeapAllocatedMemory),
|
||||
(nint)dataPointer,
|
||||
dataSize,
|
||||
|
|
@ -169,7 +169,7 @@ internal sealed partial class FontAtlasFactory
|
|||
var raw = fontConfig.Raw with
|
||||
{
|
||||
FontData = dataPointer,
|
||||
FontDataOwnedByAtlas = 1,
|
||||
FontDataOwnedByAtlas = true,
|
||||
FontDataSize = dataSize,
|
||||
};
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ internal sealed partial class FontAtlasFactory
|
|||
|
||||
TrueTypeUtils.CheckImGuiCompatibleOrThrow(raw);
|
||||
|
||||
font = this.NewImAtlas.AddFont(&raw);
|
||||
font = this.NewImAtlas.AddFont(raw);
|
||||
|
||||
var dataHash = default(HashCode);
|
||||
dataHash.AddBytes(new(dataPointer, dataSize));
|
||||
|
|
@ -222,7 +222,7 @@ internal sealed partial class FontAtlasFactory
|
|||
{
|
||||
// Note that for both RemoveAt calls, corresponding destructors will be called.
|
||||
|
||||
var configIndex = this.data.ConfigData.FindIndex(x => x.DstFont == font.NativePtr);
|
||||
var configIndex = this.data.ConfigData.FindIndex(x => x.DstFont == font.Handle);
|
||||
if (configIndex >= 0)
|
||||
this.data.ConfigData.RemoveAt(configIndex);
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ internal sealed partial class FontAtlasFactory
|
|||
|
||||
// ImFontConfig has no destructor, and does not free the data.
|
||||
if (freeOnException)
|
||||
ImGuiNative.igMemFree(dataPointer);
|
||||
ImGui.MemFree(dataPointer);
|
||||
|
||||
throw;
|
||||
}
|
||||
|
|
@ -279,7 +279,7 @@ internal sealed partial class FontAtlasFactory
|
|||
}
|
||||
catch
|
||||
{
|
||||
ImGuiNative.igMemFree(memory);
|
||||
ImGui.MemFree(memory);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
|
@ -304,7 +304,7 @@ internal sealed partial class FontAtlasFactory
|
|||
}
|
||||
catch
|
||||
{
|
||||
ImGuiNative.igMemFree(memory);
|
||||
ImGui.MemFree(memory);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
|
@ -653,7 +653,7 @@ internal sealed partial class FontAtlasFactory
|
|||
foreach (var c in FallbackCodepoints)
|
||||
{
|
||||
var g = font.FindGlyphNoFallback(c);
|
||||
if (g.NativePtr == null)
|
||||
if (g == null)
|
||||
continue;
|
||||
|
||||
font.UpdateFallbackChar(c);
|
||||
|
|
@ -663,7 +663,7 @@ internal sealed partial class FontAtlasFactory
|
|||
foreach (var c in EllipsisCodepoints)
|
||||
{
|
||||
var g = font.FindGlyphNoFallback(c);
|
||||
if (g.NativePtr == null)
|
||||
if (g == null)
|
||||
continue;
|
||||
|
||||
font.EllipsisChar = c;
|
||||
|
|
@ -699,8 +699,8 @@ internal sealed partial class FontAtlasFactory
|
|||
{
|
||||
ref var texture = ref textureSpan[i];
|
||||
var name =
|
||||
$"{nameof(FontAtlasBuiltData)}[{this.data.Owner?.Name ?? "-"}][0x{(long)this.data.Atlas.NativePtr:X}][{i}]";
|
||||
if (texture.TexID != 0)
|
||||
$"{nameof(FontAtlasBuiltData)}[{this.data.Owner?.Name ?? "-"}][0x{(long)this.data.Atlas.Handle:X}][{i}]";
|
||||
if (!texture.TexID.IsNull)
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
|
@ -769,9 +769,9 @@ internal sealed partial class FontAtlasFactory
|
|||
}
|
||||
|
||||
if (texture.TexPixelsRGBA32 is not null)
|
||||
ImGuiNative.igMemFree(texture.TexPixelsRGBA32);
|
||||
ImGui.MemFree(texture.TexPixelsRGBA32);
|
||||
if (texture.TexPixelsAlpha8 is not null)
|
||||
ImGuiNative.igMemFree(texture.TexPixelsAlpha8);
|
||||
ImGui.MemFree(texture.TexPixelsAlpha8);
|
||||
texture.TexPixelsRGBA32 = null;
|
||||
texture.TexPixelsAlpha8 = null;
|
||||
}
|
||||
|
|
@ -795,8 +795,8 @@ internal sealed partial class FontAtlasFactory
|
|||
var targetFound = false;
|
||||
foreach (var f in this.Fonts)
|
||||
{
|
||||
sourceFound |= f.NativePtr == source.NativePtr;
|
||||
targetFound |= f.NativePtr == target.NativePtr;
|
||||
sourceFound |= f.Handle == source.Handle;
|
||||
targetFound |= f.Handle == target.Handle;
|
||||
}
|
||||
|
||||
if (sourceFound && targetFound)
|
||||
|
|
@ -817,8 +817,8 @@ internal sealed partial class FontAtlasFactory
|
|||
public unsafe void BuildLookupTable(ImFontPtr font)
|
||||
{
|
||||
// Need to clear previous Fallback pointers before BuildLookupTable, or it may crash
|
||||
font.NativePtr->FallbackGlyph = null;
|
||||
font.NativePtr->FallbackHotData = null;
|
||||
font.Handle->FallbackGlyph = null;
|
||||
font.Handle->FallbackHotData = null;
|
||||
font.BuildLookupTable();
|
||||
|
||||
// Need to fix our custom ImGui, so that imgui_widgets.cpp:3656 stops thinking
|
||||
|
|
@ -826,7 +826,7 @@ internal sealed partial class FontAtlasFactory
|
|||
// Otherwise, having a fallback character in ImGui.InputText gets strange.
|
||||
var indexedHotData = font.IndexedHotDataWrapped();
|
||||
var indexLookup = font.IndexLookupWrapped();
|
||||
ref var fallbackHotData = ref *(ImGuiHelpers.ImFontGlyphHotDataReal*)font.NativePtr->FallbackHotData;
|
||||
ref var fallbackHotData = ref *(ImGuiHelpers.ImFontGlyphHotDataReal*)font.Handle->FallbackHotData;
|
||||
for (var codepoint = 0; codepoint < indexedHotData.Length; codepoint++)
|
||||
{
|
||||
if (indexLookup[codepoint] == ushort.MaxValue)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using System.Runtime.ExceptionServices;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface.GameFonts;
|
||||
using Dalamud.Interface.Textures.TextureWraps;
|
||||
using Dalamud.Interface.Utility;
|
||||
|
|
@ -15,8 +16,6 @@ using Dalamud.Logging.Internal;
|
|||
using Dalamud.Plugin.Internal.Types;
|
||||
using Dalamud.Utility;
|
||||
|
||||
using ImGuiNET;
|
||||
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Dalamud.Interface.ManagedFontAtlas.Internals;
|
||||
|
|
@ -73,12 +72,12 @@ internal sealed partial class FontAtlasFactory
|
|||
var wrapsCopy = this.wraps = new();
|
||||
this.Garbage.Add(() => wrapsCopy.Clear());
|
||||
|
||||
var atlasPtr = ImGuiNative.ImFontAtlas_ImFontAtlas();
|
||||
var atlasPtr = ImGui.ImFontAtlas();
|
||||
this.Atlas = atlasPtr;
|
||||
if (this.Atlas.NativePtr is null)
|
||||
if (this.Atlas.Handle is null)
|
||||
throw new OutOfMemoryException($"Failed to allocate a new {nameof(ImFontAtlas)}.");
|
||||
|
||||
this.Garbage.Add(() => ImGuiNative.ImFontAtlas_destroy(atlasPtr));
|
||||
this.Garbage.Add(() => this.Atlas.Destroy());
|
||||
this.IsBuildInProgress = true;
|
||||
|
||||
Interlocked.Increment(ref numActiveInstances);
|
||||
|
|
@ -188,7 +187,7 @@ internal sealed partial class FontAtlasFactory
|
|||
|
||||
case IRefCountable.RefCountResult.FinalRelease:
|
||||
#if VeryVerboseLog
|
||||
Log.Verbose("[{name}] 0x{ptr:X}: Disposing", this.Owner?.Name ?? "<?>", (nint)this.Atlas.NativePtr);
|
||||
Log.Verbose("[{name}] 0x{ptr:X}: Disposing", this.Owner?.Name ?? "<?>", (nint)this.Atlas.Handle);
|
||||
#endif
|
||||
|
||||
if (this.IsBuildInProgress)
|
||||
|
|
@ -199,7 +198,7 @@ internal sealed partial class FontAtlasFactory
|
|||
"[{name}] 0x{ptr:X}: Trying to dispose while build is in progress; disposing later.\n" +
|
||||
"Stack:\n{trace}",
|
||||
this.Owner?.Name ?? "<?>",
|
||||
(nint)this.Atlas.NativePtr,
|
||||
(nint)this.Atlas.Handle,
|
||||
new StackTrace());
|
||||
}
|
||||
|
||||
|
|
@ -371,7 +370,7 @@ internal sealed partial class FontAtlasFactory
|
|||
public Task BuildTask => this.buildTask;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool HasBuiltAtlas => !(this.builtData?.Atlas.IsNull() ?? true);
|
||||
public bool HasBuiltAtlas => !(this.builtData?.Atlas.IsNull ?? true);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool IsGlobalScaled { get; }
|
||||
|
|
@ -568,7 +567,7 @@ internal sealed partial class FontAtlasFactory
|
|||
}
|
||||
|
||||
var res = await this.RebuildFontsPrivate(true, scale);
|
||||
if (res.Atlas.IsNull())
|
||||
if (res.Atlas.IsNull)
|
||||
return res;
|
||||
|
||||
this.PromoteBuiltData(rebuildIndex, res, nameof(this.BuildFontsAsync));
|
||||
|
|
@ -663,10 +662,10 @@ internal sealed partial class FontAtlasFactory
|
|||
{
|
||||
res = new(this, scale);
|
||||
foreach (var fhm in this.fontHandleManagers)
|
||||
res.InitialAddSubstance(fhm.NewSubstance(res));
|
||||
res.InitialAddSubstance(fhm.NewSubstance(res));
|
||||
unsafe
|
||||
{
|
||||
atlasPtr = (nint)res.Atlas.NativePtr;
|
||||
atlasPtr = (nint)res.Atlas.Handle;
|
||||
}
|
||||
|
||||
Log.Verbose(
|
||||
|
|
@ -698,10 +697,10 @@ internal sealed partial class FontAtlasFactory
|
|||
|
||||
res = new(this, scale);
|
||||
foreach (var fhm in this.fontHandleManagers)
|
||||
res.InitialAddSubstance(fhm.NewSubstance(res));
|
||||
res.InitialAddSubstance(fhm.NewSubstance(res));
|
||||
unsafe
|
||||
{
|
||||
atlasPtr = (nint)res.Atlas.NativePtr;
|
||||
atlasPtr = (nint)res.Atlas.Handle;
|
||||
}
|
||||
|
||||
toolkit = res.CreateToolkit(this.factory, isAsync);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ using Dalamud.Plugin.Internal.Types;
|
|||
using Dalamud.Storage.Assets;
|
||||
using Dalamud.Utility;
|
||||
|
||||
using ImGuiNET;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
|
||||
using Lumina.Data.Files;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ using Dalamud.Plugin.Internal;
|
|||
using Dalamud.Plugin.Internal.Types;
|
||||
using Dalamud.Utility;
|
||||
|
||||
using ImGuiNET;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
|
||||
using Serilog;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ using Dalamud.Interface.Textures.TextureWraps;
|
|||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Utility;
|
||||
|
||||
using ImGuiNET;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
|
||||
using Lumina.Data.Files;
|
||||
|
||||
|
|
@ -381,7 +381,10 @@ internal class GamePrebakedFontHandle : FontHandle
|
|||
var pixels8Array = new byte*[toolkitPostBuild.NewImAtlas.Textures.Size];
|
||||
var widths = new int[toolkitPostBuild.NewImAtlas.Textures.Size];
|
||||
for (var i = 0; i < pixels8Array.Length; i++)
|
||||
toolkitPostBuild.NewImAtlas.GetTexDataAsAlpha8(i, out pixels8Array[i], out widths[i], out _);
|
||||
{
|
||||
var width = 0;
|
||||
toolkitPostBuild.NewImAtlas.GetTexDataAsAlpha8(i, ref pixels8Array[i], ref widths[i], ref width);
|
||||
}
|
||||
|
||||
foreach (var (style, plan) in this.fonts)
|
||||
{
|
||||
|
|
@ -429,7 +432,7 @@ internal class GamePrebakedFontHandle : FontHandle
|
|||
var fas = style.Scale(atlasScale).FamilyAndSize;
|
||||
using var handle = this.handleManager.GameFontTextureProvider.CreateFdtFileView(fas, out var fdt);
|
||||
ref var fdtFontHeader = ref fdt.FontHeader;
|
||||
var fontPtr = font.NativePtr;
|
||||
var fontPtr = font.Handle;
|
||||
|
||||
var scale = style.SizePt / fdtFontHeader.Size;
|
||||
fontPtr->Ascent = fdtFontHeader.Ascent * scale;
|
||||
|
|
@ -513,7 +516,7 @@ internal class GamePrebakedFontHandle : FontHandle
|
|||
var ranges = this.Ranges[this.FullRangeFont];
|
||||
foreach (var (font, extraRange) in this.Ranges)
|
||||
{
|
||||
if (font.NativePtr != this.FullRangeFont.NativePtr)
|
||||
if (font.Handle != this.FullRangeFont.Handle)
|
||||
ranges.Or(extraRange);
|
||||
}
|
||||
|
||||
|
|
@ -562,7 +565,7 @@ internal class GamePrebakedFontHandle : FontHandle
|
|||
public unsafe void PostProcessFullRangeFont(float atlasScale)
|
||||
{
|
||||
var round = 1 / atlasScale;
|
||||
var pfrf = this.FullRangeFont.NativePtr;
|
||||
var pfrf = this.FullRangeFont.Handle;
|
||||
ref var frf = ref *pfrf;
|
||||
|
||||
frf.FontSize = MathF.Round(frf.FontSize / round) * round;
|
||||
|
|
@ -589,19 +592,18 @@ internal class GamePrebakedFontHandle : FontHandle
|
|||
continue;
|
||||
if (!fullRange[leftInt] || !fullRange[rightInt])
|
||||
continue;
|
||||
ImGuiNative.ImFont_AddKerningPair(
|
||||
pfrf,
|
||||
pfrf->AddKerningPair(
|
||||
(ushort)leftInt,
|
||||
(ushort)rightInt,
|
||||
MathF.Round((k.RightOffset * scale) / round) * round);
|
||||
}
|
||||
|
||||
pfrf->FallbackGlyph = null;
|
||||
ImGuiNative.ImFont_BuildLookupTable(pfrf);
|
||||
pfrf->BuildLookupTable();
|
||||
|
||||
foreach (var fallbackCharCandidate in FontAtlasFactory.FallbackCodepoints)
|
||||
{
|
||||
var glyph = ImGuiNative.ImFont_FindGlyphNoFallback(pfrf, fallbackCharCandidate);
|
||||
var glyph = pfrf->FindGlyphNoFallback(fallbackCharCandidate);
|
||||
if ((nint)glyph == IntPtr.Zero)
|
||||
continue;
|
||||
frf.FallbackChar = fallbackCharCandidate;
|
||||
|
|
@ -619,7 +621,7 @@ internal class GamePrebakedFontHandle : FontHandle
|
|||
|
||||
foreach (var (font, rangeBits) in this.Ranges)
|
||||
{
|
||||
if (font.NativePtr == this.FullRangeFont.NativePtr)
|
||||
if (font.Handle == this.FullRangeFont.Handle)
|
||||
continue;
|
||||
|
||||
var fontScaleMode = toolkitPostBuild.GetFontScaleMode(font);
|
||||
|
|
@ -641,7 +643,7 @@ internal class GamePrebakedFontHandle : FontHandle
|
|||
glyphIndex = (ushort)glyphs.Length;
|
||||
glyphs.Add(default);
|
||||
}
|
||||
|
||||
|
||||
ref var g = ref glyphs[glyphIndex];
|
||||
g = sourceGlyph;
|
||||
if (fontScaleMode == FontScaleMode.SkipHandling)
|
||||
|
|
@ -681,16 +683,16 @@ internal class GamePrebakedFontHandle : FontHandle
|
|||
}
|
||||
}
|
||||
|
||||
font.NativePtr->FallbackGlyph = null;
|
||||
font.Handle->FallbackGlyph = null;
|
||||
font.BuildLookupTable();
|
||||
|
||||
foreach (var fallbackCharCandidate in FontAtlasFactory.FallbackCodepoints)
|
||||
{
|
||||
var glyph = font.FindGlyphNoFallback(fallbackCharCandidate).NativePtr;
|
||||
if ((nint)glyph == IntPtr.Zero)
|
||||
var glyph = font.FindGlyphNoFallback(fallbackCharCandidate);
|
||||
if (glyph == null)
|
||||
continue;
|
||||
|
||||
ref var frf = ref *font.NativePtr;
|
||||
ref var frf = ref *font.Handle;
|
||||
frf.FallbackChar = fallbackCharCandidate;
|
||||
frf.FallbackGlyph = glyph;
|
||||
frf.FallbackHotData =
|
||||
|
|
@ -804,10 +806,9 @@ internal class GamePrebakedFontHandle : FontHandle
|
|||
else
|
||||
{
|
||||
ref var rc = ref *(ImGuiHelpers.ImFontAtlasCustomRectReal*)toolkitPostBuild.NewImAtlas
|
||||
.GetCustomRectByIndex(rectId)
|
||||
.NativePtr;
|
||||
.GetCustomRectByIndex(rectId);
|
||||
var widthAdjustment = this.BaseStyle.CalculateBaseWidthAdjustment(fdtFontHeader, fdtGlyph);
|
||||
|
||||
|
||||
// Glyph is scaled at this point; undo that.
|
||||
ref var glyph = ref glyphs[lookups[rc.GlyphId]];
|
||||
glyph.X0 = this.BaseAttr.HorizontalOffset;
|
||||
|
|
@ -822,7 +823,7 @@ internal class GamePrebakedFontHandle : FontHandle
|
|||
this.gftp.GetTexFile(this.BaseAttr.TexPathFormat, fdtGlyph.TextureFileIndex);
|
||||
var sourceBuffer = texFiles[fdtGlyph.TextureFileIndex].ImageData;
|
||||
var sourceBufferDelta = fdtGlyph.TextureChannelByteIndex;
|
||||
|
||||
|
||||
for (var y = 0; y < fdtGlyph.BoundingHeight; y++)
|
||||
{
|
||||
var sourcePixelIndex =
|
||||
|
|
@ -830,11 +831,11 @@ internal class GamePrebakedFontHandle : FontHandle
|
|||
sourcePixelIndex *= 4;
|
||||
sourcePixelIndex += sourceBufferDelta;
|
||||
var blend1 = horzBlend[fdtGlyph.CurrentOffsetY + y];
|
||||
|
||||
|
||||
var targetOffset = ((rc.Y + y) * width) + rc.X;
|
||||
for (var x = 0; x < rc.Width; x++)
|
||||
pixels8[targetOffset + x] = 0;
|
||||
|
||||
|
||||
targetOffset += horzShift[fdtGlyph.CurrentOffsetY + y];
|
||||
if (blend1 == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Utility;
|
||||
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.ManagedFontAtlas.Internals;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -45,7 +44,7 @@ internal interface IFontHandleSubstance : IDisposable
|
|||
/// </summary>
|
||||
/// <param name="toolkitPreBuild">The toolkit.</param>
|
||||
void OnPreBuild(IFontAtlasBuildToolkitPreBuild toolkitPreBuild);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Called between <see cref="OnPreBuild"/> and <see cref="ImFontAtlasPtr.Build"/> calls.<br />
|
||||
/// Any further modification to <see cref="IFontAtlasBuildToolkit.Fonts"/> will result in undefined behavior.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Utility;
|
||||
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.ManagedFontAtlas.Internals;
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface.Utility;
|
||||
|
||||
using ImGuiNET;
|
||||
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
|
||||
using Serilog;
|
||||
|
|
@ -32,10 +31,10 @@ internal sealed class SimplePushedFont : IDisposable
|
|||
public static SimplePushedFont Rent(List<IDisposable> stack, ImFontPtr fontPtr)
|
||||
{
|
||||
var rented = Pool.Get();
|
||||
Debug.Assert(rented.font.IsNull(), "Rented object must not have its font set");
|
||||
Debug.Assert(rented.font.IsNull, "Rented object must not have its font set");
|
||||
rented.stack = stack;
|
||||
|
||||
if (fontPtr.IsNotNullAndLoaded())
|
||||
if (!fontPtr.IsNull && fontPtr.IsLoaded())
|
||||
{
|
||||
rented.font = fontPtr;
|
||||
ImGui.PushFont(fontPtr);
|
||||
|
|
@ -54,9 +53,9 @@ internal sealed class SimplePushedFont : IDisposable
|
|||
|
||||
this.stack.RemoveAt(this.stack.Count - 1);
|
||||
|
||||
if (!this.font.IsNull())
|
||||
if (!this.font.IsNull)
|
||||
{
|
||||
if (ImGui.GetFont().NativePtr == this.font.NativePtr)
|
||||
if (ImGui.GetFont().Handle == this.font.Handle)
|
||||
{
|
||||
ImGui.PopFont();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@ using System.Buffers.Binary;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface.Utility;
|
||||
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.ManagedFontAtlas.Internals;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -18,7 +17,7 @@ internal static partial class TrueTypeUtils
|
|||
/// and throws an appropriate exception if it is the case.
|
||||
/// </summary>
|
||||
/// <param name="fontConfig">The font config.</param>
|
||||
public static unsafe void CheckImGuiCompatibleOrThrow(in ImFontConfig fontConfig)
|
||||
public static unsafe void CheckImGuiCompatibleOrThrow(in ImFontConfigPtr fontConfig)
|
||||
{
|
||||
var ranges = fontConfig.GlyphRanges;
|
||||
var sfnt = AsSfntFile(fontConfig);
|
||||
|
|
@ -35,7 +34,7 @@ internal static partial class TrueTypeUtils
|
|||
/// <param name="fontConfig">The font config.</param>
|
||||
/// <returns>The enumerable of pair adjustments. Distance values need to be multiplied by font size in pixels.</returns>
|
||||
public static IEnumerable<(char Left, char Right, float Distance)> ExtractHorizontalPairAdjustments(
|
||||
ImFontConfig fontConfig)
|
||||
ImFontConfigPtr fontConfig)
|
||||
{
|
||||
float multiplier;
|
||||
Dictionary<ushort, char[]> glyphToCodepoints;
|
||||
|
|
@ -107,7 +106,7 @@ internal static partial class TrueTypeUtils
|
|||
}
|
||||
}
|
||||
|
||||
private static unsafe SfntFile AsSfntFile(in ImFontConfig fontConfig)
|
||||
private static unsafe SfntFile AsSfntFile(in ImFontConfigPtr fontConfig)
|
||||
{
|
||||
var memory = new PointerSpan<byte>((byte*)fontConfig.FontData, fontConfig.FontDataSize);
|
||||
if (memory.Length < 4)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue