.NET のフォールバックフォントでプレゼンテーションをレンダリング

Contents
[ ]

次の例には以下の手順が含まれます:

  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.```c# // ルールコレクションの新しいインスタンスを作成 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) { // ロードされたルールからフォールバックフォント「Tahoma」を削除しようとしています fallBackRule.Remove(“Tahoma”);

// 指定された範囲のルールを更新します
if ((fallBackRule.RangeEndIndex >= 0x4000) && (fallBackRule.RangeStartIndex < 0x5000))
    fallBackRule.AddFallBackFonts("Verdana");

}

// リストから既存のルールをすべて削除することもできます if (rulesList.Count > 0) rulesList.Remove(rulesList[0]);

using (Presentation pres = new Presentation(“input.pptx”)) { // 使用するために準備したルールリストを割り当てています pres.FontsManager.FontFallBackRulesCollection = rulesList;

// 初期化されたルールコレクションを使用してサムネイルをレンダリングし、PNGで保存します
using (IImage image = pres.Slides[0].GetImage(1f, 1f))
{
    image.Save("Slide_0.png", ImageFormat.Png);
}

}