Just for understand better, why you need to include also the Arial TTF file? Wasn't enough to add only the default (Calibri)?
You do not need Arial font files for the code snippet shared in this thread. You only need Calibri font files to correctly calculate the column widths unless you are auto-fitting the columns according to the content size. In that case you also require the Arial font files because a few cells in the given cell range have been formatted with Arial font. Moreover, for rendering purposes, it is best to have all the required fonts (Calibri, Tahoma & Arial) otherwise you will notice slight difference in size and shape of the contents due to font substitution mechanism triggered in such cases.
In my environment , do you think the missing font was Calibri or Arial or both? Should i set the font directory only for the missing font?
Please note, most of the Linux operating systems do not come with pre-installed windows fonts unless you have manually configured mscorefonts
, which too does not contain the Calibri font. I think you were missing the Calibri font files which are essential for the presented scenario.
Should i set the font directory only for the missing font? If my workbook contains some cells with some of the fonts already present in the environment, the app can see them or it search them in the font directory i've set?
As discussed earlier, Linux environments usually lack the Windows fonts therefore it is best to inspect the Workbook for used fonts (you can use Workbook.getFonts() method to get a list of required fonts) and make all the required fonts available to the API. This is the best scenario for rendering spreadsheets. However, if you are just checking the column widths and row heights, you only require the default font of the spreadsheet which can be inspected while using the Workbook.getDefaultStyle().getFont() method. If the required fonts are present in the environment (in fonts default directory), the API will automatically pick the required fonts, otherwise you have to explicitly tell the API where to look for the fonts.
The last question is, if i install the missing font in the /usr/share/fonts, i still need to set the font directory?
Please note that Aspose.Cells for Java API scans the "/usr/share/fonts" directory and its sub directories for font files (TTF & TTC) as a default behaviour. That means, if you place all the required fonts on aforementioned location, you do not need to explicitly set the font location in your code.