embed font instead of loading it at runtime

This commit is contained in:
johan0A 2024-09-23 18:35:57 +02:00
parent 904b915d31
commit 890b713e2c
2 changed files with 5 additions and 12 deletions

View file

@ -6,8 +6,8 @@
.path = "../../", .path = "../../",
}, },
.@"raylib-zig" = .{ .@"raylib-zig" = .{
.url = "https://github.com/Not-Nik/raylib-zig/archive/f26b2ab084be5e2840b7451818590cc512b7b972.tar.gz", .url = "https://github.com/johan0A/raylib-zig/archive/db141613a6d5fc7c3c94a52965669c0e86444c50.tar.gz",
.hash = "1220fc554f109a45a77ee5c58b4a847936dc0b24dcbed818b65a02de1b58500041dc", .hash = "1220a100a2f60cf4c970110666b9f3607fa388c5544de0311df2c36898b516e424b4",
}, },
}, },
.paths = .{ .paths = .{

View file

@ -86,14 +86,8 @@ fn createLayout(profile_picture: *const rl.Texture2D) cl.ClayArray(cl.RenderComm
return cl.endLayout(); return cl.endLayout();
} }
// TODO: fix raylib bindings to allow this or replace raylib bindings fn loadFont(file_data: ?[]const u8, fontId: u16, fontSize: i32) void {
// fn loadFont(file_data: ?[]const u8, fontId: u16, fontSize: i32) void { renderer.raylib_fonts[fontId] = rl.loadFontFromMemory(".ttf", file_data, fontSize * 2, null);
// renderer.raylib_fonts[fontId] = rl.loadFontFromMemory(".ttf", file_data, fontSize * 2, null);
// rl.setTextureFilter(renderer.raylib_fonts[fontId].?.texture, .texture_filter_trilinear);
// }
fn loadFont(fileName: [*:0]const u8, fontId: u16, fontSize: i32) void {
renderer.raylib_fonts[fontId] = rl.loadFontEx(fileName, fontSize, null);
rl.setTextureFilter(renderer.raylib_fonts[fontId].?.texture, .texture_filter_trilinear); rl.setTextureFilter(renderer.raylib_fonts[fontId].?.texture, .texture_filter_trilinear);
} }
@ -117,8 +111,7 @@ pub fn main() anyerror!void {
rl.initWindow(1000, 1000, "Raylib zig Example"); rl.initWindow(1000, 1000, "Raylib zig Example");
rl.setTargetFPS(60); rl.setTargetFPS(60);
// loadFont(@embedFile("./resources/Roboto-Regular.ttf"), 0, 100); loadFont(@embedFile("./resources/Roboto-Regular.ttf"), 0, 100);
loadFont("./src/resources/Roboto-Regular.ttf", 0, 100);
const profile_picture = rl.loadTextureFromImage(rl.loadImageFromMemory(".png", @embedFile("./resources/profile-picture.png"))); const profile_picture = rl.loadTextureFromImage(rl.loadImageFromMemory(".png", @embedFile("./resources/profile-picture.png")));
var debug_mode_enabled = false; var debug_mode_enabled = false;