Get font name from FontFamily in WPF

I am currently working on a small font organization / preview for myself, however, it is difficult for me to get the information I need.

I found that I can load an external font by simply creating a new FontFamily object with the location of the font file as its source. However, I cannot find a way to return the font of the font. I know that I can use FontFamily.FamilyNames to get the name of the font family, but this is useless to me when I have multiple fonts with the same family that is displayed. I would like to display a specific name for a particular font.

Is there any way to do this? I am currently displaying the file name, but it is incredibly messy because I have to iterate over each file in the directory and call Fonts.GetFontFamilies () for each so that I can get the actual file name (the FontFamily Source property gives only the temporary WPF family -name instead of something useful).

+6
fonts wpf fontfamily
source share
2 answers

FontFamily :: GetTypefaces and then Typeface :: FaceNames doesn't give you what you want?

+2
source share

This is what I do:

ListBoxItem listBoxItem = null; foreach (FontFamily fontFamily in Fonts.SystemFontFamilies) { listBoxItem = new ListBoxItem(); listBoxItem.Content = fontFamily; listBoxItem.FontFamily=fontFamily; // Shows Font Text in the Font FontFamilyListBox.Items.Add(listBoxItem); } 
+2
source share

All Articles