I also have a usecase where I need to limit the folder that aspose looks into to find the necessary fonts and skip looking into any default system defined font folders.
I found on the page at
that this could be done by setting the system property. I used the below mentioned line:
pathToMyDir/albany/.ttf (variations of albany font)
pathToMyDir/liberation/.ttf (variations of liberation font)
I am running into the problem that whenever I set the system property to limit the folders that aspose cells looks into, I can no longer use any other font from under albany or liberation folder. Cells is always choosing oracle-wingdings as the font that substitutes any missing font in excel files.
So, if I have an excel file that uses Times New Roman in a table, and I want to generate an image from the sheet in question, it looks like aspose cells is using the font oracle-wingdings, even when I have the default font defined as follows:
FontConfigs.setDefaultFontName(“Albany WT J”);
I can use this default font that I set to generate the image if I don’t have the system property set.
Can you please advice me how to limit the folders, and also have the flexibility that allows aspose cells to recursively look in to folders for fonts specified? And if necessary, use a default font as well?
For you reference I have attached:
1. ReferenceDoclet.xlsx – the excel file that has the table defined
2. actual_table_fonts.PNG – the actual table generated using the wrong font
3. expected_table_fonts.PNG – the expected table that should be generated when I have the system property set, and the font folders specified via the FontConfigs method mentioned.
below is the code that I have used to generate that result:
Workbook wb = new Workbook(“ReferenceDoclet.xlsx”);
We did evaluate your issue further. Well, if for example, System.setProperty("Aspose.Cells.FontDirExc", "pathToMyDir"); is set, Aspose.Cells will only use fonts in "pathToMyDir" and won't look for fonts into its sub dirs. So, any other font folders setting and font sources setting in FontConfigs will not take effect anymore.
For your requirements, as you mentioned:
"Can you please advice me how to limit the folders, and also have the flexibility that allows aspose cells to recursively look in to folders for fonts specified? And if necessary, use a default font as well?"
We can add a new API so that you could limit to some folder and its sub-folders (directory) to use fonts in rendering images/PDF. I have logged a ticket with an id "CELLSJAVA-42226" for your issue/requirements.
By the way, you can use FontConfigs.setFontSubstitutes(String originalFontName, String[] substituteFontNames) to specify font substitute if you are not satisfied with our font substitution.
This is to inform you that we have fixed your issue CELLSJAVA-42226 now. We will soon provide the fix after performing QA and including other enhancements and fixes.
We added API: setFontExclusiveSources(FontSourceBase[] exclusiveSources) in FontConfigs to set the fonts exclusive sources in the fix: Aspose.Cells for Java v17.3.5 (please try it), like older APIs: System.setProperty(“Aspose.Cells.FontDirExc”, “fontExclusiveFolder”).
System.setProperty(“Aspose.Cells.FontDirExc”, “fontExclusiveFolder”) will be ignored if this is set.
e.g
Sample code:
//only use fonts in “fontExclusiveFolder” dir and it’s sub dirs.
Good to know that the new fix works for your requirements.
For your information, the hotfixes (e.g v17.3.5) posted into the forums can be directly used for production, these will behave like official releases of the product which have all the functionality (full fledged) of Aspose.Cells for .NET v17.3.0 till this fix. We normally provide quick fixes (interim releases) into support forums for the users against their issues, so they do not have to wait much to get fix of their issues. However, our next official release of the product i.e., Aspose.Cells for .NET v17.4.0 (which will also include the functionality of this fix) will be scheduled to be released in the mid of next month (April 2017).
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.