An error occurs When calling FontRepository.addLocalFontPath(“localFontPath”).
but, the parameter(“localFontPath”) passed fine…
*Error: StringIndexOutOfBoundsException
The jar file uses the aspose-pdf-19.2-jdk16.jar version.
The location of the font to be used is located in C:\font.
*An error also occurs when reading fonts in the C:\Windows\Fonts location provided by default in window.
The current development environment is a vdi(virtual desktop infrastructure) environment.
Is this related?
Yes, the issue looks related to the specific environment. We tested in Windows OS and could not reproduce the issue. Can you please try using 23.7 version of the API and see if that raised the similar exception? We will log an investigation ticket and share the ID with you.
Thank you for answer.
But, the issue is not solved.
As a result of checking, the default font C:\windows\fonts provided by Windows OS system is not being accessed.
*Folder files that I created separately can be accessed.
Could you please provide the code(logic) to access the Fonts of the window OS system?
The API by default access the font from “C:\Windows\Fonts” directory in Windows and from “/usr/share/fonts/truetype/msttcorefonts” in Linux like operating system. If such directory is not present or not accessible, API throws an exception. In such case, you can define the fonts resources in the API where all fonts are located.
FontRepository.getSources().clear();
FontSource fs = new FileFontSource(dataDir + "customfonts\\");
FontRepository.getSources().add(fs);
Furthermore, if such directories are present in the VDI environment, please make sure that your application is able to access these directories. In case issue still persists, please share some more details about the environment and we will investigate accordingly.
I cleared all FontRespository resources and code to directly access the directory where the font exists through FontSource.
But, the issue is not resolved.
I think I can access the custom font directory, but I can’t access C:\windows\Fonts.
Is the logic for accessing fonts provided by Windows related to lines 298 to 299 rows of FontRepository?
As shared earlier, you do not need specific code to search this directory as API does it by default. Furthermore, you can add this source directory using the same code snippet which was shared earlier.
Can you please share the complete error stack information and more details about the VDI environment? We will log an investigation ticket and share the ID with you.
The location where the error occurs is FontRepository.addLocalFontPath(“fontPath”).
It seems that an error occurs in some code inside the function (addLocalFontPath).
The error stack is as follows.
nested exception is class com.aspose.pdf.internal.ms.System.lk: Value cannot be null.
Parameter name: path1
com.aspose.pdf.internal.ms.System.IO.l1y.lf(Unknown Source)
com.aspose.pdf.FontRepository.lI(Unknown Source)
com.aspose.pdf.FontRepository.getLocalFontPaths(Unknown Source)
com.aspose.pdf.FontRepository.lI(Unknown Source)
com.aspose.pdf.FontRepository.addLocalFontPath(Unknown Source)
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFJAVA-43096
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
We are afraid that the earlier logged ticket has not been yet resolved. We have recorded your concerns and will surely inform you as soon as we make some progress towards ticket resolution. We apologize for the inconvenience.