fix: allow font names longer than 31 characters in win32

closes #275
This commit is contained in:
CJ van den Berg 2025-07-15 12:36:50 +02:00
parent 09c890970e
commit 4592dd807d
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -2,11 +2,13 @@ const FontFace = @This();
const std = @import("std"); const std = @import("std");
// it seems that Windows only supports font faces with up to 31 characters // it seems that Windows only supports font faces with up to 31 characters,
pub const max = 31; // but we use a larger buffer here because GetFamilyNames can apparently
// return longer strings
pub const max = 254;
buf: [max + 1]u16, buf: [max + 1]u16,
len: u5, len: usize,
pub fn initUtf8(utf8: []const u8) error{ TooLong, InvalidUtf8 }!FontFace { pub fn initUtf8(utf8: []const u8) error{ TooLong, InvalidUtf8 }!FontFace {
const utf16_len = std.unicode.calcUtf16LeLen(utf8) catch return error.InvalidUtf8; const utf16_len = std.unicode.calcUtf16LeLen(utf8) catch return error.InvalidUtf8;