StreamFontSource Class
StreamFontSource class
Base class for user-defined stream font source.
public abstract class StreamFontSource : FontSourceBase
Properties
Name | Description |
---|---|
CacheKey { get; } | The key of this source in the cache. |
Priority { get; } | Returns the font source priority. |
Type { get; } | Returns the type of the font source. |
WarningCallback { get; set; } | Called during processing of font source when an issue is detected that might result in formatting fidelity loss. |
Methods
Name | Description |
---|---|
GetAvailableFonts() | Returns list of fonts available via this source. |
abstract OpenFontDataStream() | This method should open the stream with font data on demand. |
Remarks
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 Wordize 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
Demonstrates how specify stream font source.
StreamFontSourceIml streamFontSource = new StreamFontSourceIml(1, "test");
Wordize.Settings.DefaultFontSettings.SetFontsSources(new FontSourceBase[] { streamFontSource });
Implementation of StreamFontSource
private class StreamFontSourceIml : StreamFontSource
{
public StreamFontSourceIml(int priority, string cacheKey) : base(priority, cacheKey) { }
public override Stream OpenFontDataStream()
{
return File.OpenRead(MyDir + @"MyFonts\NoticiaText-Regular.ttf");
}
}
See Also
- class FontSourceBase
- namespace Wordize.Fonts
- assembly Wordize