{"record":{"id":"1fb09b144a2bf3bf","repo":"dotnet/wpf","slug":"sr-familymap-targetnotset","errorCode":null,"errorMessage":"SR.FamilyMap_TargetNotSet","messagePattern":"SR\\.FamilyMap_TargetNotSet","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontFace/CompositeFontInfo.cs","lineNumber":48,"sourceCode":"        /// Construct a composite font\n        /// </summary>\n        internal CompositeFontInfo()\n        {\n            _familyNames = new LanguageSpecificStringDictionary(new Dictionary<XmlLanguage,string>(InitialCultureCount));\n            _familyMaps = new FontFamilyMapCollection(this);\n            _defaultFamilyMapRanges = EmptyFamilyMapRanges;\n        }\n\n        /// <summary>\n        /// Called by FontFamilyMapCollection when a FontFamilyMap is being added.\n        /// </summary>\n        internal void PrepareToAddFamilyMap(FontFamilyMap familyMap)\n        {\n            // Validate parameters.\n            ArgumentNullException.ThrowIfNull(familyMap);\n\n            if (string.IsNullOrEmpty(familyMap.Target))\n                throw new ArgumentException(SR.FamilyMap_TargetNotSet);\n\n            // If it's culture-specific make sure it's in the hash table.\n            if (familyMap.Language != null)\n            {\n                if (_familyMapRangesByLanguage == null)\n                {\n                    _familyMapRangesByLanguage = new Dictionary<XmlLanguage, ushort[]>(InitialCultureCount);\n                    _familyMapRangesByLanguage.Add(familyMap.Language, EmptyFamilyMapRanges);\n                }\n                else if (!_familyMapRangesByLanguage.ContainsKey(familyMap.Language))\n                {\n                    _familyMapRangesByLanguage.Add(familyMap.Language, EmptyFamilyMapRanges);\n                }\n            }\n        }\n\n        #region family map ranges (skip lists)\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontFace/CompositeFontInfo.cs#L30-L66","documentation":"CompositeFontInfo.PrepareToAddFamilyMap validates a FontFamilyMap before adding it to a composite font (font family fallback) definition. A family map must have a non-null, non-empty Target (the target font family name); otherwise it throws ArgumentException(SR.FamilyMap_TargetNotSet).","triggerScenarios":"Adding a FontFamilyMap to a CompositeFontInfo where familyMap.Target was never assigned — e.g. constructing a FontFamilyMap in code and calling the add API before setting Target, or parsing a malformed composite font where the FontFamily element's Target attribute is missing.","commonSituations":"Programmatic composition of a font fallback list; hand-written or corrupted .xaml/CompositeFont resources missing the Target attribute for a FamilyMap entry; XAML parsers registering family maps during CompositeFont loading.","solutions":["Set familyMap.Target (e.g. to a font family name like \"Segoe UI\") before adding the map.","Fix the composite font XAML so every <FontFamilyMap> has a Target attribute.","Validate Target non-empty in your own code before invoking the add operation."],"exampleFix":"// before\nvar map = new FontFamilyMap { Language = XmlLanguage.GetLanguage(\"ja-JP\") };\ncompositeFont.PrepareToAddFamilyMap(map); // throws: Target not set\n// after\nvar map = new FontFamilyMap { Language = XmlLanguage.GetLanguage(\"ja-JP\"), Target = \"Yu Gothic\" };\ncompositeFont.PrepareToAddFamilyMap(map);","handlingStrategy":"validation","validationCode":"if (familyMap == null) throw new ArgumentNullException(nameof(familyMap));\nif (string.IsNullOrEmpty(familyMap.Target))\n    throw new ArgumentException(\"FontFamilyMap.Target must be set before adding.\");","typeGuard":"bool IsValidFamilyMap(FontFamilyMap m) => m != null && !string.IsNullOrEmpty(m.Target);","tryCatchPattern":"try { compositeFont.PrepareToAddFamilyMap(map); }\ncatch (ArgumentException) { /* fix or skip the family map */ }","preventionTips":["Always set Target on FontFamilyMap before adding.","Validate composite font XAML: every FontFamilyMap needs Target.","Check hand-edited CompositeFont resources for missing attributes."],"tags":["wpf","fonts","composite-font","argumentexception","validation"],"backgroundTag":"missing-required-argument","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"}