I'm using UWP for a front end GUI and a full trust background process written in .NetCore 3.1 for some heavy lifting tasks. However, I'm having an odd issue when it comes to pulling back all the installed fonts as the list returned is not consistent between the two frameworks.
In UWP the following code (based on the answer to this SO question) is used to populate a dropdown list and returns approximately 241 font families:
public List<string> FontFamilies
{
get
{
return CanvasTextFormat.GetSystemFontFamilies(ApplicationLanguages.Languages).OrderBy(x => x).ToList();
}
}
The selected fontfamily is then passed as a string to the .NetCore background process which attempts to get the font. However, var fonts = System.Drawing.Text.InstalledFontCollection()
returns a very different list (477 elements) to the UWP function. Many of these additional items seem to be because the variations on the font families (e.g. regular, bold and italic) are not being collapsed into a single family. But in some cases the name is different; for example an OpenType font Playlist Script
in UWP becomes Playlist
in NetCore.
I've tried to seeing if the language IDs has something to do with the disparity but without success and wondered if anyone else has had to deal with a similar issue?