AvaloniaUI/Avalonia · error · ArgumentException
Specified family is not supported.
Error message
Specified family is not supported.
What it means
FontFamily.Parse throws ArgumentException when the input string is null or empty. A font family specification must contain at least a family name or a source identifier (e.g. 'FamilyName', 'avares://...#Family', or '#Source'). Empty/null input cannot identify any font family.
Source
Thrown at src/Avalonia.Base/Media/FontFamily.cs:210
/// <exception cref="ArgumentException">
/// Specified family is not supported.
/// </exception>
public static FontFamily Parse(string s) => Parse(s, null);
/// <summary>
/// Parses a <see cref="T:Avalonia.Media.FontFamily"/> string.
/// </summary>
/// <param name="s">The <see cref="T:Avalonia.Media.FontFamily"/> string.</param>
/// <param name="baseUri">Specifies the base uri that is used to resolve font family assets.</param>
/// <returns></returns>
/// <exception cref="ArgumentException">
/// Specified family is not supported.
/// </exception>
public static FontFamily Parse(string s, Uri? baseUri)
{
if (string.IsNullOrEmpty(s))
{
throw new ArgumentException("Specified family is not supported.", nameof(s));
}
return new FontFamily(baseUri, s);
}
/// <summary>
/// Returns a <see cref="string" /> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="string" /> that represents this instance.
/// </returns>
public override string ToString()
{
if (Key != null)
{
return Key + "#" + FamilyNames;
}
View on GitHub (pinned to 11c5427268)
Solutions
- Provide a non-empty font family string (e.g. a system font name or an avares: source).
- Guard against null/empty before parsing: if (string.IsNullOrEmpty(s)) use a fallback family.
- Check XAML bindings and resource definitions for empty FontFamily values.
Example fix
// before var ff = FontFamily.Parse(fontNameFromConfig, null); // fontNameFromConfig is "" // after var name = string.IsNullOrEmpty(fontNameFromConfig) ? "Segoe UI" : fontNameFromConfig; var ff = FontFamily.Parse(name, null);
Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(s))
throw new ArgumentException("Font family name required.", nameof(s));
var ff = FontFamily.Parse(s, baseUri); Prevention
- Validate font family strings are non-empty before parsing.
- Guard XAML bindings that could yield null/empty FontFamily values.
- Provide fallback family names in config-driven scenarios.
When it happens
Trigger: Calling FontFamily.Parse(s, baseUri) where s is null or empty string. Often reached from XAML when a FontFamily attribute is empty or bound to a null/empty value.
Common situations: A XAML FontFamily attribute left empty or set to "{}". Binding FontFamily to a property that evaluates to null/empty. Loading font family names from config with missing entries. A theme/style that omits the font family value.
Related errors
- IterationCount can't be a negative number.
- Invalid brush string: '{s}'.
- Unknown CacheMode: {s}
- Invalid color string: '{s}'.
- Invalid color string: '{s.ToString()}'.
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/4135f262e904e3cf.
Report an issue: GitHub.