Base class for user-defined stream font source.
In order to use the stream font source you should create a derived class from the StreamFontSource and provide implementation of the OpenFontDataStream method.
OpenFontDataStream method could be called several times. For the first time it will be called when Aspose.Words scans the provided font sources to get the list of available fonts. Later it may be called if the font is used in the document to parse the font data and to embed the font data to some output formats.
StreamFontSource may be useful because it allows to load the font data only when it is required and not to store it in the memory for the FontSettings lifetime.
- 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:
{
}
protected:
virtual ~StreamFontSourceFile()
{
}
};