src/gui/font_options.zig
Ref: Size: 890 B History
//! Shared font option validation for config files and native CLI flags.
const std = @import("std");
pub const Error = error{InvalidValue};
/// Ghostty-style point size: finite, inclusive range 1–192 points.
/// The upper limit is 256 pixels at Linux's 96 DPI and 100% display scale.
pub fn parsePointSize(text: []const u8) Error!f64 {
const value = std.fmt.parseFloat(f64, text) catch return error.InvalidValue;
if (!std.math.isFinite(value) or value < 1 or value > 192) return error.InvalidValue;
return value;
}
test "point size validation is shared and bounded" {
try std.testing.expectEqual(@as(f64, 12.5), try parsePointSize("12.5"));
try std.testing.expectError(error.InvalidValue, parsePointSize("nan"));
try std.testing.expectError(error.InvalidValue, parsePointSize("0"));
try std.testing.expectError(error.InvalidValue, parsePointSize("193"));
}