FontData — Aspose.Slides FOSS for .NET API Reference
The FontData class represents a font name reference. It is used in BasePortionFormat properties such as LatinFont, EastAsianFont, ComplexScriptFont, and SymbolFont.
Package: Aspose.Slides.Foss (net9.0)
using Aspose.Slides.Foss;public class FontData : IFontDataConstructors
| Signature | Description |
|---|---|
FontData(string fontName) | Create a font data instance with the specified font name. |
Properties
| Property | Type | Access | Description |
|---|---|---|---|
FontName | string | Read | Name of the font face. |
Methods
GetFontName(object?)
Get the resolved font name, optionally considering a theme.
| Parameter | Type | Description |
|---|---|---|
theme | object? | Theme to resolve against, or null. |
Returns: string
Usage Examples
Set Font on a Portion
using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;
using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 300, 100);
shape.AddTextFrame("Custom font");
var portion = shape.TextFrame.Paragraphs[0].Portions[0];
portion.PortionFormat.LatinFont = new FontData("Consolas");
portion.PortionFormat.FontHeight = 18;
prs.Save("font.pptx", SaveFormat.Pptx);Read Font from a Portion
using Aspose.Slides.Foss;
using var prs = new Presentation("deck.pptx");
var shape = prs.Slides[0].Shapes[0] as IAutoShape;
if (shape?.TextFrame != null)
{
var portion = shape.TextFrame.Paragraphs[0].Portions[0];
Console.WriteLine($"Font: {portion.PortionFormat.LatinFont?.FontName}");
}