We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Default fonts on MacOS Big Sur

Hello,

wanted to clarify the topic of loading fonts on MacOS Big Sur system. Your documentation (https://docs.aspose.com/cells/java/configuring-fonts-for-rendering-spreadsheets/) says:
“In order to maximize the conversion fidelity, it is necessary that the fonts used in the spreadsheet should be available in the operating system’s default font directory.” & “Aspose.Cells APIs search the operating system’s default font directory for the required fonts.”

The thing is that I’m getting wrong results when autofitting row on MacOS system, unless I configure the path manually myself (/System/Library/Fonts with recursive option ON, which might be important as MacOS now holds significant amount of fonts in /System/Library/Fonts/Supplemental).

    FontConfigs.setFontFolder("/System/Library/Fonts", true);
    System.out.println("Aspose version: " + CellsHelper.getVersion());
    System.out.println("Java version: " + System.getProperty("java.version"));
    System.out.println("OS version: " + System.getProperty("os.name"));
    Workbook w1 = new Workbook();
    Style style = w1.getWorksheets().get(0).getCells().get("A1").getStyle();
    style.setTextWrapped(true);
    w1.getWorksheets().get(0).getCells().get("A1").setStyle(style);
    w1.getWorksheets().get(0).getCells().get("A1").setValue("LOOOOOOOOOOOOOOOOOONG TEEEEEEEEEEXT");
    w1.getWorksheets().get(0).autoFitRow(0);
    System.out.println(w1.getWorksheets().get(0).getCells().getRowHeight(0));

prints 76.5

but

    System.out.println("Aspose version: " + CellsHelper.getVersion());
    System.out.println("Java version: " + System.getProperty("java.version"));
    System.out.println("OS version: " + System.getProperty("os.name"));
    Workbook w1 = new Workbook();
    Style style = w1.getWorksheets().get(0).getCells().get("A1").getStyle();
    style.setTextWrapped(true);
    w1.getWorksheets().get(0).getCells().get("A1").setStyle(style);
    w1.getWorksheets().get(0).getCells().get("A1").setValue("LOOOOOOOOOOOOOOOOOONG TEEEEEEEEEEXT");
    w1.getWorksheets().get(0).autoFitRow(0);
    System.out.println(w1.getWorksheets().get(0).getCells().getRowHeight(0));

prints 105.0

It seems like the second version didn’t find required fonts to make proper calculations? Or maybe there is yet another reason?

It would be much easier for us if it would load the required fonts. Otherwise we would have to modifying how we run aspose per environents (dev machines/OSes/cloud) and usecases.

@konradglayer,

Please note, the Aspose.Cells APIs always scans the operating system’s default font directory with one exception, that is; when JVM arguments -DAspose.Cells.FontDirExc=“YourFontDir” are set, so you should evaluate it on your end.

Moreover, on a safer side, it is always better to explicitly set the fonts folder path/configurations using the FontConfigs.setFontFolder/FontConfigs.setFontFolders API at the start. So, you should also set it for second version.

I’m 100% sure that I’m not using Aspose.Cells.FontDirExc flag.

That is contrary to what your documentation states at: https://docs.aspose.com/cells/java/configuring-fonts-for-rendering-spreadsheets/. It’s pretty explicit about Aspose scanning system folders, which seems not to be the case on MacOS.

@konradglayer,
We have tried this scenario in macOS and observed no issue as following is the output by executing both the code samples:

Aspose version: 21.7.3
Java version: 1.8.0_131
OS version: Mac OS X
76.5

Aspose version: 21.7.3
Java version: 1.8.0_131
OS version: Mac OS X
76.5 

This output shows that even if we do not use FontConfigs.setFontFolder("/System/Library/Fonts", true);, it uses font information from the Fonts folder. Could you please test this scenario on some other system and share the feedback.

We have run those snippets on two development machines, configured independently, with the same result - wrong height if we do not configure the fontFolder.

Have you tried it on MacOS Big Sur? Apple made some changes to font location in recent versions of MacOS.

$ sw_vers
ProductName: macOS
ProductVersion: 11.4
BuildVersion: 20F71

@konradglayer

We have logged the issue as “CELLSJAVA-43566” in our database for investigations. Once we will have some news for you, we will update you in this topic.

@konradglayer,

We are working over your issue and hopefully we will provide the fixed version in the next week.

@konradglayer

Please try the latest fix v21.7.5 and give us your feedback.
aspose-cells-21.7.5-java.zip (7.4 MB)