Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7042927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:13:37+00:00 2026-05-28T02:13:37+00:00

When using fonts for my application I get no warning/error/exception when a FontFamily I

  • 0

When using fonts for my application I get no warning/error/exception when a FontFamily I set in a style is not found.

Normally in WPF you get a warning message in your output window telling you you’re binding doesn’t exist. Or you get an exception when your ResourceDictionary can’t be loaded because it’s file can’t be found. However there is absolutely no warning at all when trying to load a FontFamily without a proper name or from a faulty assembly, is there a way to see what font is actually loaded/shown and if it succeeds?

*EDIT:
I used the answer below and changed the TestFont method to the following:

[Conditional("DEBUG")]
private void CheckFontFamily()
{
    string fontName = FontFamily.Source.Substring(FontFamily.Source.IndexOf('#') + 1);

    if (!FontFamily.FamilyNames.Any(x => x.Value == fontName))
    {
        bool fontFamilyFound = false;
        string baseFontName = fontName;

        while (!fontFamilyFound && fontName.Contains(' '))
        {
            fontName = fontName.Substring(0, fontName.LastIndexOf(' '));
            if (FontFamily.FamilyNames.Any(x => x.Value == fontName))
            {
                fontFamilyFound = true;
                string fontFace = baseFontName.Substring(fontName.Length + 1);
                if (!FontFamily.FamilyTypefaces.Any(x => x.AdjustedFaceNames.Any(y => y.Value == fontFace)))
                {
                    Console.WriteLine("WARNING: Font '{0}' with TypeFace '{1}' not found at '{2}'.", fontName, fontFace, FontFamily.Source);
                }
                break;
            }
        }

        if (!fontFamilyFound)
        {
            Console.WriteLine("WARNING: Font '{0}' not found at '{1}'.", fontName, FontFamily.Source);
        }
    }

This will show if loading a font like this will work: (and thus check if the path worked)

<TextBlock Text="Lorem Ipsum" FontFamily="{Fonts:FontFamily '/Project;component/Fonts/#ITC Quay Book'}"/>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:13:38+00:00Added an answer on May 28, 2026 at 2:13 am

    You could use a markup extension, unfortunately that would require you to use it in every place where you set the FontFamily.

    e.g.

    <TextBlock Text="Lorem Ipsum" FontFamily="{me:FontFamily Spam}" />
    
    public sealed class FontFamilyExtension:MarkupExtension
    {
        public FontFamily FontFamily { get; set; }
    
        public FontFamilyExtension(FontFamily fontFamily)
        {
            FontFamily = fontFamily;
        }
    
        [Conditional("DEBUG")]
        private void TestFont()
        {
            if (!Fonts.SystemFontFamilies.Contains(FontFamily))
                Console.WriteLine("Font '{0}' not found.", FontFamily.Source);
        }
    
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            TestFont();
            return FontFamily;
        }
    }
    

    The warning would then be displayed in the output window when running in debug (which should satisfy the conditional).

    Output window

    You could get more info from the service provider, e.g. on what kind of object the FontFamily was set and output that as well to aid the debugging.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The error I get is that class net.rim.device.api.ui.ScrollView is not found. All I am
I am using the external fonts capability for my application. As external fonts are
I have created an application in WPF & used Arial & Verdana fonts in
We have an application that communicates with printers using their internal printer fonts. This
i've got a few fonts embedded and am using them in my mobile application,
I am using Segoe UI for my winforms application. On XP, this font doesn't
I am using the Photoshop's javascript API to find the fonts in a given
I'm using a third-party library which accesses fonts through the GraphicsEnvironment: getAllFonts() call. This
I need to embed the fonts that I'm using in my TeX document in
When setting the size of fonts in CSS, should I be using a percent

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.