My setup has a linux server that is used to convert .pptx & .ppt into a pdf. Since linux distribution doesn’t have the standard Microsoft fonts, so the I have the required fonts (1.35GB in total) are loaded by FontsLoader.loadExternalFonts
. Most of the time, the font load take about 0-2ms. However, there are time it takes more than 14s to just load the font. May I know what’s the more efficient ways to load the fonts?
def loadStart = System.currentTimeMillis();
FontsLoader.loadExternalFonts(new String[] {"/usr/share/fonts/truetype/msttcorefonts"});
def loadEnd = System.currentTimeMillis();
logger.info("Font load executionTime: " + (loadEnd-loadStart) + "ms");
//most of the time it takes 0-2ms, but there's one execution that takes
// Font load executionTime: 142596ms
Initially, I have the fonts placed under /usr/share/fonts/truetype/msttcorefonts
and ran fc-cache -f -v
. That doesn’t seems to load the fonts for conversion automatically. So I load it with the loadExternalFotns
method in code
@minketalus,
Thank you for contacting support.
The fonts installed in the folder /usr/share/fonts
and its subfolders are system fonts and you do not need to load them using the FontsLoader.loadExternalFonts
method. If the fonts are not loaded, it means that your application process does not have access to them.
However, it worked after I call FontsLoader.loadExternalFonts
. Doesn’t that imply the application process does have access to the fonts?
@minketalus,
It looks like you are right. Anyway, you shouldn’t load system fonts using the FontsLoader.loadExternalFonts
method. Could you please share the output of the command fc-list
?
The output of fc-list is indeed correct after the fc-cache -f -v.
So what I tried is that, after installing the fonts and fc-cache -f -v, I have stop and deploy the application. However, the fonts are still missing (i can see bullet point can’t resolve and show ‘n’). So I added the line of loading fonts, deployed the same way and the bullet points got resolved.
Anyways, is there any harm loading the system fonts as external fonts again? A bit worried about how it will play out in prod
fc-list | grep wing
/usr/share/fonts/truetype/msttcorefonts/wingding.ttf: Wingdings:style=Regular,Standard
@minketalus,
The entire process of working with fonts is briefly as follows. Aspose.Slides for Java queries the JDK to see what fonts are available. The JDK returns a list of fonts that it knows are on the system. Aspose.Slides for Java then starts using these fonts. Using the FontsLoader.loadExternalFonts
method will essentially repeat the process of registering fonts. Could you please indicate the version of the operating system on which you are having the problem?