FontInfoCollection class
FontInfoCollection class
Represents a collection of fonts used in a document. To learn more, visit the Working with Fonts documentation article.
Remarks
Items are FontInfo objects.
You do not create instances of this class directly. Use the DocumentBase.fontInfos property to access the collection of fonts defined in the document.
Properties
Name | Description |
---|---|
count | Gets the number of elements contained in the collection. |
embedSystemFonts | Specifies whether or not to embed System fonts into the document. Default value for this property is false . |
embedTrueTypeFonts | Specifies whether or not to embed TrueType fonts in a document when it is saved. Default value for this property is false . |
saveSubsetFonts | Specifies whether or not to save a subset of the embedded TrueType fonts with the document. Default value for this property is false . |
this[] | |
this[] |
Methods
Name | Description |
---|---|
contains(name) | Determines whether the collection contains a font with the given name. |
Examples
Shows how to print the details of what fonts are present in a document.
let doc = new aw.Document(base.myDir + "Embedded font.docx");
let allFonts = doc.fontInfos;
expect(allFonts.count).toEqual(5);
// Print all the used and unused fonts in the document.
for (let i = 0; i < allFonts.count; i++) {
console.log(`Font index #${i}`);
console.log(`\tName: ${allFonts.at(i).name}`);
console.log(`\tIs ${allFonts.at(i).isTrueType ? "" : "not "}a trueType font`);
}
Shows how to save a document with embedded TrueType fonts.
let doc = new aw.Document(base.myDir + "Document.docx");
let fontInfos = doc.fontInfos;
fontInfos.embedTrueTypeFonts = embedAllFonts;
fontInfos.embedSystemFonts = embedAllFonts;
fontInfos.saveSubsetFonts = embedAllFonts;
doc.save(base.artifactsDir + "Font.FontInfoCollection.docx");
See Also
- module Aspose.Words.Fonts
- class FontInfo
- property DocumentBase.fontInfos