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

Free Support Forum - aspose.com

How to migrate FontSettings API from 15.11 to 16.12

Hi,
We are currently using Aspose Words Java 15.11 API in one of our components…

We want to migrate to latest Aspose Words Java library which is currently 16.12.

When we are migrating, we getting compilation errors in FontSettings code…

Below provided the sample code and corresponding compilation errors:


//// Code written with Aspose Words Java 15.11:

public static void main(String[] args) throws Exception {
License license = new License();
license.setLicense(“Aspose.Words.lic”);
// Font settings.
FontSourceBase[] fontSources = new FontSourceBase[] { new FolderFontSource("/Fonts", true) };
String missingFontName = “Font1”;
String[] fontsToSubstitute = new String[] { “NewFont1” };
// Setup font settings.
FontSettings.setFontsSources(fontSources);
String[] currentFontSubstitutes = FontSettings.getFontSubstitutes(missingFontName);
System.out.println("currentFontSubstitutes: " + currentFontSubstitutes);
FontSettings.setFontSubstitutes(missingFontName, fontsToSubstitute);
}


//// Errors for above code with Aspose Words Java 16.12:


  • Error(33,21): non-static method setFontsSources(com.aspose.words.FontSourceBase[]) cannot be referenced from a static context
  • Error(34,55): non-static method getFontSubstitutes(java.lang.String) cannot be referenced from a static context
  • Error(36,21): non-static method setFontSubstitutes(java.lang.String,java.lang.String...) cannot be referenced from a static context



Earlier in 15.11 version, these methods are static methods in FontSettings class…
Now they no longer static methods…

How to migrate this code for 16.12?

Can you please provide the code changes that works for 16.12? with retaining the functionality.

Thanks,
-Satya

Hi Satya,

Thanks for your inquiry. All methods of FontSettings class made instance methods. Static methods are replaced with static DefaultInstance property. This is a breaking change in Aspose.Words 16.1.0. Please read the detail from here:
Public API Changes in Aspose.Words 16.1.0

Moreover, please read about public API changes in Aspose.Words' version released in 2016 from here:
Release Notes - 2016

Ok got it. Thanks for clarification.