Providing substitute fonts

When I run tests with Aspose library on CI environment I got:

-----
java.lang.RuntimeException:
class com.aspose.tasks.private.Exceptions.InvalidOperationException: Cannot find any fonts installed on the system.
com.aspose.tasks.private.u.i.a(Unknown Source)
com.aspose.tasks.private.u.i.a(Unknown Source)
com.aspose.tasks.private.u.i.a(Unknown Source)
com.aspose.tasks.z.a(Unknown Source)
com.aspose.tasks.q$a.(Unknown Source)
com.aspose.tasks.q.(Unknown Source)
com.aspose.tasks.y.(Unknown Source)
com.aspose.tasks.y.(Unknown Source)
com.aspose.tasks.x.n(Unknown Source)
com.aspose.tasks.j.l(Unknown Source)
com.aspose.tasks.x.l(Unknown Source)
com.aspose.tasks.cyd.a(Unknown Source)
com.aspose.tasks.Project.save(Unknown Source)
-----

How can I provide Aspose with default fonts i case there is non installed on host environment?

Hi Bartłomiej,

Thank you for contacting Aspose Suppor team.

Can you please share your environment details with us? Aspose.Tasks API is not dependent on any fonts and should not raise any such exception. Please share your environment details alongwith your sample file/code so that we can investigate the issue further for assisting you. Please make sure that you are using the latest version of Aspose.Tasks for Java API.

I wrote a Test that reads simple *.mpp file and writes it into *.pdf.


@Test()
public void testWrite() throws IOException {
Project project = new Project(MSProjectProgrmWriterPdfTest.class.getClassLoader().getResource(“app/export/writer/ms_project/project.mpp”).openStream());
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setView(ProjectView.getDefaultGanttChartView());
saveOptions.setFitContent(true);
saveOptions.setRollUpGanttBars(false);
saveOptions.setDrawNonWorkingTime(true);
saveOptions.setPageSize(PageSize.A4);
saveOptions.setTimescale(Timescale.Days);


Properties p = System.getProperties();
Enumeration keys = p.keys();
while (keys.hasMoreElements()) {
String key = (String)keys.nextElement();
String value = (String)p.get(key);
//CHECKSTYLE OFF 1
System.out.println(key + ": " + value);
}

File file = File.createTempFile(“tmp-ms-project-”, “.pdf”);
project.save(file.getAbsolutePath(), saveOptions);
file.delete();
}
At runtime I print system properties:
java.runtime.name: Java™ SE Runtime Environment
sun.boot.library.path: /var/lib/jenkins/tools/hudson.model.JDK/Java_SE_7/jre/lib/amd64
java.vm.version: 24.55-b03
java.vm.vendor: Oracle Corporation
java.vendor.url: http://java.oracle.com/
path.separator: :
java.vm.name: Java HotSpot™ 64-Bit Server VM
file.encoding.pkg: sun.io
user.country: US
sun.java.launcher: SUN_STANDARD
sun.os.patch.level: unknown
java.vm.specification.name: Java Virtual Machine Specification
user.dir: /var/lib/jenkins/jobs/PPM jira6 REVIEW/workspace/ppm/export
java.runtime.version: 1.7.0_55-b13
basedir: /var/lib/jenkins/jobs/PPM jira6 REVIEW/workspace/ppm/export
java.awt.graphicsenv: sun.awt.X11GraphicsEnvironment
java.endorsed.dirs: /var/lib/jenkins/tools/hudson.model.JDK/Java_SE_7/jre/lib/endorsed
os.arch: amd64
surefire.real.class.path: /var/lib/jenkins/jobs/PPM jira6 REVIEW/workspace/ppm/export/target/surefire/surefirebooter6035748717849165968.jar
java.io.tmpdir: /tmp
line.separator:

