Allow not specifiying codepoints in loadFontEx (#110)

This commit is contained in:
Not-Nik 2024-06-25 20:01:25 +02:00
parent fb11a4e1c8
commit 1dab3352b3
No known key found for this signature in database
GPG Key ID: E95F679E3CDD9784
2 changed files with 20 additions and 8 deletions

View File

@ -1815,6 +1815,16 @@ pub fn loadImagePalette(image: Image, maxPaletteSize: i32) RaylibError![]Color {
return res;
}
pub fn loadFontEx(fileName: [:0]const u8, fontSize: i32, fontChars: ?[]i32) Font {
var fontCharsFinal = @as([*c]c_int, 0);
var fontCharsLen: c_int = @as(c_int, 0);
if (fontChars) |fontCharsSure| {
fontCharsFinal = @as([*c]c_int, @ptrCast(fontCharsSure));
fontCharsLen = @as(i32, @intCast(fontCharsSure.len));
}
return cdef.LoadFontEx(@as([*c]const u8, @ptrCast(fileName)), @as(c_int, fontSize), fontCharsFinal, fontCharsLen);
}
pub fn loadFontFromMemory(fileType: [:0]const u8, fileData: ?[]const u8, fontSize: i32, fontChars: []i32) Font {
var fileDataFinal = @as([*c]const u8, 0);
var fileDataLen: i32 = 0;
@ -1939,10 +1949,6 @@ pub fn checkCollisionPointPoly(point: Vector2, points: []Vector2) bool {
return cdef.CheckCollisionPointPoly(point, @as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len)));
}
pub fn loadFontEx(fileName: [:0]const u8, fontSize: i32, fontChars: []i32) Font {
return cdef.LoadFontEx(@as([*c]const u8, @ptrCast(fileName)), @as(c_int, fontSize), @as([*c]c_int, @ptrCast(fontChars)), @as(c_int, @intCast(fontChars.len)));
}
pub fn genImageFontAtlas(chars: []const GlyphInfo, recs: [][]Rectangle, fontSize: i32, padding: i32, packMethod: i32) Image {
return cdef.GenImageFontAtlas(@as([*c]const GlyphInfo, @ptrCast(chars)), @as([*c][*c]Rectangle, @ptrCast(recs)), @as(c_int, @intCast(recs.len)), @as(c_int, fontSize), @as(c_int, padding), @as(c_int, packMethod));
}

View File

@ -1815,6 +1815,16 @@ pub fn loadImagePalette(image: Image, maxPaletteSize: i32) RaylibError![]Color {
return res;
}
pub fn loadFontEx(fileName: [:0]const u8, fontSize: i32, fontChars: ?[]i32) Font {
var fontCharsFinal = @as([*c]c_int, 0);
var fontCharsLen: c_int = @as(c_int, 0);
if (fontChars) |fontCharsSure| {
fontCharsFinal = @as([*c]c_int, @ptrCast(fontCharsSure));
fontCharsLen = @as(i32, @intCast(fontCharsSure.len));
}
return cdef.LoadFontEx(@as([*c]const u8, @ptrCast(fileName)), @as(c_int, fontSize), fontCharsFinal, fontCharsLen);
}
pub fn loadFontFromMemory(fileType: [:0]const u8, fileData: ?[]const u8, fontSize: i32, fontChars: []i32) Font {
var fileDataFinal = @as([*c]const u8, 0);
var fileDataLen: i32 = 0;
@ -1939,10 +1949,6 @@ pub fn checkCollisionPointPoly(point: Vector2, points: []Vector2) bool {
return cdef.CheckCollisionPointPoly(point, @as([*c]Vector2, @ptrCast(points)), @as(c_int, @intCast(points.len)));
}
pub fn loadFontEx(fileName: [:0]const u8, fontSize: i32, fontChars: []i32) Font {
return cdef.LoadFontEx(@as([*c]const u8, @ptrCast(fileName)), @as(c_int, fontSize), @as([*c]c_int, @ptrCast(fontChars)), @as(c_int, @intCast(fontChars.len)));
}
pub fn genImageFontAtlas(chars: []const GlyphInfo, recs: [][]Rectangle, fontSize: i32, padding: i32, packMethod: i32) Image {
return cdef.GenImageFontAtlas(@as([*c]const GlyphInfo, @ptrCast(chars)), @as([*c][*c]Rectangle, @ptrCast(recs)), @as(c_int, @intCast(recs.len)), @as(c_int, fontSize), @as(c_int, padding), @as(c_int, packMethod));
}