Aspose::Words::Fonts::StreamFontSource::OpenFontDataStream method
StreamFontSource::OpenFontDataStream method
This method should open the stream with font data on demand.
virtual System::SharedPtr<System::IO::Stream> Aspose::Words::Fonts::StreamFontSource::OpenFontDataStream()=0
ReturnValue
Font data stream.
Examples
Shows how to load fonts from stream.
void StreamFontSourceFileRendering()
{
auto fontSettings = MakeObject<FontSettings>();
fontSettings->SetFontsSources(MakeArray<SharedPtr<FontSourceBase>>({MakeObject<ExFontSettings::StreamFontSourceFile>()}));
auto builder = MakeObject<DocumentBuilder>();
builder->get_Document()->set_FontSettings(fontSettings);
builder->get_Font()->set_Name(u"Kreon-Regular");
builder->Writeln(u"Test aspose text when saving to PDF.");
builder->get_Document()->Save(ArtifactsDir + u"FontSettings.StreamFontSourceFileRendering.pdf");
}
class StreamFontSourceFile : public StreamFontSource
{
public:
SharedPtr<System::IO::Stream> OpenFontDataStream() override
{
return System::IO::File::OpenRead(FontsDir + u"Kreon-Regular.ttf");
}
protected:
virtual ~StreamFontSourceFile()
{
}
};
See Also
- Class StreamFontSource
- Namespace Aspose::Words::Fonts
- Library Aspose.Words for C++