|
|
@ -85,121 +85,175 @@ namespace ImGuiNET |
|
|
|
public ImFontPtr AddFontFromFileTTF(string filename, float size_pixels) |
|
|
|
public ImFontPtr AddFontFromFileTTF(string filename, float size_pixels) |
|
|
|
{ |
|
|
|
{ |
|
|
|
byte* native_filename; |
|
|
|
byte* native_filename; |
|
|
|
|
|
|
|
int filename_byteCount = 0; |
|
|
|
if (filename != null) |
|
|
|
if (filename != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int filename_byteCount = Encoding.UTF8.GetByteCount(filename); |
|
|
|
filename_byteCount = Encoding.UTF8.GetByteCount(filename); |
|
|
|
byte* native_filename_stackBytes = stackalloc byte[filename_byteCount + 1]; |
|
|
|
if (filename_byteCount > Util.StackAllocationSizeLimit) |
|
|
|
native_filename = native_filename_stackBytes; |
|
|
|
|
|
|
|
fixed (char* filename_ptr = filename) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
int native_filename_offset = Encoding.UTF8.GetBytes(filename_ptr, filename.Length, native_filename, filename_byteCount); |
|
|
|
native_filename = Util.Allocate(filename_byteCount + 1); |
|
|
|
native_filename[native_filename_offset] = 0; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
byte* native_filename_stackBytes = stackalloc byte[filename_byteCount + 1]; |
|
|
|
|
|
|
|
native_filename = native_filename_stackBytes; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int native_filename_offset = Util.GetUtf8(filename, native_filename, filename_byteCount); |
|
|
|
|
|
|
|
native_filename[native_filename_offset] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
else { native_filename = null; } |
|
|
|
else { native_filename = null; } |
|
|
|
ImFontConfig* font_cfg = null; |
|
|
|
ImFontConfig* font_cfg = null; |
|
|
|
ushort* glyph_ranges = null; |
|
|
|
ushort* glyph_ranges = null; |
|
|
|
ImFont* ret = ImGuiNative.ImFontAtlas_AddFontFromFileTTF(NativePtr, native_filename, size_pixels, font_cfg, glyph_ranges); |
|
|
|
ImFont* ret = ImGuiNative.ImFontAtlas_AddFontFromFileTTF(NativePtr, native_filename, size_pixels, font_cfg, glyph_ranges); |
|
|
|
|
|
|
|
if (filename_byteCount > Util.StackAllocationSizeLimit) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Util.Free(native_filename); |
|
|
|
|
|
|
|
} |
|
|
|
return new ImFontPtr(ret); |
|
|
|
return new ImFontPtr(ret); |
|
|
|
} |
|
|
|
} |
|
|
|
public ImFontPtr AddFontFromFileTTF(string filename, float size_pixels, ImFontConfigPtr font_cfg) |
|
|
|
public ImFontPtr AddFontFromFileTTF(string filename, float size_pixels, ImFontConfigPtr font_cfg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
byte* native_filename; |
|
|
|
byte* native_filename; |
|
|
|
|
|
|
|
int filename_byteCount = 0; |
|
|
|
if (filename != null) |
|
|
|
if (filename != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int filename_byteCount = Encoding.UTF8.GetByteCount(filename); |
|
|
|
filename_byteCount = Encoding.UTF8.GetByteCount(filename); |
|
|
|
byte* native_filename_stackBytes = stackalloc byte[filename_byteCount + 1]; |
|
|
|
if (filename_byteCount > Util.StackAllocationSizeLimit) |
|
|
|
native_filename = native_filename_stackBytes; |
|
|
|
{ |
|
|
|
fixed (char* filename_ptr = filename) |
|
|
|
native_filename = Util.Allocate(filename_byteCount + 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
int native_filename_offset = Encoding.UTF8.GetBytes(filename_ptr, filename.Length, native_filename, filename_byteCount); |
|
|
|
byte* native_filename_stackBytes = stackalloc byte[filename_byteCount + 1]; |
|
|
|
native_filename[native_filename_offset] = 0; |
|
|
|
native_filename = native_filename_stackBytes; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int native_filename_offset = Util.GetUtf8(filename, native_filename, filename_byteCount); |
|
|
|
|
|
|
|
native_filename[native_filename_offset] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
else { native_filename = null; } |
|
|
|
else { native_filename = null; } |
|
|
|
ImFontConfig* native_font_cfg = font_cfg.NativePtr; |
|
|
|
ImFontConfig* native_font_cfg = font_cfg.NativePtr; |
|
|
|
ushort* glyph_ranges = null; |
|
|
|
ushort* glyph_ranges = null; |
|
|
|
ImFont* ret = ImGuiNative.ImFontAtlas_AddFontFromFileTTF(NativePtr, native_filename, size_pixels, native_font_cfg, glyph_ranges); |
|
|
|
ImFont* ret = ImGuiNative.ImFontAtlas_AddFontFromFileTTF(NativePtr, native_filename, size_pixels, native_font_cfg, glyph_ranges); |
|
|
|
|
|
|
|
if (filename_byteCount > Util.StackAllocationSizeLimit) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Util.Free(native_filename); |
|
|
|
|
|
|
|
} |
|
|
|
return new ImFontPtr(ret); |
|
|
|
return new ImFontPtr(ret); |
|
|
|
} |
|
|
|
} |
|
|
|
public ImFontPtr AddFontFromFileTTF(string filename, float size_pixels, ImFontConfigPtr font_cfg, IntPtr glyph_ranges) |
|
|
|
public ImFontPtr AddFontFromFileTTF(string filename, float size_pixels, ImFontConfigPtr font_cfg, IntPtr glyph_ranges) |
|
|
|
{ |
|
|
|
{ |
|
|
|
byte* native_filename; |
|
|
|
byte* native_filename; |
|
|
|
|
|
|
|
int filename_byteCount = 0; |
|
|
|
if (filename != null) |
|
|
|
if (filename != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int filename_byteCount = Encoding.UTF8.GetByteCount(filename); |
|
|
|
filename_byteCount = Encoding.UTF8.GetByteCount(filename); |
|
|
|
byte* native_filename_stackBytes = stackalloc byte[filename_byteCount + 1]; |
|
|
|
if (filename_byteCount > Util.StackAllocationSizeLimit) |
|
|
|
native_filename = native_filename_stackBytes; |
|
|
|
{ |
|
|
|
fixed (char* filename_ptr = filename) |
|
|
|
native_filename = Util.Allocate(filename_byteCount + 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
int native_filename_offset = Encoding.UTF8.GetBytes(filename_ptr, filename.Length, native_filename, filename_byteCount); |
|
|
|
byte* native_filename_stackBytes = stackalloc byte[filename_byteCount + 1]; |
|
|
|
native_filename[native_filename_offset] = 0; |
|
|
|
native_filename = native_filename_stackBytes; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int native_filename_offset = Util.GetUtf8(filename, native_filename, filename_byteCount); |
|
|
|
|
|
|
|
native_filename[native_filename_offset] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
else { native_filename = null; } |
|
|
|
else { native_filename = null; } |
|
|
|
ImFontConfig* native_font_cfg = font_cfg.NativePtr; |
|
|
|
ImFontConfig* native_font_cfg = font_cfg.NativePtr; |
|
|
|
ushort* native_glyph_ranges = (ushort*)glyph_ranges.ToPointer(); |
|
|
|
ushort* native_glyph_ranges = (ushort*)glyph_ranges.ToPointer(); |
|
|
|
ImFont* ret = ImGuiNative.ImFontAtlas_AddFontFromFileTTF(NativePtr, native_filename, size_pixels, native_font_cfg, native_glyph_ranges); |
|
|
|
ImFont* ret = ImGuiNative.ImFontAtlas_AddFontFromFileTTF(NativePtr, native_filename, size_pixels, native_font_cfg, native_glyph_ranges); |
|
|
|
|
|
|
|
if (filename_byteCount > Util.StackAllocationSizeLimit) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Util.Free(native_filename); |
|
|
|
|
|
|
|
} |
|
|
|
return new ImFontPtr(ret); |
|
|
|
return new ImFontPtr(ret); |
|
|
|
} |
|
|
|
} |
|
|
|
public ImFontPtr AddFontFromMemoryCompressedBase85TTF(string compressed_font_data_base85, float size_pixels) |
|
|
|
public ImFontPtr AddFontFromMemoryCompressedBase85TTF(string compressed_font_data_base85, float size_pixels) |
|
|
|
{ |
|
|
|
{ |
|
|
|
byte* native_compressed_font_data_base85; |
|
|
|
byte* native_compressed_font_data_base85; |
|
|
|
|
|
|
|
int compressed_font_data_base85_byteCount = 0; |
|
|
|
if (compressed_font_data_base85 != null) |
|
|
|
if (compressed_font_data_base85 != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int compressed_font_data_base85_byteCount = Encoding.UTF8.GetByteCount(compressed_font_data_base85); |
|
|
|
compressed_font_data_base85_byteCount = Encoding.UTF8.GetByteCount(compressed_font_data_base85); |
|
|
|
byte* native_compressed_font_data_base85_stackBytes = stackalloc byte[compressed_font_data_base85_byteCount + 1]; |
|
|
|
if (compressed_font_data_base85_byteCount > Util.StackAllocationSizeLimit) |
|
|
|
native_compressed_font_data_base85 = native_compressed_font_data_base85_stackBytes; |
|
|
|
|
|
|
|
fixed (char* compressed_font_data_base85_ptr = compressed_font_data_base85) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
int native_compressed_font_data_base85_offset = Encoding.UTF8.GetBytes(compressed_font_data_base85_ptr, compressed_font_data_base85.Length, native_compressed_font_data_base85, compressed_font_data_base85_byteCount); |
|
|
|
native_compressed_font_data_base85 = Util.Allocate(compressed_font_data_base85_byteCount + 1); |
|
|
|
native_compressed_font_data_base85[native_compressed_font_data_base85_offset] = 0; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
byte* native_compressed_font_data_base85_stackBytes = stackalloc byte[compressed_font_data_base85_byteCount + 1]; |
|
|
|
|
|
|
|
native_compressed_font_data_base85 = native_compressed_font_data_base85_stackBytes; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int native_compressed_font_data_base85_offset = Util.GetUtf8(compressed_font_data_base85, native_compressed_font_data_base85, compressed_font_data_base85_byteCount); |
|
|
|
|
|
|
|
native_compressed_font_data_base85[native_compressed_font_data_base85_offset] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
else { native_compressed_font_data_base85 = null; } |
|
|
|
else { native_compressed_font_data_base85 = null; } |
|
|
|
ImFontConfig* font_cfg = null; |
|
|
|
ImFontConfig* font_cfg = null; |
|
|
|
ushort* glyph_ranges = null; |
|
|
|
ushort* glyph_ranges = null; |
|
|
|
ImFont* ret = ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(NativePtr, native_compressed_font_data_base85, size_pixels, font_cfg, glyph_ranges); |
|
|
|
ImFont* ret = ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(NativePtr, native_compressed_font_data_base85, size_pixels, font_cfg, glyph_ranges); |
|
|
|
|
|
|
|
if (compressed_font_data_base85_byteCount > Util.StackAllocationSizeLimit) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Util.Free(native_compressed_font_data_base85); |
|
|
|
|
|
|
|
} |
|
|
|
return new ImFontPtr(ret); |
|
|
|
return new ImFontPtr(ret); |
|
|
|
} |
|
|
|
} |
|
|
|
public ImFontPtr AddFontFromMemoryCompressedBase85TTF(string compressed_font_data_base85, float size_pixels, ImFontConfigPtr font_cfg) |
|
|
|
public ImFontPtr AddFontFromMemoryCompressedBase85TTF(string compressed_font_data_base85, float size_pixels, ImFontConfigPtr font_cfg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
byte* native_compressed_font_data_base85; |
|
|
|
byte* native_compressed_font_data_base85; |
|
|
|
|
|
|
|
int compressed_font_data_base85_byteCount = 0; |
|
|
|
if (compressed_font_data_base85 != null) |
|
|
|
if (compressed_font_data_base85 != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int compressed_font_data_base85_byteCount = Encoding.UTF8.GetByteCount(compressed_font_data_base85); |
|
|
|
compressed_font_data_base85_byteCount = Encoding.UTF8.GetByteCount(compressed_font_data_base85); |
|
|
|
byte* native_compressed_font_data_base85_stackBytes = stackalloc byte[compressed_font_data_base85_byteCount + 1]; |
|
|
|
if (compressed_font_data_base85_byteCount > Util.StackAllocationSizeLimit) |
|
|
|
native_compressed_font_data_base85 = native_compressed_font_data_base85_stackBytes; |
|
|
|
{ |
|
|
|
fixed (char* compressed_font_data_base85_ptr = compressed_font_data_base85) |
|
|
|
native_compressed_font_data_base85 = Util.Allocate(compressed_font_data_base85_byteCount + 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
int native_compressed_font_data_base85_offset = Encoding.UTF8.GetBytes(compressed_font_data_base85_ptr, compressed_font_data_base85.Length, native_compressed_font_data_base85, compressed_font_data_base85_byteCount); |
|
|
|
byte* native_compressed_font_data_base85_stackBytes = stackalloc byte[compressed_font_data_base85_byteCount + 1]; |
|
|
|
native_compressed_font_data_base85[native_compressed_font_data_base85_offset] = 0; |
|
|
|
native_compressed_font_data_base85 = native_compressed_font_data_base85_stackBytes; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int native_compressed_font_data_base85_offset = Util.GetUtf8(compressed_font_data_base85, native_compressed_font_data_base85, compressed_font_data_base85_byteCount); |
|
|
|
|
|
|
|
native_compressed_font_data_base85[native_compressed_font_data_base85_offset] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
else { native_compressed_font_data_base85 = null; } |
|
|
|
else { native_compressed_font_data_base85 = null; } |
|
|
|
ImFontConfig* native_font_cfg = font_cfg.NativePtr; |
|
|
|
ImFontConfig* native_font_cfg = font_cfg.NativePtr; |
|
|
|
ushort* glyph_ranges = null; |
|
|
|
ushort* glyph_ranges = null; |
|
|
|
ImFont* ret = ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(NativePtr, native_compressed_font_data_base85, size_pixels, native_font_cfg, glyph_ranges); |
|
|
|
ImFont* ret = ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(NativePtr, native_compressed_font_data_base85, size_pixels, native_font_cfg, glyph_ranges); |
|
|
|
|
|
|
|
if (compressed_font_data_base85_byteCount > Util.StackAllocationSizeLimit) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Util.Free(native_compressed_font_data_base85); |
|
|
|
|
|
|
|
} |
|
|
|
return new ImFontPtr(ret); |
|
|
|
return new ImFontPtr(ret); |
|
|
|
} |
|
|
|
} |
|
|
|
public ImFontPtr AddFontFromMemoryCompressedBase85TTF(string compressed_font_data_base85, float size_pixels, ImFontConfigPtr font_cfg, IntPtr glyph_ranges) |
|
|
|
public ImFontPtr AddFontFromMemoryCompressedBase85TTF(string compressed_font_data_base85, float size_pixels, ImFontConfigPtr font_cfg, IntPtr glyph_ranges) |
|
|
|
{ |
|
|
|
{ |
|
|
|
byte* native_compressed_font_data_base85; |
|
|
|
byte* native_compressed_font_data_base85; |
|
|
|
|
|
|
|
int compressed_font_data_base85_byteCount = 0; |
|
|
|
if (compressed_font_data_base85 != null) |
|
|
|
if (compressed_font_data_base85 != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int compressed_font_data_base85_byteCount = Encoding.UTF8.GetByteCount(compressed_font_data_base85); |
|
|
|
compressed_font_data_base85_byteCount = Encoding.UTF8.GetByteCount(compressed_font_data_base85); |
|
|
|
byte* native_compressed_font_data_base85_stackBytes = stackalloc byte[compressed_font_data_base85_byteCount + 1]; |
|
|
|
if (compressed_font_data_base85_byteCount > Util.StackAllocationSizeLimit) |
|
|
|
native_compressed_font_data_base85 = native_compressed_font_data_base85_stackBytes; |
|
|
|
{ |
|
|
|
fixed (char* compressed_font_data_base85_ptr = compressed_font_data_base85) |
|
|
|
native_compressed_font_data_base85 = Util.Allocate(compressed_font_data_base85_byteCount + 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
int native_compressed_font_data_base85_offset = Encoding.UTF8.GetBytes(compressed_font_data_base85_ptr, compressed_font_data_base85.Length, native_compressed_font_data_base85, compressed_font_data_base85_byteCount); |
|
|
|
byte* native_compressed_font_data_base85_stackBytes = stackalloc byte[compressed_font_data_base85_byteCount + 1]; |
|
|
|
native_compressed_font_data_base85[native_compressed_font_data_base85_offset] = 0; |
|
|
|
native_compressed_font_data_base85 = native_compressed_font_data_base85_stackBytes; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int native_compressed_font_data_base85_offset = Util.GetUtf8(compressed_font_data_base85, native_compressed_font_data_base85, compressed_font_data_base85_byteCount); |
|
|
|
|
|
|
|
native_compressed_font_data_base85[native_compressed_font_data_base85_offset] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
else { native_compressed_font_data_base85 = null; } |
|
|
|
else { native_compressed_font_data_base85 = null; } |
|
|
|
ImFontConfig* native_font_cfg = font_cfg.NativePtr; |
|
|
|
ImFontConfig* native_font_cfg = font_cfg.NativePtr; |
|
|
|
ushort* native_glyph_ranges = (ushort*)glyph_ranges.ToPointer(); |
|
|
|
ushort* native_glyph_ranges = (ushort*)glyph_ranges.ToPointer(); |
|
|
|
ImFont* ret = ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(NativePtr, native_compressed_font_data_base85, size_pixels, native_font_cfg, native_glyph_ranges); |
|
|
|
ImFont* ret = ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(NativePtr, native_compressed_font_data_base85, size_pixels, native_font_cfg, native_glyph_ranges); |
|
|
|
|
|
|
|
if (compressed_font_data_base85_byteCount > Util.StackAllocationSizeLimit) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Util.Free(native_compressed_font_data_base85); |
|
|
|
|
|
|
|
} |
|
|
|
return new ImFontPtr(ret); |
|
|
|
return new ImFontPtr(ret); |
|
|
|
} |
|
|
|
} |
|
|
|
public ImFontPtr AddFontFromMemoryCompressedTTF(IntPtr compressed_font_data, int compressed_font_size, float size_pixels) |
|
|
|
public ImFontPtr AddFontFromMemoryCompressedTTF(IntPtr compressed_font_data, int compressed_font_size, float size_pixels) |
|
|
|