Hi Team, we are trying to figure out what all fonts are used by Group Docs convertor library for JAVA by default. We wish to add more fonts which are not used by default, It would be a great help if you could tell the fonts that group docs come out of the box. also do you support CJK fonts by default? please answer this in reference to JAVA API version 22.3 and 20.10
Let’s understand how GroupDocs.Conversion for Java utilizes fonts.
Suppose you have a Word file with textual content in Times New Roman font and you want to convert it to a PDF format. Now, if Times New Roman is installed on your machine/server, the resultant PDF will have all the text in Times New Roman.
If the concerned font is missing on your computer, you can set the default font as follows:
//Java code WordProcessingLoadOptions loadOptions = new WordProcessingLoadOptions(); loadOptions.setDefaultFont("Helvetica");
Please have a look at this documentation article - Specify font substitution.
If the font is installed on the machine, you can set it as a default in loading option.
Thank you so much for the response it was really helpful.
couple of follow up questions. We were planing to use setFontDirectories(List value) method in convertor settings. can you please let us know what should the font directory contains or is there any same we can refer to for the same?
Also, setting font directory in convertor setting and passing the convertor settings to convertor object should work?
You can install fonts or copy font files to any folder and specify this folder in
ConverterSettings converterSettings = new ConverterSettings(); converterSettings.setFontDirectories(Collections.singletonList("/fontsfolder"));
Yes, please have a look at the full sample/code:
ConverterSettings converterSettings = new ConverterSettings(); converterSettings.setFontDirectories(Collections.singletonList("/fontsfolder")); WordProcessingLoadOptions loadOptions = new WordProcessingLoadOptions(); loadOptions.setDefaultFont("MSGothic"); final Converter converter = new Converter("input file/stream", loadOptions, converterSettings);
One more follow up question, if I set a custom font directory using converterSettings.setFontDirectories() method, Will the fonts already installed in the system not used, or will the be used like normal? I want to insure that the fonts that are already in installed in the system are also used while conversion.
Yes, if the source file is relying on a font that is already installed on your machine, it will be used.
You are welcome.
Hi Atir, I have one more question for you.
What is the preference of fonts used internally? If a System Font is available and a font is available in our custom fonts folder - which one would be picked up for rendering?
It’ll pick system fonts.
Also, is there any way to cache the fonts that are being used? Since for every file conversion we are passing the ConverterSettings object to the Converter object?
We are investigating this scenario. Your investigation ID is CONVERSIONJAVA-1626.
This is not possible in GroupDocs.Conversion for Java API.
So is there any performance impact if we are setting a custom font directory for every conversion?
We don’t think so. However, we’ve created a ticket to evaluate performance. Your investigation ticket ID is CONVERSIONJAVA-1627.
Could you please share preference for count of fonts in the custom font folder? If you share your use-case (the number of fonts available in your directory), we’ll evaluate performance accordingly.
Thanks, we are using around 11 fonts in the custom font folder. most of these fonts are notosans CJK fonts while the others are Arabic, Hebrew, sourcesans, and NotoSans basic. the total size of this directory is about 70Mb
Thanks for the details. We will continue our investigation. You’ll be notified about the outcomes.
Hi Tahir, Any updates on this?
This scenario is still under investigation. We’ll let you know once there’s any update.
For the file in the sample project with number of fonts in fonts folder the numbers for 100 iterations are as follow:
- Without custom fonts - 50 seconds
- With custom fonts folder - 70 seconds
Please note that these measurements depends from the source file size and the count of the fonts in the custom fonts folder.