{"record":{"id":"5279c3a0d65eaed6","repo":"AvaloniaUI/Avalonia","slug":"could-not-create-glyphtypeface-font-family-font","errorCode":null,"errorMessage":"Could not create glyphTypeface. Font family: {FontFamily?.Name} (key: {FontFamily?.Key}). Style: {Style}. Weight: {Weight}. Stretch: {Stretch}","messagePattern":"Could not create glyphTypeface\\. Font family: (.+?) \\(key: (.+?)\\)\\. Style: (.+?)\\. Weight: (.+?)\\. Stretch: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Media/Typeface.cs","lineNumber":95,"sourceCode":"        /// </summary>\n        public FontStretch Stretch { get; }\n\n        /// <summary>\n        /// Gets the glyph typeface.\n        /// </summary>\n        /// <value>\n        /// The glyph typeface.\n        /// </value>\n        public GlyphTypeface GlyphTypeface\n        {\n            get\n            {\n                if(FontManager.Current.TryGetGlyphTypeface(this, out var glyphTypeface))\n                {\n                    return glyphTypeface;\n                }\n\n                throw new InvalidOperationException(\n                    $\"Could not create glyphTypeface. Font family: {FontFamily?.Name} (key: {FontFamily?.Key}). Style: {Style}. Weight: {Weight}. Stretch: {Stretch}\");\n            }\n        }\n\n        public static bool operator !=(Typeface a, Typeface b)\n        {\n            return !(a == b);\n        }\n\n        public static bool operator ==(Typeface a, Typeface b)\n        {\n            return  a.Equals(b);\n        }\n\n        public override bool Equals(object? obj)\n        {\n            return obj is Typeface typeface && Equals(typeface);\n        }","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Media/Typeface.cs#L77-L113","documentation":"Thrown by the Typeface.GlyphTypeface getter when FontManager.Current.TryGetGlyphTypeface fails to resolve a matching glyph typeface for the given Typeface (family, style, weight, stretch). This is an InvalidOperationException indicating the font could not be loaded or matched at all. The message includes the family name/key and the requested style/weight/stretch for diagnostics.","triggerScenarios":"Accessing typeface.GlyphTypeface when the FontManager cannot find or load any font matching the specified FontFamily and attributes. Happens with a missing custom font asset, an unregistered font family, an embedded resource that failed to load, or a weight/stretch combination with no fallback.","commonSituations":"Bundling a custom font but forgetting to register it or mis-specifying its family name; referencing a system font not present on the target OS (common in CI/Linux containers); NativeAOT/trimming stripping the font asset; requesting an exotic weight/stretch the installed fonts do not cover.","solutions":["Verify the FontFamily name exactly matches the font's internal family name (use a font inspection tool).","Ensure custom fonts are included as assets and the FontFamily URI points to the correct resource path.","Provide fallback fonts so FontManager can substitute when the primary is unavailable.","On CI/headless environments, install the required system fonts or ship embedded font assets.","For trimming/NativeAOT, ensure font resources are not trimmed and the font loader is rooted."],"exampleFix":"// before\nvar tf = new Typeface(new FontFamily(\"MyCustomFont\")); // not registered\nvar glyph = tf.GlyphTypeface; // throws\n\n// after\nvar tf = new Typeface(new FontFamily(\"avares://MyApp/Assets/Fonts/#MyCustomFont\"));\nvar glyph = tf.GlyphTypeface;","handlingStrategy":"validation","validationCode":"static bool CanResolveGlyphTypeface(Typeface tf)\n    => FontManager.Current.TryGetGlyphTypeface(tf, out _);","typeGuard":null,"tryCatchPattern":"try { return tf.GlyphTypeface; }\ncatch (InvalidOperationException) { return fallbackTypeface.GlyphTypeface; }","preventionTips":["Register custom fonts as embedded assets with correct FontFamily URIs.","Provide fallback font families for cross-platform/CI robustness.","Install or embed required fonts in headless/CI environments.","For NativeAOT, ensure font assets and loaders are not trimmed."],"tags":["font","typeface","glyph","font-loading","avalonia"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}