private static Font GetFont(string fontName, float fontSize) { var fontFamily = GetFontFamily(fontName); if (fontFamily == null) { if (privateFontLoader == null) { privateFontLoader = new PrivateFontLoader(FactoryDWrite); privateFontCollection = new FontCollection(FactoryDWrite, privateFontLoader, privateFontLoader.Key); } _currentFontCollection = privateFontCollection; fontFamily = GetFontFamily(fontName); } if (fontFamily == null) { _currentFontCollection = FactoryDWrite.GetSystemFontCollection(true); return(GenericSanSerif()); } // This is generic right now. We should be able to handle different styles in the future var font = fontFamily.GetFirstMatchingFont(FontWeight.Regular, FontStretch.Normal, FontStyle.Normal); return(font); }
private static Font GetFont(string fontName, float fontSize) { var fontFamily = GetFontFamily(fontName); if (fontFamily == null) { if (privateFontLoader == null) { privateFontLoader = new PrivateFontLoader(FactoryDWrite); privateFontCollection = new FontCollection(FactoryDWrite, privateFontLoader, privateFontLoader.Key); } _currentFontCollection = privateFontCollection; fontFamily = GetFontFamily(fontName); } if (fontFamily == null) { _currentFontCollection = FactoryDWrite.GetSystemFontCollection(true); return GenericSanSerif(); } // This is generic right now. We should be able to handle different styles in the future var font = fontFamily.GetFirstMatchingFont(FontWeight.Regular, FontStretch.Normal, FontStyle.Normal); return font; }