{"record":{"id":"796c046102e85f71","repo":"dotnet/wpf","slug":"sr-glyphstoomanycommas","errorCode":null,"errorMessage":"SR.GlyphsTooManyCommas","messagePattern":"SR\\.GlyphsTooManyCommas","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Glyphs.cs","lineNumber":616,"sourceCode":"                                        throw new ArgumentException(SR.GlyphsAdvanceWidthCannotBeNegative);\n                                }\n                                break;\n\n                            case 2:\n                                // interpret glyph offset X\n                                if (!IsEmpty(valueSpec))\n                                    parsedGlyphData.offsetX = double.Parse(valueSpec, provider: CultureInfo.InvariantCulture);\n                                break;\n\n                            case 3:\n                                // interpret glyph offset Y\n                                if (!IsEmpty(valueSpec))\n                                    parsedGlyphData.offsetY = double.Parse(valueSpec, provider: CultureInfo.InvariantCulture);\n                                break;\n\n                            default:\n                                // too many commas; can't interpret\n                                throw new ArgumentException(SR.GlyphsTooManyCommas);\n                        }\n                        #endregion Interpret one comma-delimited value\n\n                        // prepare to scan next value (if any)\n                        valueWithinGlyph++;\n                        valueStartIndex = i + 1;\n                    }\n\n                    // finished processing the current glyph?\n                    if ((c == ';') || (i == glyphsProp.Length))\n                    {\n                        parsedGlyphs.Add(parsedGlyphData);\n                        parsedGlyphData = new ParsedGlyphData();\n\n                        if (inCluster)\n                        {\n                            --glyphClusterSize;\n                            // when we reach the end of a glyph cluster, increment character index","sourceCodeStart":598,"sourceCodeEnd":634,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Glyphs.cs#L598-L634","documentation":"Thrown by Glyphs.ParseGlyphsProperty when a single glyph specification contains more comma-separated values than the parser understands. Each glyph slot accepts at most index, advance width, offset X, and offset Y (valueWithinGlyph 0..2 plus the index); anything beyond that hits the default case, which throws ArgumentException (\"too many commas\").","triggerScenarios":"A GlyphIndices string with extra trailing comma fields per glyph, e.g. \";41,10,0,0,5\" or a stray double comma producing an extra empty value slot beyond the allowed count.","commonSituations":"Generator/exporter code emitting additional per-glyph metrics WPF doesn't accept; accidental trailing commas like \";41,10,,\"; copy-paste from formats with more fields (e.g. font tool exports).","solutions":["Remove extra comma-separated fields so each glyph has at most index, advanceWidth, offsetX, offsetY.","Strip trailing/empty comma slots from each glyph spec.","In generator code, format exactly the fields supported by Glyphs.GlyphIndices."],"exampleFix":"// before\nglyphs.GlyphIndices = \";41,10.5,0,0,7\"; // 5 fields\n// after\nglyphs.GlyphIndices = \";41,10.5,0,0\";   // max 4 fields","handlingStrategy":"validation","validationCode":"static string FormatGlyphEntry(params double[] fields) { if (fields.Length > 4) throw new ArgumentException(\"Max 4 fields per glyph\"); return \";\" + string.Join(\",\", fields); }","typeGuard":"static bool FieldCountValid(string entry) => entry.Split(',').Length <= 4;","tryCatchPattern":"try { glyphs.GlyphIndices = indices; }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"comma\")) { indices = string.Join(\";\", indices.Split(';').Select(TrimToFourFields)); glyphs.GlyphIndices = indices; }","preventionTips":["Emit at most index,advanceWidth,offsetX,offsetY per glyph","Trim trailing commas from generated strings","Map foreign font-tool exports to WPF's 4-field format explicitly"],"tags":["wpf","glyphs","parsing","format-error","argumentexception"],"backgroundTag":"invalid-argument-format","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}