Render Presentation with Fallback Font

Contents
[ ]

The following example includes these steps:

  1. We create fallback font rules collection.
  2. Remove() a fallback font rule and AddFallBackFonts() to another rule.
  3. Set rules collection to FontsManager.FontFallBackRulesCollection property.
  4. With Presentation.Save() method we can save presentation in the same format, or save it in another one. After fallback font rules collection is set to FontsManager, these rules are applied during any operations over the presentation: save, render, convert, etc.
// Create new instance of a rules collection
IFontFallBackRulesCollection rulesList = new FontFallBackRulesCollection();

// create a number of rules
rulesList.Add(new FontFallBackRule(0x400, 0x4FF, "Times New Roman"));
//rulesList.Add(new FontFallBackRule(...));

foreach (IFontFallBackRule fallBackRule in rulesList)
{
	//Trying to remove FallBack font "Tahoma" from loaded rules
	fallBackRule.Remove("Tahoma");

	//And to update of rules for specified range
	if ((fallBackRule.RangeEndIndex >= 0x4000) && (fallBackRule.RangeStartIndex < 0x5000))
		fallBackRule.AddFallBackFonts("Verdana");
}

//Also we can remove any existing rules from list
if (rulesList.Count > 0)
	rulesList.Remove(rulesList[0]);

using (Presentation pres = new Presentation("input.pptx"))
{
    //Assigning a prepared rules list for using
    pres.FontsManager.FontFallBackRulesCollection = rulesList;

    // Rendering of thumbnail with using of initialized rules collection and saving to PNG
    using (IImage image = pres.Slides[0].GetImage(1f, 1f))
    {
        image.Save("Slide_0.png", ImageFormat.Png);
    }
}