mirror of
https://github.com/Not-Nik/raylib-zig.git
synced 2025-09-09 03:57:29 +00:00
Fix issues with slices in font loading functions (#47)
This commit is contained in:
parent
4bb6b605e4
commit
c08e5f51c2
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user