dotnet/wpf · error · XpsPackagingException

Obfuscated font resources require valid GUID file name.

Error message

Obfuscated font resources require valid GUID file name.

What it means

The XpsFixedPageReaderWriter constructor throws XpsPackagingException(SR.ReachPackaging_ObfucatedFontNeedGuid) when a font part's file name claims to be an obfuscated font but the file name is not a valid GUID. Obfuscated (embedded) XPS fonts must be named '{GUID}.odttf'; the GUID is required to de-obfuscate the font data.

Solutions

  1. Rename the font part to a valid GUID file name, e.g. '{0D5C6F4A-...}.odttf'.
  2. If the font is not actually obfuscated, change its content type / relationship to the plain font type instead.
  3. Regenerate the XPS package with the original tooling so fonts are named correctly.

Example fix

// before
/resources/fonts/myfont.odttf
// after
/resources/fonts/{3B4D6F4A-1C2B-4E8A-9F0D-5A6B7C8D9E0F}.odttf
Defensive patterns

Strategy: validation

Validate before calling

if (fileName.EndsWith(".odttf") && !Guid.TryParse(fileName.Trim('{','}').Split('.')[0], out _))
    throw new XpsPackagingException("Obfuscated font needs a GUID file name");

Try / catch

try { LoadXps(path); }
catch (XpsPackagingException ex) when (ex.Message.Contains("Obfuscated font")) { /* rename part or reject package */ }

Prevention

When it happens

Trigger: Loading a page whose resource part has an obfuscated-font content type but a file name that Guid.Parse/new Guid() cannot parse — e.g. 'myfont.odttf' or a GUID with braces/wrong format.

Common situations: Hand-renamed font files inside an XPS package; third-party producers that mark fonts obfuscated but use arbitrary names; zip repackaging that renamed parts.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsFixedPageReaderWriter.cs:1911

            )
        {
            //Extract file extension
            String path = fontUri.OriginalString;
            String extension = Path.GetExtension(path);
            String fileName = Path.GetFileNameWithoutExtension(path);

            ContentType contentType = null;
            if (string.Equals(extension, XpsS0Markup.ObfuscatedFontExt, StringComparison.OrdinalIgnoreCase))
            {
                // Verify that the filename is a valid GUID string
                // Until Guid has a TryParse method we will have to depend on an exception being thrown
                try
                {  
                    Guid guid = new Guid(fileName );
                }
                catch( FormatException )
                {
                    throw new XpsPackagingException(SR.ReachPackaging_ObfucatedFontNeedGuid);
                }

                contentType =  XpsS0Markup.FontObfuscatedContentType;
            }
            else
            {
                //default to PNG
                contentType = XpsS0Markup.FontContentType;
            }

            return contentType;
         }


        #endregion Private methods

        #region Private data

View on GitHub (pinned to 81131a70a4)