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

Free Support Forum - aspose.com

FontSettings.setFontsFolder no longer static

I just requested a temp license to test newest version, which I just downloaded.

When re-compiling the java code, I get an error saying that

non-static method setFontsFolder(java.lang.String,boolean) cannot be referenced from a static context

how is the FontSettings class supposed to be used now?

Hi Matteo,


Thanks for your inquiry. We have tested setFontsFolder method as following from a static method using Aspose.Words for Java 17.4 and unable to notice the reported issue. Hopefully it will help you to resolve the issue. However, if the issue persists then please share your sample code to replicate the issue. We will look into it and will guide you accordingly.

public static void DOCtoPDF() throws Exception{<o:p></o:p>

FontSettings.getDefaultInstance().setFontsFolder("/home/tilal/Fonts", true);

com.aspose.words.Document docx = new com.aspose.words.Document(“sample.doc”);<o:p></o:p>

docx.save(“sample.pdf”);<o:p></o:p>

}


Best Regards,

The previously working code is as simple as:

FontSettings.setFontsFolder(’/my/fonts/folder’, true);

but it seems that setFontsFolder is no longer a static method, now is an instance method.

Hi Matteo,


Thanks for your feedback. We are unable to notice any error while using FontSettings object as following in a static method. Furthermore, please check API reference of FontSettings class for more details. However if the issue persists then please share a sample complete Java code to replicate the issue at our end.

com.aspose.words.Document docx = new
com.aspose.words.Document(
“sample.doc”);<o:p></o:p>

FontSettings fontsetting= new FontSettings();

fontsetting.setFontsFolder("/home/tilal/Fonts", true);

....


We are sorry for the inconvenience.

Best Regards,

Hi,

perhaps I didn’t phrase my issue correctly.

The problem is NOT using the setFontsFolder in a static method; but rather that setFontsFolder used to be a static method itself, to be called like FontSettings.setFontsFolder(…), while now it has become an instance method, and I do not understand how should it be used now.

Hi Matteo,


Thanks for your feedback. Please note by default all documents use single static font settings instance. It could be accessed by DefaultInstance property, getDefaultInstance(). This instance is used by default in a document unless Document.FontSettings is specified. Hopefully it will help you to accomplish the task.

FontSettings.getDefaultInstance().setFontsFolder("/home/tilal/Fonts", true);


Best Regards,