setFontsSources method

setFontsSources(sources) {#fontsourcebase[]}

Sets the sources where Aspose.Words looks for TrueType fonts when rendering documents or embedding fonts.

setFontsSources(sources: Aspose.Words.Fonts.FontSourceBase[])
ParameterTypeDescription
sourcesFontSourceBase[]An array of sources that contain TrueType fonts.

Remarks

By default, Aspose.Words looks for fonts installed to the system.

Setting this property resets the cache of all previously loaded fonts.

setFontsSources(sources, cacheInputStream) {#fontsourcebase[]_buffer}

Sets the sources where Aspose.Words looks for TrueType fonts and additionally loads previously saved font search cache.

setFontsSources(sources: Aspose.Words.Fonts.FontSourceBase[], cacheInputStream: Buffer)
ParameterTypeDescription
sourcesFontSourceBase[]An array of sources that contain TrueType fonts.
cacheInputStreamBufferInput stream with saved font search cache.

Remarks

Loading previously saved font search cache will speed up the font cache initialization process. It is especially useful when access to font sources is complicated (e.g. when fonts are loaded via network).

When saving and loading font search cache, fonts in the provided sources are identified via cache key. For the fonts in the SystemFontSource and FolderFontSource cache key is the path to the font file. For MemoryFontSource and StreamFontSource cache key is defined in the MemoryFontSource.cacheKey and StreamFontSource.cacheKey properties respectively. For the FileFontSource cache key is either FileFontSource.cacheKey property or a file path if the FileFontSource.cacheKey is null.

It is highly recommended to provide the same font sources when loading cache as at the time the cache was saved. Any changes in the font sources (e.g. adding new fonts, moving font files or changing the cache key) may lead to the inaccurate font resolving by Aspose.Words.

See Also