add DistanceRange to Font

cosmonaut 2023-12-07 23:50:34 -08:00
parent 4774e931b6
commit 02d92ea2c0
3 changed files with 8 additions and 4 deletions

@ -1 +1 @@
Subproject commit 82093d2b0d4ee8510820213cbcd248418528a88c Subproject commit 9d62a80dc7d5f339d5384bfb4d2954087151409c

View File

@ -9,6 +9,7 @@ namespace MoonWorks.Graphics.Font
{ {
public Texture Texture { get; } public Texture Texture { get; }
public float PixelsPerEm { get; } public float PixelsPerEm { get; }
public float DistanceRange { get; }
internal IntPtr Handle { get; } internal IntPtr Handle { get; }
@ -39,7 +40,8 @@ namespace MoonWorks.Graphics.Font
(uint) fontFileByteSpan.Length, (uint) fontFileByteSpan.Length,
(IntPtr) atlasFileByteBuffer, (IntPtr) atlasFileByteBuffer,
(uint) atlasFileByteSpan.Length, (uint) atlasFileByteSpan.Length,
out float pixelsPerEm out float pixelsPerEm,
out float distanceRange
); );
var texture = Texture.FromImageFile(graphicsDevice, commandBuffer, Path.ChangeExtension(fontPath, ".png")); var texture = Texture.FromImageFile(graphicsDevice, commandBuffer, Path.ChangeExtension(fontPath, ".png"));
@ -47,14 +49,15 @@ namespace MoonWorks.Graphics.Font
NativeMemory.Free(fontFileByteBuffer); NativeMemory.Free(fontFileByteBuffer);
NativeMemory.Free(atlasFileByteBuffer); NativeMemory.Free(atlasFileByteBuffer);
return new Font(handle, texture, pixelsPerEm); return new Font(handle, texture, pixelsPerEm, distanceRange);
} }
private Font(IntPtr handle, Texture texture, float pixelsPerEm) private Font(IntPtr handle, Texture texture, float pixelsPerEm, float distanceRange)
{ {
Handle = handle; Handle = handle;
Texture = texture; Texture = texture;
PixelsPerEm = pixelsPerEm; PixelsPerEm = pixelsPerEm;
DistanceRange = distanceRange;
StringBytesLength = 32; StringBytesLength = 32;
StringBytes = (byte*) NativeMemory.Alloc((nuint) StringBytesLength); StringBytes = (byte*) NativeMemory.Alloc((nuint) StringBytesLength);

View File

@ -119,6 +119,7 @@ namespace MoonWorks.Graphics.Font
} }
NativeMemory.Free(StringBytes); NativeMemory.Free(StringBytes);
Wellspring.Wellspring_DestroyTextBatch(Handle);
IsDisposed = true; IsDisposed = true;
} }