dotnet/wpf · error · ArgumentException

SR.Format(SR.PropertyMustBeGreaterThanZero, propertyName)

Error message

SR.Format(SR.PropertyMustBeGreaterThanZero, propertyName)

What it means

CompositeFontParser.ValidateMultiplier throws ArgumentException via VerifyPositiveMultiplierOfEm when a composite font property that must be a strictly positive em-multiplier is <= 0 (NaN is also rejected by the first branch). The parser clamps oversized values but treats zero/negative as a hard error because the property would be meaningless for a font.

Solutions

  1. Open the .CompositeFont XML and fix the offending attribute to a value > 0
  2. Validate the value with double.IsNaN(v) && v > 0 before passing it to the parser
  3. Ensure the font family resource files were not truncated or corrupted during deployment

Example fix

<!-- before -->
<Glyphs Width="0" Height="-1.5" />
<!-- after -->
<Glyphs Width="1.0" Height="1.0" />
Defensive patterns

Strategy: validation

Validate before calling

if (double.IsNaN(value) || value <= 0)
    throw new ArgumentException($"{name} must be > 0, got {value}");

Type guard

bool IsValidPositiveMultiplier(double v) => !double.IsNaN(v) && v > 0;

Prevention

When it happens

Trigger: Parsing a .CompositeFont file whose width/height/scale-factor style attribute is 0, negative, or NaN, e.g. via GlyphTypeface/Typeface font family lookup, or calling VerifyPositiveMultiplierOfEm directly with a non-positive double.

Common situations: Hand-edited or machine-generated CompositeFont XML with a bad multiplier value (e.g. Width="0"), localization of font family resources, programmatic font-family construction.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/7417b6e15c12f257. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontFace/CompositeFontParser.cs:49

            else if (value < -Constants.GreatestMutiplierOfEm)
            {
                value = -Constants.GreatestMutiplierOfEm;
            }
        }

        internal static void VerifyPositiveMultiplierOfEm(string propertyName, ref double value)
        {
            if (double.IsNaN(value))
            {
                throw new ArgumentException(SR.Format(SR.PropertyValueCannotBeNaN, propertyName));
            }
            else if (value > Constants.GreatestMutiplierOfEm)
            {
                value = Constants.GreatestMutiplierOfEm;
            }
            else if (value <= 0)
            {
                throw new ArgumentException(SR.Format(SR.PropertyMustBeGreaterThanZero, propertyName));
            }
        }

        internal static void VerifyNonNegativeMultiplierOfEm(string propertyName, ref double value)
        {
            if (double.IsNaN(value))
            {
                throw new ArgumentException(SR.Format(SR.PropertyValueCannotBeNaN, propertyName));
            }
            else if (value > Constants.GreatestMutiplierOfEm)
            {
                value = Constants.GreatestMutiplierOfEm;
            }
            else if (value < 0)
            {
                throw new ArgumentException(SR.Format(SR.PropertyCannotBeNegative, propertyName));
            }
        }

View on GitHub (pinned to 81131a70a4)