{"record":{"id":"775a22eee1cb55ea","repo":"dotnet/wpf","slug":"sr-glyphtypefacenotrecorded","errorCode":null,"errorMessage":"SR.GlyphTypefaceNotRecorded","messagePattern":"SR\\.GlyphTypefaceNotRecorded","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FontEmbeddingManager.cs","lineNumber":87,"sourceCode":"                return _collectedGlyphTypefaces.Keys;\n            }\n        }\n\n        /// <summary>\n        /// Obtain the list of glyphs used by the glyph typeface specified by a Uri.\n        /// </summary>\n        /// <param name=\"glyphTypeface\">Specifies the Uri of a glyph typeface to obtain usage data for.</param>\n        /// <returns>A collection of glyph indices recorded previously.</returns>\n        /// <exception cref=\"System.ArgumentException\">\n        ///     Glyph typeface Uri does not point to a previously recorded glyph typeface.\n        /// </exception>\n        [CLSCompliant(false)]\n        public ICollection<ushort> GetUsedGlyphs(Uri glyphTypeface)\n        {\n            Dictionary<ushort, bool> glyphsUsed = _collectedGlyphTypefaces[glyphTypeface];\n            if (glyphsUsed == null)\n            {\n                throw new ArgumentException(SR.GlyphTypefaceNotRecorded, nameof(glyphTypeface));\n            }\n            return glyphsUsed.Keys;\n        }\n\n        #endregion Public Methods\n\n        private class UriComparer : IEqualityComparer<Uri>\n        {\n            #region IEqualityComparer<Uri> Members\n\n            public bool Equals(Uri x, Uri y)\n            {\n                // We don't use Uri.Equals because it doesn't compare Fragment parts,\n                // and we use Fragment part to store font face index.\n                return String.Equals(x.ToString(), y.ToString(), StringComparison.OrdinalIgnoreCase);\n            }\n\n            public int GetHashCode(Uri obj)","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FontEmbeddingManager.cs#L69-L105","documentation":"FontEmbeddingManager.GetUsedGlyphs throws this ArgumentException when the supplied glyphTypeface Uri was never recorded by a previous CollectGlyphTypefaces/embedding pass, so _collectedGlyphTypefaces contains no entry (or the stored entry is null). The method can only report glyphs for typefaces the manager has actually collected.","triggerScenarios":"Calling GetUsedGlyphs(uri) with a Uri that was never passed to the manager's glyph-collection step (e.g. different Uri instance/equality, or GetUsedGlyphs called before any text layout occurred).","commonSituations":"Embedding workflows where the developer constructs a fresh FontEmbeddingManager and asks for used glyphs without first running the collection that populates the dictionary, or querying a font Uri that differs from the one actually used at render time.","solutions":["Ensure the glyph typefaces were collected first (render/layout text through the manager) before calling GetUsedGlyphs.","Use the exact same glyphTypeface Uri that was recorded during collection.","Check the Uri equals the keys recorded (scheme/casing differences produce different dictionary keys)."],"exampleFix":"// before\nvar mgr = new FontEmbeddingManager();\nvar glyphs = mgr.GetUsedGlyphs(fontUri); // never recorded\n// after\nvar mgr = new FontEmbeddingManager();\nmgr.CollectGlyphTypefaces(textSource...); // run collection\nvar glyphs = mgr.GetUsedGlyphs(fontUri);","handlingStrategy":"validation","validationCode":"if (fontUri == null) throw new ArgumentNullException(nameof(fontUri));\n// ensure collection happened; only query Uris produced by/used during collection","typeGuard":null,"tryCatchPattern":"try { var glyphs = manager.GetUsedGlyphs(fontUri); }\ncatch (ArgumentException) { /* glyphTypeface was never recorded; run collection first */ }","preventionTips":["Run the glyph collection pass before querying GetUsedGlyphs.","Keep and reuse the exact Uri instances that were collected.","Normalize Uris (scheme, casing, trailing slash) before both collecting and querying."],"tags":["wpf","fonts","argumentexception","glyph-embedding"],"backgroundTag":"record-not-found","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"}