No fonts exception when saving MPP project

Greetings

We are using Aspose Tasks for Java in version 17.5 (jdk16).

We have the code that looks something like this:
Note: InputStream is just a stream of the empty mpp project

public void convertToImage(InputStream sourceStream, OutputStream targetStream) throws Exception {
	Project project = new Project(sourceStream);
	project.save(targetStream, createOptions());
}

private SaveOptions createOptions() {
	SaveOptions saveOptions = new ImageSaveOptions(SaveFileFormat.PNG);
	saveOptions.setView(ProjectView.getDefaultGanttChartView());
	saveOptions.setFitContent(true);
	saveOptions.setRollUpGanttBars(false);
	saveOptions.setDrawNonWorkingTime(true);
	saveOptions.setPageSize(PageSize.A4);
	saveOptions.setTimescale(Timescale.Days);
	return saveOptions;
}

So when we try to save a project as an image we get this exception:

class com.aspose.tasks.private.Exceptions.InvalidOperationException: Cannot find any fonts installed on the system.
com.aspose.tasks.private.ad.i.a(Unknown Source)
com.aspose.tasks.private.ad.i.a(Unknown Source)
com.aspose.tasks.private.ad.i.a(Unknown Source)
com.aspose.tasks.y.a(Unknown Source)
com.aspose.tasks.p$a.(Unknown Source)
com.aspose.tasks.p.(Unknown Source)
com.aspose.tasks.x.(Unknown Source)
com.aspose.tasks.x.(Unknown Source)
com.aspose.tasks.w.n(Unknown Source)
com.aspose.tasks.i.l(Unknown Source)
com.aspose.tasks.m.l(Unknown Source)
com.aspose.tasks.w.l(Unknown Source)
com.aspose.tasks.czs.a(Unknown Source)
com.aspose.tasks.Project.a(Unknown Source)
com.aspose.tasks.Project.save(Unknown Source)

So the error says that there are no fonts on the system, but interestingly enough running the code below lists all the fonts installed (so Java ‘sees’ the fonts):

GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
for (String font : e.getAvailableFontFamilyNames()) {
     log.debug(font);
}

So my questions are:

  1. does the Aspose task library need any specific fonts?
  2. how and where does it look for fonts in the system?
  3. is there any Java code we could run (on the customer’s production server) to debug what the problem is? (from the given exception it is hard to understand what the problem really is…)

@SoftwarePlant,

Could you please share your sample Project file with us for further investigation at our end? Our API doesn’t require any specific fonts for conversion of project data to images.

About the location of fonts in the system, we have requested this information from our Product team. Please share with us your environment details i.e. which OS you are using?

I attached the file you requested.
The problem occurs in our customer’s environment. The OS is Unix.

project.zip (25.5 KB)

@SoftwarePlant,

The file you have shared is empty. Can you confirm to us if it is the right file you have shared with us?

@SoftwarePlant,

We have reported this issue to our Product team via TASKSJAVA-457 for further investigation . We’ll update you here once there is furhter information or a fix version available in this regard.

Yes, I confirm that the file I shared is empty - we use it as our template to generate data exports for our customers. But we still got that exception. That is why I asked for your help with it.

@SoftwarePlant,

We will update you here once there is some information available in this regard.

@SoftwarePlant,

As per our investigations, there are no TrueType fonts installed on your server. Aspose.Tasks API supports only TrueType fonts which were not found on your server. At present, we have no plans to support other type of fonts. To solve the issue, however, you can copy TTF fonts to one of following directories:

/usr/share/fonts // Ubuntu, openSUSE
/usr/local/share/fonts // Fedora?
/usr/X11R6/lib/X11/fonts // RHEL?
/usr/share/X11/fonts // CentOS?
~/.fonts of the user running the application.

Thank you. This is very useful information.

You are welcome.