MemoryFontSource

MemoryFontSource class

Represents the single TrueType font file stored in memory.

To learn more, visit the Working with Fonts documentation article.

public class MemoryFontSource : FontSourceBase

Constructors

NameDescription
MemoryFontSource(byte[])Ctor.
MemoryFontSource(byte[], int)Ctor.
MemoryFontSource(byte[], int, string)Ctor.

Properties

NameDescription
CacheKey { get; }The key of this source in the cache.
FontData { get; }Binary font data.
Priority { get; }Returns the font source priority.
override 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

NameDescription
GetAvailableFonts()Returns list of fonts available via this source.

Examples

Shows how to use a byte array with data from a font file as a font source.

byte[] fontBytes = File.ReadAllBytes(MyDir + "Alte DIN 1451 Mittelschrift.ttf");
MemoryFontSource memoryFontSource = new MemoryFontSource(fontBytes, 0);

Document doc = new Document();
doc.FontSettings = new FontSettings();
doc.FontSettings.SetFontsSources(new FontSourceBase[] {memoryFontSource});

Assert.AreEqual(FontSourceType.MemoryFont, memoryFontSource.Type);
Assert.AreEqual(0, memoryFontSource.Priority);

See Also