Reputation: 1441
I have two applications that use the same data to create a UI, one is using WPF and the other is using GDI. I'm using a font called Myriad Condensed Web
, according to the font name attribute in Windows. I have no problem instantiating the System.Drawing.FontFamily
object using the given font name. However, when I create this font using WPF's System.Windows.Media.FontFamily
, I can only do it using the name Myriad Web
. I can't find a reference to this value anywhere in the font properties within Window's fonts control panel. When I inspect System.Windows.Media.Fonts.SystemFontFamilies
, Myriad Web
is the value of the Source attribute.
So my question is, where is WPF getting this value from? And why is it different to the value GDI is giving? And how can I instantiate the same font for both GDI and WPF using one font name? I want to avoid storing two values - one for GDI and one for WPF.
Upvotes: 0
Views: 902
Reputation: 941277
I'm not 100% sure about what's happening, but I have a good theory. Font technology has progressed considerably since GDI+, probably as a result of incorporating OpenType support. WPF has the notion of FontStretch, the FontStretches class defines values like "Consensed", "Medium", "Expanded" etc.
This property isn't available in legacy code, I think the Windows font manager synthesizes font family names to keep things compatible. By injecting "Condensed" (etc) in the regular family name. So, mentally remove this adjective to get the WPF name. It does kill your plan of course, unless you'd consider filtering it yourself in code.
Upvotes: 1