LoadExternalFonts call is very slow. Is there any way to improve performance?
Sample code I am using:
std::vector<String> candidatePaths;
#ifdef MACINTOSH
candidatePaths = {
u"/Applications/Microsoft PowerPoint.app/Contents/Resources/DFonts",
u"/Applications/Microsoft PowerPoint.app/Contents/Resources/Fonts",
};
#endif
std::vector<String> validPaths;
validPaths.reserve(candidatePaths.size());
for (const auto &path : candidatePaths)
{
if (System::IO::Directory::Exists(path))
{
validPaths.push_back(path);
}
}
if (!validPaths.empty())
{
auto fontFolders = MakeObject<Array<String>>(validPaths.size());
for (size_t i = 0; i < validPaths.size(); ++i)
{
(*fontFolders)[i] = validPaths[i];
}
try
{
FontsLoader::LoadExternalFonts(fontFolders);
}
@pankajku,
Thank you for posting the question.
Could you please share a few details to help us pinpoint why FontsLoader::LoadExternalFonts is slow on your side?
- Environment: exact Aspose.Slides for C++ version, OS version, CPU, build type (Debug/Release), storage type (SSD/HDD).
- Timing: wall-clock duration of the
FontsLoader::LoadExternalFonts call.
- Inputs: for each directory the number of font files and total size, the font formats involved (TTF/OTF/TTC). If possible, include timings per directory.
- Experiments: a minimal sample font set.
@andrey.potapov
Hi, apologies for the delay in response.
Here is the answer to your questions:
Environment:
- Aspose.Slides for C++ version: 25.6
- OS: macOS 15.6.1 (Build 24G90)
- CPU: Apple M2 Max (12 physical cores, 12 logical cores)
- Build type: Release
- Storage: SSD (Apple Fabric - APPLE SSD AP1024Z)
Issue:
FontsLoader::LoadExternalFonts() is taking 27 seconds to load fonts
Timing:
- Wall-clock duration: 27,036 milliseconds (27.036 seconds)
- Measured using std::chrono::high_resolution_clock
Input Details:
Directory: /Applications/Microsoft PowerPoint.app/Contents/Resources/DFonts
- Total files: 280 font files
- TTF: 259 files
- OTF: 0 files
- TTC: 21 files
- Total size: 515.77 MB
- Average file size: ~1.84 MB per font
- Font types: Microsoft Office bundled fonts (Aptos, Cambria, Verdana, etc.)
Observations:
- Loading 280 fonts takes ~96ms per font on average
- Minimal set (10 fonts, 19MB): 3 seconds to load
- The fonts are standard Microsoft Office fonts bundled with PowerPoint
- Performance is significantly impacting user experience
Questions:
- Is there a way to cache loaded fonts across imports?
- Can fonts be loaded lazily/on-demand rather than upfront?
- Are there any performance optimization flags or settings we should use?
- Is this expected behavior for this volume of fonts?
Please advise on potential optimizations or workarounds.
@pankajku,
Thank you for the details.
We have opened the following new ticket(s) in our internal issue tracking system and will answer your questions according to the terms mentioned in Free Support Policies.
Issue ID(s): SLIDESCPP-4088
aspose-issue.pptx.zip (28.3 KB)
The original PPT had 8 slides. It was exceeding the upload limit. So, I have kept only 1 slide with the PPT that is causing the issue. It is a text inside a shape with aptos font.
@andrey.potapov
@pankajku,
Thank you for the sample presentation file. I’ve passed it to our developers.