font: handle CRLF line endings in octants.txt parsing

Trim trailing \r when splitting octants.txt by \n at comptime. On
Windows, git may convert LF to CRLF on checkout, leaving \r at the
end of each line. Without trimming, the parser tries to use \r as
a struct field name in @field(), causing a compile error.

Follows the same pattern used in x11_color.zig for rgb.txt parsing.
pull/11839/head
Alessandro De Blasis 2026-03-26 01:29:13 +01:00 committed by Mitchell Hashimoto
parent fead488d23
commit 650b9d470a
1 changed files with 8 additions and 1 deletions

View File

@ -102,7 +102,14 @@ pub fn draw1CD00_1CDE5(
const data = @embedFile("octants.txt");
var it = std.mem.splitScalar(u8, data, '\n');
while (it.next()) |line| {
while (it.next()) |raw_line| {
// Trim \r so this works with both LF and CRLF line endings,
// since git may convert octants.txt to CRLF on Windows checkouts.
const line = if (raw_line.len > 0 and raw_line[raw_line.len - 1] == '\r')
raw_line[0 .. raw_line.len - 1]
else
raw_line;
// Skip comments
if (line.len == 0 or line[0] == '#') continue;