FontInfoCollectionItem Property (String)

Gets a font with the specified name.

Namespace:  Aspose.Words.Fonts
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public FontInfo this[
	string name
] { get; }

Parameters

name
Type: SystemString
Case-insensitive name of the font to locate.

Property Value

Type: FontInfo
Examples
Shows how to extract embedded font from a document.
Document doc = new Document(MyDir + "Embedded font.docx");

// Get the FontInfo for the embedded font
FontInfo embeddedFont = doc.FontInfos["Alte DIN 1451 Mittelschrift"];

// We can now extract this embedded font
byte[] embeddedFontBytes = embeddedFont.GetEmbeddedFont(EmbeddedFontFormat.OpenType, EmbeddedFontStyle.Regular);
Assert.IsNotNull(embeddedFontBytes);

// Then we can save the font to our directory
File.WriteAllBytes(ArtifactsDir + "Alte DIN 1451 Mittelschrift.ttf", embeddedFontBytes);

// If we want to extract a font from a .doc as opposed to a .docx, we need to make sure to set the appropriate embedded font format
doc = new Document(MyDir + "Embedded font.doc");

Assert.IsNull(doc.FontInfos["Alte DIN 1451 Mittelschrift"].GetEmbeddedFont(EmbeddedFontFormat.OpenType, EmbeddedFontStyle.Regular));
Assert.IsNotNull(doc.FontInfos["Alte DIN 1451 Mittelschrift"].GetEmbeddedFont(EmbeddedFontFormat.EmbeddedOpenType, EmbeddedFontStyle.Regular));
See Also