com.aspose.words
Class FontConfigSubstitutionRule

java.lang.Object
  extended by FontSubstitutionRule
      extended by com.aspose.words.FontConfigSubstitutionRule

public class FontConfigSubstitutionRule 
extends FontSubstitutionRule

Font config substitution rule.

This rule uses fontconfig utility on Linux (and other Unix-like) platforms to get the substitution if the original font is not available.

If fontconfig utility is not available then this rule will be ignored.

Example:

Shows OS-dependent font config substitution.
// Create a new FontSettings object and get its font config substitution rule
FontSettings fontSettings = new FontSettings();
FontConfigSubstitutionRule configSubstitution = fontSettings.getSubstitutionSettings().getFontConfigSubstitution();

// The FontConfigSubstitutionRule object works differently on Windows/non-Windows platforms
final String OS = System.getProperty("os.name").toLowerCase();

// On Windows, it is unavailable
if (OS == "win") {
    Assert.assertFalse(configSubstitution.getEnabled());
    Assert.assertFalse(configSubstitution.isFontConfigAvailable());
}

// On Linux/Mac, we will have access and will be able to perform operations
if (OS == "nix") {
    Assert.assertTrue(configSubstitution.getEnabled());
    Assert.assertTrue(configSubstitution.isFontConfigAvailable());

    configSubstitution.resetCache();
}

Property Getters/Setters Summary
voidsetEnabled(boolean value)
           Specifies whether the rule is enabled or not.
 
Method Summary
booleanisFontConfigAvailable()
           Check if fontconfig utility is available or not.
voidresetCache()
           Resets the cache of fontconfig calling results.
 

Property Getters/Setters Detail

setEnabled

public void setEnabled(boolean value)
Specifies whether the rule is enabled or not.

Example:

Shows OS-dependent font config substitution.
// Create a new FontSettings object and get its font config substitution rule
FontSettings fontSettings = new FontSettings();
FontConfigSubstitutionRule configSubstitution = fontSettings.getSubstitutionSettings().getFontConfigSubstitution();

// The FontConfigSubstitutionRule object works differently on Windows/non-Windows platforms
final String OS = System.getProperty("os.name").toLowerCase();

// On Windows, it is unavailable
if (OS == "win") {
    Assert.assertFalse(configSubstitution.getEnabled());
    Assert.assertFalse(configSubstitution.isFontConfigAvailable());
}

// On Linux/Mac, we will have access and will be able to perform operations
if (OS == "nix") {
    Assert.assertTrue(configSubstitution.getEnabled());
    Assert.assertTrue(configSubstitution.isFontConfigAvailable());

    configSubstitution.resetCache();
}

Method Detail

isFontConfigAvailable

public boolean isFontConfigAvailable()
Check if fontconfig utility is available or not.

Example:

Shows OS-dependent font config substitution.
// Create a new FontSettings object and get its font config substitution rule
FontSettings fontSettings = new FontSettings();
FontConfigSubstitutionRule configSubstitution = fontSettings.getSubstitutionSettings().getFontConfigSubstitution();

// The FontConfigSubstitutionRule object works differently on Windows/non-Windows platforms
final String OS = System.getProperty("os.name").toLowerCase();

// On Windows, it is unavailable
if (OS == "win") {
    Assert.assertFalse(configSubstitution.getEnabled());
    Assert.assertFalse(configSubstitution.isFontConfigAvailable());
}

// On Linux/Mac, we will have access and will be able to perform operations
if (OS == "nix") {
    Assert.assertTrue(configSubstitution.getEnabled());
    Assert.assertTrue(configSubstitution.isFontConfigAvailable());

    configSubstitution.resetCache();
}

resetCache

public void resetCache()
Resets the cache of fontconfig calling results.

Example:

Shows OS-dependent font config substitution.
// Create a new FontSettings object and get its font config substitution rule
FontSettings fontSettings = new FontSettings();
FontConfigSubstitutionRule configSubstitution = fontSettings.getSubstitutionSettings().getFontConfigSubstitution();

// The FontConfigSubstitutionRule object works differently on Windows/non-Windows platforms
final String OS = System.getProperty("os.name").toLowerCase();

// On Windows, it is unavailable
if (OS == "win") {
    Assert.assertFalse(configSubstitution.getEnabled());
    Assert.assertFalse(configSubstitution.isFontConfigAvailable());
}

// On Linux/Mac, we will have access and will be able to perform operations
if (OS == "nix") {
    Assert.assertTrue(configSubstitution.getEnabled());
    Assert.assertTrue(configSubstitution.isFontConfigAvailable());

    configSubstitution.resetCache();
}

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.