{"record":{"id":"8b118106b89fb5a4","repo":"iOfficeAI/OfficeCLI","slug":"invalid-font-size-value-minimum-font-size-is","errorCode":null,"errorMessage":"Invalid font size: '{value}'. Minimum font size is 0.5pt (one half-point).","messagePattern":"Invalid font size: '(.+?)'\\. Minimum font size is 0\\.5pt \\(one half-point\\)\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/ParseHelpers.cs","lineNumber":375,"sourceCode":"    /// Returns double to preserve fractional sizes for correct unit conversion.\n    /// </summary>\n    public static double ParseFontSize(string value)\n    {\n        var trimmed = value.Trim();\n        if (trimmed.EndsWith(\"pt\", StringComparison.OrdinalIgnoreCase))\n            trimmed = trimmed[..^2].Trim();\n        if (trimmed.Contains(','))\n            throw new ArgumentException($\"Invalid font size: '{value}'. Comma is not allowed — use '.' as decimal separator (e.g., '10.5').\");\n        if (!double.TryParse(trimmed, CultureInfo.InvariantCulture, out var result) || double.IsNaN(result) || double.IsInfinity(result))\n            throw new ArgumentException($\"Invalid font size: '{value}'. Expected a finite number (e.g., '12', '10.5', '14pt').\");\n        if (result <= 0)\n            throw new ArgumentException($\"Invalid font size: '{value}'. Font size must be greater than 0.\");\n        // OOXML w:sz/w:szCs/w:fontSize are half-points and must be >= 1.\n        // Anything below 0.5pt would round to val=0 on write, producing\n        // schema-invalid OOXML. Reject up front with the same shape as\n        // the \"<= 0\" guard above.\n        if (result < 0.5)\n            throw new ArgumentException($\"Invalid font size: '{value}'. Minimum font size is 0.5pt (one half-point).\");\n        // OOXML caps user-entered font size at 1638pt (Word) and Office\n        // renderers stop honoring values past ~4000pt anyway. Anything\n        // larger silently overflows the int32 the writers cast to (PPTX\n        // writes pt × 100, Word writes pt × 2 as half-points), producing\n        // negative w:sz / a:rPr@sz values Word rejects on open. Reject\n        // up front with the same shape as the lower-bound guards.\n        if (result > 4000)\n            throw new ArgumentException($\"Invalid font size: '{value}'. Maximum font size is 4000pt (Office cap).\");\n        return result;\n    }\n\n    /// <summary>\n    /// BUG-R4B(BUG1): Leniently parse an integer-valued OOXML attribute that\n    /// some producers emit with a fractional part (e.g. <c>w:w=\"0.0\"</c> /\n    /// <c>w:w=\"9440.0\"</c>). The Open XML SDK's typed accessors (e.g.\n    /// <c>Int32Value.Value</c>) parse the raw string lazily and throw a bare\n    /// <see cref=\"FormatException\"/> (\"The input string '0.0' was not in a\n    /// correct format\") the first time the value is read. Reading the raw","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/ParseHelpers.cs#L357-L393","documentation":"Thrown by ParseFontSize when the size is positive but below 0.5pt. OOXML stores font size as half-points (w:sz must be >= 1), so anything below 0.5pt would round to val=0 on write and produce schema-invalid OOXML that Word rejects. The library rejects up front with the same message shape as the other guards.","triggerScenarios":"Passing \"0.25\" or \"0.3\". A fractional size from a scaling factor that shrank the font below half a point.","commonSituations":"Responsive/scaling code that multiplies by a small factor; converting from a unit where the result is sub-half-point; debug values entered during testing.","solutions":["Use a size of at least 0.5pt.","Clamp the computed size: Math.Max(pts, 0.5).","Re-check scale factors that can shrink text below readable sizes."],"exampleFix":"// before\nvar pts = baseSize * 0.01; // -> 0.12\nParseFontSize(pts.ToString(CultureInfo.InvariantCulture)); // throws 295\n\n// after\nvar pts = Math.Max(baseSize * 0.01, 0.5);\nParseFontSize(pts.ToString(CultureInfo.InvariantCulture));","handlingStrategy":"validation","validationCode":"const double MinPt = 0.5;\npts = Math.Max(pts, MinPt);","typeGuard":"static bool IsAtLeastHalfPoint(double v) => v >= 0.5 && !double.IsNaN(v) && !double.IsInfinity(v);","tryCatchPattern":"try { pts = ParseFontSize(s); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"0.5pt\"))\n{ pts = 0.5; }","preventionTips":["Clamp computed sizes to >= 0.5pt.","Re-check scale factors that can shrink text below readable sizes.","Unit-test the lower boundary explicitly."],"tags":["font","validation","argument","range","ooxml"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}