FontInfoCollection Class

Represents a collection of fonts used in a document.

Inheritance Hierarchy


Namespace:  Aspose.Words.Fonts
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.7.0


public class FontInfoCollection : IEnumerable<FontInfo>, 

The FontInfoCollection type exposes the following members.


Public propertyCode exampleCount
Gets the number of elements contained in the collection.
Public propertyCode exampleEmbedSystemFonts

Specifies whether or not to embed System fonts into the document. Default value for this property is false.

This option works only when EmbedTrueTypeFonts option is set to true.

Public propertyCode exampleEmbedTrueTypeFonts
Specifies whether or not to embed TrueType fonts in a document when it is saved. Default value for this property is false.
Public propertyCode exampleItemInt32
Gets a font at the specified index.
Public propertyCode exampleItemString
Gets a font with the specified name.
Public propertyCode exampleSaveSubsetFonts

Specifies whether or not to save a subset of the embedded TrueType fonts with the document. Default value for this property is false.

This option works only when EmbedTrueTypeFonts property is set to true.


Public methodCode exampleContains
Determines whether the collection contains a font with the given name.
Public methodEquals (Inherited from Object.)
Public methodCode exampleGetEnumerator
Returns an enumerator object that can be used to iterate over all items in the collection.
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodToString (Inherited from Object.)


Items are FontInfo objects.

You do not create instances of this class directly. Use the FontInfos property to access the collection of fonts defined in the document.


Shows how to save a document with embedded TrueType fonts.
Document doc = new Document(MyDir + "Document.docx");

FontInfoCollection fontInfos = doc.FontInfos;
fontInfos.EmbedTrueTypeFonts = true;
fontInfos.EmbedSystemFonts = false;
fontInfos.SaveSubsetFonts = false;

doc.Save(ArtifactsDir + "Font.FontInfoCollection.docx");
Shows how to print the details of what fonts are present in a document.
Document doc = new Document(MyDir + "Embedded font.docx");

FontInfoCollection fonts = doc.FontInfos;

// The fonts info extracted from this document does not necessarily mean that the fonts themselves are
// used in the document. If a font is present but not used then most likely they were referenced at some time
// and then removed from the Document
for (int i = 0; i < fonts.Count; i++)
    Console.WriteLine($"Font index #{i}");
    Console.WriteLine($"\tName: {fonts[i].Name}");
    Console.WriteLine($"\tIs {(fonts[i].IsTrueType ? "" : "not ")}a trueType font");

See Also