{"record":{"id":"52654181cb74e5fd","repo":"dotnet/wpf","slug":"sr-glyphsclusterbadcharactersbeforebracket","errorCode":null,"errorMessage":"SR.GlyphsClusterBadCharactersBeforeBracket","messagePattern":"SR\\.GlyphsClusterBadCharactersBeforeBracket","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Glyphs.cs","lineNumber":407,"sourceCode":"        /// <returns>true if glyph index is present, false if glyph index is not present.</returns>\n        private bool ReadGlyphIndex(\n            ReadOnlySpan<char> valueSpec,\n            ref bool           inCluster,\n            ref int            glyphClusterSize,\n            ref int            characterClusterSize,\n            ref ushort         glyphIndex)\n        {\n            // the format is ... [(CharacterClusterSize[:GlyphClusterSize])] GlyphIndex ...\n            ReadOnlySpan<char> glyphIndexString = valueSpec;\n\n            int firstBracket = valueSpec.IndexOf('(');\n            if (firstBracket != -1)\n            {\n                // Only spaces are allowed before the bracket\n                for (int i=0; i<firstBracket; i++)\n                {\n                    if (!Char.IsWhiteSpace(valueSpec[i]))\n                        throw new ArgumentException(SR.GlyphsClusterBadCharactersBeforeBracket);\n                }\n\n                if (inCluster)\n                    throw new ArgumentException(SR.GlyphsClusterNoNestedClusters);\n\n                int secondBracket = valueSpec.IndexOf(')');\n                if (secondBracket == -1 || secondBracket <= firstBracket + 1)\n                    throw new ArgumentException(SR.GlyphsClusterNoMatchingBracket);\n\n                // look for colon separator\n                int colon = valueSpec.IndexOf(':');\n                if (colon == -1)\n                {\n                    // parse glyph cluster size\n                    ReadOnlySpan<char> characterClusterSpec = valueSpec.Slice(firstBracket + 1, secondBracket - (firstBracket + 1));\n                    characterClusterSize = int.Parse(characterClusterSpec, provider: CultureInfo.InvariantCulture);\n                    glyphClusterSize = 1;\n                }","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Glyphs.cs#L389-L425","documentation":"Glyph index specs support cluster syntax '(a,b,c)' inside the Indices string. ParseGlyphsProperty's ReadGlyphIndex requires that only whitespace precede the opening '(' of a cluster; any other character before it throws this ArgumentException.","triggerScenarios":"An Indices value where a cluster opening bracket follows a non-whitespace character, e.g. '12(3,4)' or 'a(1,2)'.","commonSituations":"Hand-written Indices strings missing the semicolon or comma separator before a cluster; converter output concatenating glyph indexes and clusters without a separator.","solutions":["Insert a separator (e.g. ';') or space between the preceding glyph index and the cluster bracket","Ensure cluster groups like '(a,b)' start at the beginning of the spec or after valid separators","Validate the Indices string against the Glyphs cluster grammar"],"exampleFix":"// before\nIndices=\"12(3,4)\"\n// after\nIndices=\"12;(3,4)\"","handlingStrategy":"validation","validationCode":"int i = indices.IndexOf('(');\nbool ok = i <= 0 || indices.Take(i).All(char.IsWhiteSpace);","typeGuard":null,"tryCatchPattern":"try { glyphs.Indices = value; } catch (ArgumentException) { /* insert ';' separator before '(' */ }","preventionTips":["Separate cluster groups with ';' or whitespace","Follow the Glyphs.Indices grammar when generating strings","Test index strings through ParseGlyphsProperty before use"],"tags":["wpf","glyphs","indices-parsing"],"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-21T21:30:21.729Z"}