デフォルトフォント
デフォルトフォントの設定
Aspose.Slides for C++を使用すると、PowerPointプレゼンテーションでデフォルトフォントを設定できます。新しいメソッドset_DefaultRegularFont()がSaveOptionsクラスに追加されました。このメソッドは、プレゼンテーションを異なるフォーマットに保存する際に、すべての欠落しているフォントの代わりに使用されるデフォルトフォントを設定することを可能にします。
以下のコードスニペットは、異なるデフォルトレギュラーフォントでプレゼンテーションをHTMLおよびPDFに保存する方法を示しています。
const String tempplatePath = u"../templates/DemoFile.pptx"; | |
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(tempplatePath); | |
System::SharedPtr<HtmlOptions> htmlOpts = System::MakeObject<HtmlOptions>(); | |
htmlOpts->set_DefaultRegularFont(u"Arial Black"); | |
pres->Save(u"../out/SomePresentation-out-ArialBlack.html", Aspose::Slides::Export::SaveFormat::Html, htmlOpts); | |
htmlOpts->set_DefaultRegularFont(u"Lucida Console"); | |
pres->Save(u"../out/Somepresentation-out-LucidaConsole.html", Aspose::Slides::Export::SaveFormat::Html, htmlOpts); | |
System::SharedPtr<PdfOptions> pdfOpts = System::MakeObject<PdfOptions>(); | |
pdfOpts->set_DefaultRegularFont(u"Arial Black"); | |
pres->Save(u"../out/SomePresentation-out-ArialBlack.pdf", Aspose::Slides::Export::SaveFormat::Pdf, pdfOpts); | |
プレゼンテーションのレンダリングにデフォルトフォントを使用する
Aspose.Slidesを使用すると、PDF、XPS、またはサムネイルにプレゼンテーションをレンダリングするためのデフォルトフォントを設定できます。この記事では、デフォルトフォントとして使用するためのDefaultRegular FontとDefaultAsian Fontの定義方法を示します。以下の手順に従って、Aspose.Slides for C++ APIを使用して外部ディレクトリからフォントをロードします。
- LoadOptionsのインスタンスを作成します。
- DefaultRegularFontを希望のフォントに設定します。以下の例では、Wingdingsを使用しました。
- DefaultAsianFontを希望のフォントに設定します。次のサンプルでもWingdingsを使用しました。
- Presentationを使用してプレゼンテーションをロードし、ロードオプションを設定します。
- 最後に、スライドのサムネイル、PDF、およびXPSを生成して結果を確認します。
上記の実装は以下の通りです。
// ロードオプションを使用してデフォルトレギュラーおよびアジアフォントを指定します
auto loadOptions = MakeObject<LoadOptions>(LoadFormat::Auto);
loadOptions->set_DefaultRegularFont(u"Wingdings");
loadOptions->set_DefaultAsianFont(u"Wingdings");
auto pptx = MakeObject<Presentation>(u"DefaultFonts.pptx", loadOptions);
auto image = pptx->get_Slide(0)->GetImage(1, 1);
image->Save(u"DefaultFonts_out.png", ImageFormat::Png);
image->Dispose();
pptx->Save(u"DefaultFonts_out.pdf", SaveFormat::Pdf);
pptx->Save(u"DefaultFonts_out.xps", SaveFormat::Xps);
pptx->Dispose();