java.vm.specification.vendor: Oracle Corporation
os.name: Linux
sun.jnu.encoding: UTF-8
java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
surefire.test.class.path: /var/lib/jenkins/jobs/PPM jira6 REVIEW/workspace/ppm/export/target/test-classes:/var/lib/jenkins/jobs/PPM jira6 REVIEW/workspace/ppm/export/target/classes:/var/lib/jenkins/.m2/repository_review/org/apache/commons/commons-lang3/3.4/commons-lang3-3.4.jar:/var/lib/jenkins/.m2/repository_review/com/aspose/aspose-tasks/9.2.0/aspose-tasks-9.2.0-jdk16.jar:/var/lib/jenkins/.m2/repository_review/com/aspose/aspose-words/16.1.0/aspose-words-16.1.0-jdk16.jar:/var/lib/jenkins/.m2/repository_review/com/aspose/aspose-cells/8.7.0/aspose-cells-8.7.0.jar:/var/lib/jenkins/.m2/repository_review/com/google/guava/guava/11.0.2/guava-11.0.2.jar:/var/lib/jenkins/.m2/repository_review/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar:/var/lib/jenkins/.m2/repository_review/joda-time/joda-time/2.3/joda-time-2.3.jar:/var/lib/jenkins/.m2/repository_review/org/slf4j/slf4j-api/1.7.12/slf4j-api-1.7.12.jar:/var/lib/jenkins/.m2/repository_review/org/mockito/mockito-all/1.9.0/mockito-all-1.9.0.jar:/var/lib/jenkins/.m2/repository_review/org/assertj/assertj-core/1.7.1/assertj-core-1.7.1.jar:/var/lib/jenkins/.m2/repository_review/junit/junit/4.12/junit-4.12.jar:/var/lib/jenkins/.m2/repository_review/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/var/lib/jenkins/.m2/repository_review/org/testng/testng/6.8.8/testng-6.8.8.jar:/var/lib/jenkins/.m2/repository_review/org/beanshell/bsh/2.0b4/bsh-2.0b4.jar:/var/lib/jenkins/.m2/repository_review/com/beust/jcommander/1.27/jcommander-1.27.jar:/var/lib/jenkins/.m2/repository_review/org/easytesting/fest-assert/1.4/fest-assert-1.4.jar:/var/lib/jenkins/.m2/repository_review/org/easytesting/fest-util/1.1.6/fest-util-1.1.6.jar:/var/lib/jenkins/.m2/repository_review/com/softwareplant/jdependunit/1.0.13/jdependunit-1.0.13.jar:/var/lib/jenkins/.m2/repository_review/jdepend/jdepend/2.9.1/jdepend-2.9.1.jar:/var/lib/jenkins/.m2/repository_review/org/apache/maven/surefire/surefire-testng-utils/2.19.1/surefire-testng-utils-2.19.1.jar:/var/lib/jenkins/.m2/repository_review/org/apache/maven/surefire/surefire-grouper/2.19.1/surefire-grouper-2.19.1.jar:
java.specification.name: Java Platform API Specification
java.class.version: 51.0
sun.management.compiler: HotSpot 64-Bit Tiered Compilers
maven.repo.local: /var/lib/jenkins/.m2/repository_review
os.version: 3.10.0-327.3.1.el7.x86_64
user.home: /var/lib/jenkins
user.timezone: Europe/Warsaw
java.awt.printerjob: sun.print.PSPrinterJob
file.encoding: UTF-8
java.specification.version: 1.7
java.class.path: /var/lib/jenkins/jobs/PPM jira6 REVIEW/workspace/ppm/export/target/test-classes:/var/lib/jenkins/jobs/PPM jira6 REVIEW/workspace/ppm/export/target/classes:/var/lib/jenkins/.m2/repository_review/org/apache/commons/commons-lang3/3.4/commons-lang3-3.4.jar:/var/lib/jenkins/.m2/repository_review/com/aspose/aspose-tasks/9.2.0/aspose-tasks-9.2.0-jdk16.jar:/var/lib/jenkins/.m2/repository_review/com/aspose/aspose-words/16.1.0/aspose-words-16.1.0-jdk16.jar:/var/lib/jenkins/.m2/repository_review/com/aspose/aspose-cells/8.7.0/aspose-cells-8.7.0.jar:/var/lib/jenkins/.m2/repository_review/com/google/guava/guava/11.0.2/guava-11.0.2.jar:/var/lib/jenkins/.m2/repository_review/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar:/var/lib/jenkins/.m2/repository_review/joda-time/joda-time/2.3/joda-time-2.3.jar:/var/lib/jenkins/.m2/repository_review/org/slf4j/slf4j-api/1.7.12/slf4j-api-1.7.12.jar:/var/lib/jenkins/.m2/repository_review/org/mockito/mockito-all/1.9.0/mockito-all-1.9.0.jar:/var/lib/jenkins/.m2/repository_review/org/assertj/assertj-core/1.7.1/assertj-core-1.7.1.jar:/var/lib/jenkins/.m2/repository_review/junit/junit/4.12/junit-4.12.jar:/var/lib/jenkins/.m2/repository_review/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/var/lib/jenkins/.m2/repository_review/org/testng/testng/6.8.8/testng-6.8.8.jar:/var/lib/jenkins/.m2/repository_review/org/beanshell/bsh/2.0b4/bsh-2.0b4.jar:/var/lib/jenkins/.m2/repository_review/com/beust/jcommander/1.27/jcommander-1.27.jar:/var/lib/jenkins/.m2/repository_review/org/easytesting/fest-assert/1.4/fest-assert-1.4.jar:/var/lib/jenkins/.m2/repository_review/org/easytesting/fest-util/1.1.6/fest-util-1.1.6.jar:/var/lib/jenkins/.m2/repository_review/com/softwareplant/jdependunit/1.0.13/jdependunit-1.0.13.jar:/var/lib/jenkins/.m2/repository_review/jdepend/jdepend/2.9.1/jdepend-2.9.1.jar:/var/lib/jenkins/.m2/repository_review/org/apache/maven/surefire/surefire-testng-utils/2.19.1/surefire-testng-utils-2.19.1.jar:/var/lib/jenkins/.m2/repository_review/org/apache/maven/surefire/surefire-grouper/2.19.1/surefire-grouper-2.19.1.jar:
user.name: jenkins
java.vm.specification.version: 1.7
sun.java.command: /var/lib/jenkins/jobs/PPM jira6 REVIEW/workspace/ppm/export/target/surefire/surefirebooter6035748717849165968.jar /var/lib/jenkins/jobs/PPM jira6 REVIEW/workspace/ppm/export/target/surefire/surefire5199888091428401958tmp /var/lib/jenkins/jobs/PPM jira6 REVIEW/workspace/ppm/export/target/surefire/surefire_68963251701099218047tmp
java.home: /var/lib/jenkins/tools/hudson.model.JDK/Java_SE_7/jre
sun.arch.data.model: 64
user.language: en
java.specification.vendor: Oracle Corporation
awt.toolkit: sun.awt.X11.XToolkit
java.vm.info: mixed mode
java.version: 1.7.0_55
java.ext.dirs: /var/lib/jenkins/tools/hudson.model.JDK/Java_SE_7/jre/lib/ext:/usr/java/packages/lib/ext
sun.boot.class.path: /var/lib/jenkins/tools/hudson.model.JDK/Java_SE_7/jre/lib/resources.jar:/var/lib/jenkins/tools/hudson.model.JDK/Java_SE_7/jre/lib/rt.jar:/var/lib/jenkins/tools/hudson.model.JDK/Java_SE_7/jre/lib/sunrsasign.jar:/var/lib/jenkins/tools/hudson.model.JDK/Java_SE_7/jre/lib/jsse.jar:/var/lib/jenkins/tools/hudson.model.JDK/Java_SE_7/jre/lib/jce.jar:/var/lib/jenkins/tools/hudson.model.JDK/Java_SE_7/jre/lib/charsets.jar:/var/lib/jenkins/tools/hudson.model.JDK/Java_SE_7/jre/lib/jfr.jar:/var/lib/jenkins/tools/hudson.model.JDK/Java_SE_7/jre/classes
java.vendor: Oracle Corporation
localRepository: /var/lib/jenkins/.m2/repository_review
file.separator: /
java.vendor.url.bug: http://bugreport.sun.com/bugreport/
sun.font.fontmanager: sun.awt.X11FontManager
sun.io.unicode.encoding: UnicodeLittle
sun.cpu.endian: little
sun.cpu.isalist:


