Hallo
I am trying to use a custom font folder, but it does not seem to work as expected. I am using Java and my OS is Windows 7.
Steps to reproduce:
- copy Arial Unicode MS from C:\Windows\Fonts to C:\CustomFonts
- delete Arial Unicode MS from C:\Windows\Fonts
- run the following code snippet:
com.aspose.cells.FontConfigs.setFontFolder(“C:\CustomFonts”, true);
com.aspose.pdf.Document doc = new com.aspose.pdf.Document(“Blank.pdf”);
com.aspose.pdf.Table table = new com.aspose.pdf.Table();
table.setColumnWidths(“400”);
table.getRows().add().getCells().add(“竤”);
doc.getPages().get_Item(1).getParagraphs().add(table);
doc.save(“Result.pdf”);
Note that the “竤” character is not shown correctly in the PDF. I would have expected that the font file is found and used from the “C:\CustomFonts” location (if I re-install the deleted font, it is recognized and used from the C:\Windows\Fonts folder).
I am using:
aspose-cells - 9.0.0
aspose-pdf - 11.8.0
I also tried older versions of aspose-cells with the following code snippets
CellsHelper.setFontDir(“C:\CustomFonts”);
System.setProperty(“Aspose.Cells.FontDirExc”, “C:\CustomFonts”);
but it also does not work as expected.
Am I doing something wrong?
Thank you,
Samuel
Hi,
Hi Samuel,
Thanks for your inquiry. Please note if you want to use some custom font folder then you need to add folder in font folder lists as following.
String path = “E:/Data/Fonts/”;
List fontPaths = com.aspose.pdf.Document.getLocalFontPaths();
fontPaths.add(path);
com.aspose.pdf.Document.setLocalFontPaths(fontPaths);
However you can also use a font directly from a file path as following
textState.setFont(FontRepository.openFont(myDir+"mangal.ttf"));
Please feel free to contact us for any further assistance.
Best Regards,
Hallo
Works like a charm. Thank you,
Samuel
Hi Samuel,
I am using aspose.pdf-21.6.jar. How to set up customs fonts folder. I cannot see anything in the API. I want to run the API on Ubuntu
You can please use FontRepository.setLocalFontPaths(“fontPaths”); method offered by the API to set the custom font folder path. The required method was moved under FontRepository
Class in higher/latest version(s).
Thanks… I upload microsoft fonts under /usr/share/fonts
Now i am able to get the required output. There are no more error related to Fonts. However, i still need to compare the fonts
Can you please elaborate on why and how you need to compare fonts? Please share a bit more details so that we can check related information at our end and share it with you.
I am still experiencing some issue with performance. CPU Utilization is high. Is there any mechanism by which i can increase the performance. Can we configure to use multi threading?
You can please try increasing the Java Heap Size. Also, you can surely use the API in multi-threading environment. However, please note that Aspose.PDF is a multi-threaded safe API which means you will not face any issue until one document is accessed only by one thread at a time.