From 4592dd807d7aed5d5b7d56bdf88d05a253b13ab4 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 15 Jul 2025 12:36:50 +0200 Subject: [PATCH] fix: allow font names longer than 31 characters in win32 closes #275 --- src/win32/FontFace.zig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/win32/FontFace.zig b/src/win32/FontFace.zig index 6bf2e81..811340e 100644 --- a/src/win32/FontFace.zig +++ b/src/win32/FontFace.zig @@ -2,11 +2,13 @@ const FontFace = @This(); const std = @import("std"); -// it seems that Windows only supports font faces with up to 31 characters -pub const max = 31; +// it seems that Windows only supports font faces with up to 31 characters, +// but we use a larger buffer here because GetFamilyNames can apparently +// return longer strings +pub const max = 254; buf: [max + 1]u16, -len: u5, +len: usize, pub fn initUtf8(utf8: []const u8) error{ TooLong, InvalidUtf8 }!FontFace { const utf16_len = std.unicode.calcUtf16LeLen(utf8) catch return error.InvalidUtf8;