diff --git a/lib/generate_functions.py b/lib/generate_functions.py index 1630134..84c7cbc 100644 --- a/lib/generate_functions.py +++ b/lib/generate_functions.py @@ -238,7 +238,7 @@ def parse_header(header_name: str, output_file: str, ext_file: str, prefix: str, zig_arguments = ", ".join(zig_arguments) zig_call_args = ", ".join(zig_call_args) - if func_name in ["TextFormat", "LoadShader", "LoadShaderFromMemory"]: + if func_name in ["TextFormat", "LoadShader", "LoadShaderFromMemory", "LoadFontFromMemory"]: continue zig_return = ziggify_type(func_name, return_type) diff --git a/lib/preludes/raylib-zig-prelude.zig b/lib/preludes/raylib-zig-prelude.zig index edfb93a..25683b3 100755 --- a/lib/preludes/raylib-zig-prelude.zig +++ b/lib/preludes/raylib-zig-prelude.zig @@ -958,10 +958,18 @@ pub fn loadImagePalette(image: Image, maxPaletteSize: i32) []Color { return res; } -pub fn loadFontData(fileData: []const u8, dataSize: i32, fontSize: i32, fontChars: []i32, glyphCount: i32, ty: i32) []GlyphInfo { +pub fn loadFontFromMemory(fileType: []const u8, fileData: ?[]const u8, fontSize: i32, fontChars: []i32) Font { + var fileDataFinal = @as([*c]const u8, 0); + if (fileData) |fileDataSure| { + fileDataFinal = @ptrCast([*c]const u8, fileDataSure); + } + return cdef.LoadFontFromMemory(@ptrCast([*c]const u8, fileType), @ptrCast([*c]const u8, fileDataFinal), @as(c_int, fileData.len), @as(c_int, fontSize), @ptrCast([*c]c_int, fontChars), @as(c_int, fontChars.len)); +} + +pub fn loadFontData(fileData: []const u8, fontSize: i32, fontChars: []i32, ty: i32) []GlyphInfo { var res: []GlyphInfo = undefined; - res.ptr = @ptrCast([*]GlyphInfo, cdef.LoadFontData(@ptrCast([*c]const u8, fileData), @as(c_int, dataSize), @as(c_int, fontSize), @ptrCast([*c]c_int, fontChars), @as(c_int, glyphCount), @as(c_int, ty))); - res.len = @intCast(usize, glyphCount); + res.ptr = @ptrCast([*]GlyphInfo, cdef.LoadFontData(@ptrCast([*c]const u8, fileData), @as(c_int, fileData.len), @as(c_int, fontSize), @ptrCast([*c]c_int, fontChars), @as(c_int, fontChars.len), @as(c_int, ty))); + res.len = @intCast(usize, fontChars.len); return res; } diff --git a/lib/raylib-zig.zig b/lib/raylib-zig.zig index 46e67bb..9f2fb62 100644 --- a/lib/raylib-zig.zig +++ b/lib/raylib-zig.zig @@ -958,10 +958,18 @@ pub fn loadImagePalette(image: Image, maxPaletteSize: i32) []Color { return res; } -pub fn loadFontData(fileData: []const u8, dataSize: i32, fontSize: i32, fontChars: []i32, glyphCount: i32, ty: i32) []GlyphInfo { +pub fn loadFontFromMemory(fileType: []const u8, fileData: ?[]const u8, fontSize: i32, fontChars: []i32) Font { + var fileDataFinal = @as([*c]const u8, 0); + if (fileData) |fileDataSure| { + fileDataFinal = @ptrCast([*c]const u8, fileDataSure); + } + return cdef.LoadFontFromMemory(@ptrCast([*c]const u8, fileType), @ptrCast([*c]const u8, fileDataFinal), @as(c_int, fileData.len), @as(c_int, fontSize), @ptrCast([*c]c_int, fontChars), @as(c_int, fontChars.len)); +} + +pub fn loadFontData(fileData: []const u8, fontSize: i32, fontChars: []i32, ty: i32) []GlyphInfo { var res: []GlyphInfo = undefined; - res.ptr = @ptrCast([*]GlyphInfo, cdef.LoadFontData(@ptrCast([*c]const u8, fileData), @as(c_int, dataSize), @as(c_int, fontSize), @ptrCast([*c]c_int, fontChars), @as(c_int, glyphCount), @as(c_int, ty))); - res.len = @intCast(usize, glyphCount); + res.ptr = @ptrCast([*]GlyphInfo, cdef.LoadFontData(@ptrCast([*c]const u8, fileData), @as(c_int, fileData.len), @as(c_int, fontSize), @ptrCast([*c]c_int, fontChars), @as(c_int, fontChars.len), @as(c_int, ty))); + res.len = @intCast(usize, fontChars.len); return res; } @@ -2343,10 +2351,6 @@ pub fn loadFontFromImage(image: Image, key: Color, firstChar: i32) Font { return cdef.LoadFontFromImage(image, key, @as(c_int, firstChar)); } -pub fn loadFontFromMemory(fileType: []const u8, fileData: []const u8, dataSize: i32, fontSize: i32, fontChars: []i32, glyphCount: i32) Font { - return cdef.LoadFontFromMemory(@ptrCast([*c]const u8, fileType), @ptrCast([*c]const u8, fileData), @as(c_int, dataSize), @as(c_int, fontSize), @ptrCast([*c]c_int, fontChars), @as(c_int, glyphCount)); -} - pub fn genImageFontAtlas(chars: []const GlyphInfo, recs: [][]Rectangle, glyphCount: i32, fontSize: i32, padding: i32, packMethod: i32) Image { return cdef.GenImageFontAtlas(@ptrCast([*c]const GlyphInfo, chars), @ptrCast([*c][*c]Rectangle, recs), @as(c_int, glyphCount), @as(c_int, fontSize), @as(c_int, padding), @as(c_int, packMethod)); }