Aspose::Words::Fonts::FontInfoCollection class

FontInfoCollection class

Represents a collection of fonts used in a document. To learn more, visit the Working with Fonts documentation article.

class FontInfoCollection : public System::Collections::Generic::IEnumerable<System::SharedPtr<Aspose::Words::Fonts::FontInfo>>

Methods

MethodDescription
Contains(const System::String &)Determines whether the collection contains a font with the given name.
GetEnumerator() overrideReturns an enumerator object that can be used to iterate over all items in the collection.
get_Count()Gets the number of elements contained in the collection.
get_EmbedSystemFonts() constSpecifies 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. | | get_EmbedTrueTypeFonts() const | Specifies whether or not to embed TrueType fonts in a document when it is saved. Default value for this property is false. | | get_SaveSubsetFonts() const | 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. | | idx_get(const System::String &) | Gets a font with the specified name. | | idx_get(int32_t) | Gets a font at the specified index. | | set_EmbedSystemFonts(bool) | 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. | | set_EmbedTrueTypeFonts(bool) | Specifies whether or not to embed TrueType fonts in a document when it is saved. Default value for this property is false. | | set_SaveSubsetFonts(bool) | 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. |

Typedefs

TypedefDescription
const_iteratorConst iterator type.
iteratorIterator type.
iterator_holder_typeA collection type whose iterator types is used as iterator types in the current collection.
virtualized_iteratorVirtualized type.
virtualized_iterator_elementVirtualized element type.

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 print the details of what fonts are present in a document.

auto doc = System::MakeObject<Aspose::Words::Document>(System::String(get_MyDir() + u"Embedded font.docx"));

System::SharedPtr<Aspose::Words::Fonts::FontInfoCollection> allFonts = doc->get_FontInfos();

// Print all the used and unused fonts in the document.
for (int32_t i = 0; i < allFonts->get_Count(); i++)
{
    std::cout << System::String::Format(u"Font index #{0}", i) << std::endl;
    std::cout << System::String::Format(u"\tName: {0}", allFonts->idx_get(i)->get_Name()) << std::endl;
    std::cout << System::String::Format(u"\tIs {0}a trueType font", allFonts->idx_get(i)->get_IsTrueType() ? System::String(u"") : System::String(u"not ")) << std::endl;
}

Shows how to save a document with embedded TrueType fonts.

auto doc = System::MakeObject<Aspose::Words::Document>(System::String(get_MyDir() + u"Document.docx"));

System::SharedPtr<Aspose::Words::Fonts::FontInfoCollection> fontInfos = doc->get_FontInfos();
fontInfos->set_EmbedTrueTypeFonts(embedAllFonts);
fontInfos->set_EmbedSystemFonts(embedAllFonts);
fontInfos->set_SaveSubsetFonts(embedAllFonts);

doc->Save(get_ArtifactsDir() + u"Font.FontInfoCollection.docx");

See Also