private void EmbedFonts()
{
var fontsWanted = GetFontsUsed(Book.FolderPath, true); // Need to include fallback fonts in case one of the preferred fonts isn't on this machine
var fontFileFinder = new FontFileFinder();
var filesToEmbed = fontsWanted.SelectMany(fontFileFinder.GetFilesForFont).ToArray();
foreach (var file in filesToEmbed)
{
CopyFileToEpub(file);
}
var sb = new StringBuilder();
foreach (var font in fontsWanted)
{
var group = fontFileFinder.GetGroupForFont(font);
if (group != null)
{
AddFontFace(sb, font, "normal", "normal", group.Normal);
AddFontFace(sb, font, "bold", "normal", group.Bold);
AddFontFace(sb, font, "normal", "italic", group.Italic);
AddFontFace(sb, font, "bold", "italic", group.BoldItalic);
}
}
RobustFile.WriteAllText(Path.Combine(_contentFolder, "fonts.css"), sb.ToString());
_manifestItems.Add("fonts.css");
}