iOfficeAI/OfficeCLI · error · ArgumentException
Invalid font size: '{value}'. Comma is not allowed — use '.'
Error message
Invalid font size: '{value}'. Comma is not allowed — use '.' as decimal separator (e.g., '10.5'). What it means
Thrown by ParseFontSize when the size string contains a comma. officecli uses the invariant culture, so the decimal separator must be '.'; a comma (common in locales like de-DE) is rejected explicitly with a pointer to the correct format so users do not get a generic parse failure.
Source
Thrown at src/officecli/Core/ParseHelpers.cs:365
/// Returns true if the value is a recognized boolean string (truthy or falsy).
/// Returns false for null, empty, or non-boolean values (no exception thrown).
/// </summary>
public static bool IsValidBooleanString(string? value) =>
value != null && TrimInvisible(value).ToLowerInvariant() is "true" or "1" or "yes" or "on"
or "false" or "0" or "no" or "off";
/// <summary>
/// Parse a font size string, stripping optional "pt" suffix.
/// Supports integers and fractional values (e.g. "24", "10.5", "24pt").
/// Returns double to preserve fractional sizes for correct unit conversion.
/// </summary>
public static double ParseFontSize(string value)
{
var trimmed = value.Trim();
if (trimmed.EndsWith("pt", StringComparison.OrdinalIgnoreCase))
trimmed = trimmed[..^2].Trim();
if (trimmed.Contains(','))
throw new ArgumentException($"Invalid font size: '{value}'. Comma is not allowed — use '.' as decimal separator (e.g., '10.5').");
if (!double.TryParse(trimmed, CultureInfo.InvariantCulture, out var result) || double.IsNaN(result) || double.IsInfinity(result))
throw new ArgumentException($"Invalid font size: '{value}'. Expected a finite number (e.g., '12', '10.5', '14pt').");
if (result <= 0)
throw new ArgumentException($"Invalid font size: '{value}'. Font size must be greater than 0.");
// OOXML w:sz/w:szCs/w:fontSize are half-points and must be >= 1.
// Anything below 0.5pt would round to val=0 on write, producing
// schema-invalid OOXML. Reject up front with the same shape as
// the "<= 0" guard above.
if (result < 0.5)
throw new ArgumentException($"Invalid font size: '{value}'. Minimum font size is 0.5pt (one half-point).");
// OOXML caps user-entered font size at 1638pt (Word) and Office
// renderers stop honoring values past ~4000pt anyway. Anything
// larger silently overflows the int32 the writers cast to (PPTX
// writes pt × 100, Word writes pt × 2 as half-points), producing
// negative w:sz / a:rPr@sz values Word rejects on open. Reject
// up front with the same shape as the lower-bound guards.
if (result > 4000)
throw new ArgumentException($"Invalid font size: '{value}'. Maximum font size is 4000pt (Office cap).");View on GitHub (pinned to 1ced45e900)
Solutions
- Use a dot decimal separator: "10.5".
- Format doubles with CultureInfo.InvariantCulture: size.ToString(CultureInfo.InvariantCulture).
- Strip thousands separators before parsing.
Example fix
// before var s = fontSize.ToString(); // "10,5" on de-DE ParseFontSize(s); // throws 292 // after var s = fontSize.ToString(CultureInfo.InvariantCulture); // "10.5" ParseFontSize(s);
Defensive patterns
Strategy: validation
Validate before calling
var s = size.ToString(CultureInfo.InvariantCulture);
if (s.Contains(',')) s = s.Replace(',', '.'); Type guard
static bool IsInvariantNumber(string s) => !s.Contains(',') && double.TryParse(s, CultureInfo.InvariantCulture, out _); Try / catch
try { ParseFontSize(s); }
catch (ArgumentException ex) when (ex.Message.Contains("Comma is not allowed"))
{ s = s.Replace(',', '.'); ParseFontSize(s); } Prevention
- Always format doubles with CultureInfo.InvariantCulture.
- Set the thread culture to invariant for serialization.
- Reject comma input at the UI/config boundary.
When it happens
Trigger: Passing "10,5" (European decimal), "1,000" (thousands separator), or any size string with a comma. Often happens when the value was formatted with the current culture instead of invariant.
Common situations: Running on a machine with a comma-decimal locale; serializing a double with default ToString (culture-aware) instead of ToString(CultureInfo.InvariantCulture); user typing a size in their local format.
Related errors
- Invalid font size: '{value}'. Expected a finite number (e.g.
- Invalid font size: '{value}'. Font size must be greater than
- Invalid font size: '{value}'. Minimum font size is 0.5pt (on
- Invalid font size: '{value}'. Maximum font size is 4000pt (O
- Invalid '{propertyName}' value '{value}'. Expected an intege
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/8291435cd84d4612.
Report an issue: GitHub.