Class MemoryFontSource
Contents
[
Hide
]MemoryFontSource class
Represents the single TrueType font file stored in memory.
public class MemoryFontSource : FontSourceBase
Constructors
| Name | Description | 
|---|---|
| MemoryFontSource(byte[]) | Ctor. | 
Properties
| Name | Description | 
|---|---|
| FontData { get; } | Binary font data. | 
| override Type { get; } | Returns the type of the font source. | 
Examples
namespace AsposeCellsExamples
{
    using Aspose.Cells;
    using System;
    using System.IO;
    public class CellsClassMemoryFontSourceDemo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            // Load a TrueType font file into memory
            byte[] fontData = File.ReadAllBytes("arial.ttf");
            // Create an instance of MemoryFontSource with the font data
            MemoryFontSource memoryFontSource = new MemoryFontSource(fontData);
            // Create font sources array containing our memory font source
            FontSourceBase[] fontSources = new FontSourceBase[] { memoryFontSource };
            // Set the font sources using FontConfigs
            FontConfigs.SetFontSources(fontSources);
            // Use the custom font in a cell
            worksheet.Cells["A1"].PutValue("Text with custom font from memory");
            Style style = worksheet.Cells["A1"].GetStyle();
            style.Font.Name = "Arial";
            style.Font.Size = 14;
            worksheet.Cells["A1"].SetStyle(style);
            // Save the workbook
            workbook.Save("MemoryFontSourceDemo.xlsx");
        }
    }
}
See Also
- class FontSourceBase
- namespace Aspose.Cells
- assembly Aspose.Cells