Page 1 of 1

Create WPFFont from System.Windows.Media.FontFamily?

Posted: Mon Jan 06, 2014 8:10 pm
by ShawnCG
Is it possible to create a WPFFont object from a System.Windows.Media.FontFamily instead of a System.Drawing.FontFamily? The two don't seem to have equivalent lookup tables for the FontFamily name and in my project all of our fonts are selected from the System.Windows.Media collection.

Re: Create WPFFont from System.Windows.Media.FontFamily?

Posted: Tue Jan 07, 2014 6:20 am
by ArctionTero
There is no such constructor for now.

You could try following kind of code to get FontFamily from System.Windows.Media.FontFamily:

Code: Select all

System.Windows.Media.FontFamily ff = new System.Windows.Media.FontFamily("Times New Roman");
List<String> listFamilyNames = new List<string>(ff.FamilyNames.Values);
WPFFont wpfFont = new WPFFont(listFamilyNames[0], 12);