{"record":{"id":"70a13400827ac674","repo":"iOfficeAI/OfficeCLI","slug":"invalid-font-size-value-maximum-font-size-is","errorCode":null,"errorMessage":"Invalid font size: '{value}'. Maximum font size is 4000pt (Office cap).","messagePattern":"Invalid font size: '(.+?)'\\. Maximum font size is 4000pt \\(Office cap\\)\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/ParseHelpers.cs","lineNumber":383,"sourceCode":"            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\n    /// <c>InnerText</c> and routing it through this helper truncates the\n    /// fractional part to an int (matching Word's own tolerance for these\n    /// attributes), so dump/get no longer crash on such files.\n    ///\n    /// Returns null when <paramref name=\"raw\"/> is null/blank or cannot be\n    /// parsed even leniently.\n    /// </summary>\n    public static int? LenientInt(string? raw)","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/ParseHelpers.cs#L365-L401","documentation":"Thrown by ParseFontSize when the size exceeds 4000pt. Office caps user-entered sizes at 1638pt (Word) and renderers stop honoring values past ~4000pt; larger values overflow the int32 the writers cast to (PPTX writes pt*100, Word pt*2 as half-points), producing negative w:sz/a:rPr@sz values Word rejects on open. The library rejects up front rather than emitting corrupt output.","triggerScenarios":"Passing \"5000\" or a size scaled up by a bug. A unit confusion where points were treated as half-points and doubled.","commonSituations":"A multiplier bug inflating sizes; feeding a value intended as half-points directly as points; stress-test inputs.","solutions":["Use a size at or below 4000pt.","Clamp: Math.Min(pts, 4000).","Audit code that multiplies sizes to ensure it stays within the Office cap."],"exampleFix":"// before\nvar pts = halfPoints * 2 * 10; // unintended inflation\nParseFontSize(pts.ToString(CultureInfo.InvariantCulture)); // throws 296\n\n// after\nvar pts = Math.Min(halfPoints * 2, 4000.0);\nParseFontSize(pts.ToString(CultureInfo.InvariantCulture));","handlingStrategy":"validation","validationCode":"const double MaxPt = 4000;\npts = Math.Min(pts, MaxPt);","typeGuard":"static bool IsWithinOfficeCap(double v) => v <= 4000 && !double.IsNaN(v) && !double.IsInfinity(v);","tryCatchPattern":"try { pts = ParseFontSize(s); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"4000pt\"))\n{ pts = 4000; }","preventionTips":["Clamp sizes to <= 4000pt.","Audit multipliers that could inflate sizes.","Confirm you are passing points, not half-points."],"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"}