Fix issues with slices in font loading functions (#47)
This commit is contained in:
parent
4bb6b605e4
commit
c08e5f51c2
3 changed files with 23 additions and 11 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue