public static void UpdateFonts(IEnumerable<Material> materials, Func<string, FontInfo> getFont, IFontService fontService) { var requiredFonts = materials.SelectMany(m => m.MaterialFields).Select(f => f.FontName); foreach (var requiredFontName in requiredFonts.Where(f => fontService.IsFontAvailable(f) == false)) { var fontInfo = getFont(requiredFontName); if (fontInfo != null) { fontService.InstallFont(fontInfo.FileName, fontInfo.Buffer); } } }