In WPF, the following code returns a list of all fonts in the given location:
foreach (var fontFamily in Fonts.GetFontFamilies(@"C:\Dummy\Fonts\"))
{
System.Diagnostics.Debug.WriteLine(fontFamily.Source);
}
The problem is if you change the content of that folder (add or remove a font) and run this code again, it returns the same list (as it is cached somewhere internally).
This cache will not be cleared until you exit the application!
Is there any way to prevent this behaviour and always make WPF to look into that folder for fonts at that moment?
NOTE: The result is the same regardless of “Windows Presentation Foundation Font Cache 3.0.0.0” service state is started or stopped. Apparently this specific type of cache is not being handled by the service.
I believe you may need to disable the font cache service, as it may be started automatically when needed.
EDIT:
You may have to get the list of FontFamily objects yourself like so:
There may be some issues with the family name, but the above should get you most of the relevant information.