When test is runned on CI environment, then the exception is thrown.

I have checked JRE fonts directory - fonts are present.
Environment default fonts are installed. Their directories are:
- /usr/share/fonts
- /usr/X11R6/lib/X11/fonts /usr/local/share/fonts
- ~/.fonts

I’ve attached the *.ppm file.

It seems CI environment is OK.

Hi Bartłomiej,

Could you please share the exact version of the server where the tests are running? We have tested it on latest version of Ubuntu over a Virtual Machine and not such issue was faced. Please share details of server and java installed for our further analysis.

The exact version of the server is placed in my previous post under os.version key.

Hi Bartłomiej,


We have again tested it at our end with latest version of the API and JDK 1.7 but were not able to reproduce the same at our end. Could you please check it with the latest version of the API and share your feedback with us? If possible, please share a link to the linux version for downloading so that we can configure it as a VM at our end for reproducing the issue.

Hi,


Now one of our clients has such problem.

The client hosts application at Ubuntu 14.04.5 LTS.
System fonts are visible to the application user. Configured system fonts are:
<div style=“color: rgb(34, 34, 34); font-family: “Helvetica Neue”, Helvetica, Arial, sans-serif; background-color: rgb(255, 255, 255);”>- truetype: liberation, msttcorefonts
<div style=“color: rgb(34, 34, 34); font-family: “Helvetica Neue”, Helvetica, Arial, sans-serif; background-color: rgb(255, 255, 255);”>- type1: gsfonts<div style=“color: rgb(34, 34, 34); font-family: “Helvetica Neue”, Helvetica, Arial, sans-serif; background-color: rgb(255, 255, 255);”>- X11: (the classic, standard one)

