FontInfoCollection

FontInfoCollection class

Represents a collection of fonts used in a document.

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

public class FontInfoCollection : IEnumerable<FontInfo>

Properties

NameDescription
Count { get; }Gets the number of elements contained in the collection.
EmbedSystemFonts { get; set; }Specifies whether or not to embed System fonts into the document. Default value for this property is false.
EmbedTrueTypeFonts { get; set; }Specifies whether or not to embed TrueType fonts in a document when it is saved. Default value for this property is false.
Item { get; }Gets a font with the specified name. (2 indexers)
SaveSubsetFonts { get; set; }Specifies whether or not to save a subset of the embedded TrueType fonts with the document. Default value for this property is false.

Methods

NameDescription
Contains(string)Determines whether the collection contains a font with the given name.
GetEnumerator()Returns an enumerator object that can be used to iterate over all items in the collection.

Remarks

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.

Examples

Shows how to save a document with embedded TrueType fonts.

Document doc = new Document(MyDir + "Document.docx");

FontInfoCollection fontInfos = doc.FontInfos;
fontInfos.EmbedTrueTypeFonts = embedAllFonts;
fontInfos.EmbedSystemFonts = embedAllFonts;
fontInfos.SaveSubsetFonts = embedAllFonts;

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 allFonts = doc.FontInfos;
// Print all the used and unused fonts in the document.
for (int i = 0; i < allFonts.Count; i++)
{
    Console.WriteLine($"Font index #{i}");
    Console.WriteLine($"\tName: {allFonts[i].Name}");
    Console.WriteLine($"\tIs {(allFonts[i].IsTrueType ? "" : "not ")}a trueType font");
}

See Also