Hi Bartłomiej,


Thank you for sharing additional information.

We downloaded this version of Ubuntu and installed as VM at our end from the official release page (torrent attached). We tested the issue again with the latest version of the API on this VM and even the default version of the VM didn’t raise any such issue. Could you please share if there is anything else which is different than the default installation of Ubuntu that may be raising any such issue? May be there are some permission issues that could be causing the problem.

I am sure the problem exists and we have successfully reproduced it.


We used docker to install:
- OS: 14.04.5 Long Term Support
- JAVA: 1.8.0_101

We have reproduced the issue by running our application which exported MSProject file to *.pdf that displayed Gantt Chart.

Only after installing True Type Liberation fonts and linking them to JRE fonts the problem disappeared and we could successfully export to *.pdf.

This proves that, contrary to what you wrote, Aspose.Tasks API depends on environment fonts.

Hi,


The problem didn’t arose at our end for the reason that these fonts were available by default in the Ubuntu version that we downloaded for installation on a VM. We didn’t install or configure any such fonts after configuring the VM at our end and that is why we didn’t state any such thing as the requirement of fonts for this purpose. If installing and configuring the fonts have solved your issue, we can stop our further investigation into this issue.

I believe this issue should be assumed closed if you add proper information about fonts requirement to Aspose.Tasks documentation.


Please dig into Aspose.Tasks code in order to specify what is the minimal fonts set in order to export PDF. Please start with OS without fonts installed.

Hi,


We have logged this request of identifying the required fonts as TASKSNET-1659 in our issue tracking system for further feedback from our Product team. We’ll update you here once there is some information available in this regard.