public class FontConfigSubstitutionRule extends FontSubstitutionRule
To learn more, visit the Working with Fonts documentation article.
Remarks:
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.
Examples:
Shows operating system-dependent font config substitution.
FontSettings fontSettings = new FontSettings();
FontConfigSubstitutionRule fontConfigSubstitution = fontSettings.getSubstitutionSettings().getFontConfigSubstitution();
// The FontConfigSubstitutionRule object works differently on Windows/non-Windows platforms.
// On Windows, it is unavailable.
if (SystemUtils.IS_OS_WINDOWS) {
Assert.assertFalse(fontConfigSubstitution.getEnabled());
Assert.assertFalse(fontConfigSubstitution.isFontConfigAvailable());
}
// On Linux/Mac, we will have access to it, and will be able to perform operations.
if (SystemUtils.IS_OS_LINUX) {
Assert.assertTrue(fontConfigSubstitution.getEnabled());
Assert.assertTrue(fontConfigSubstitution.isFontConfigAvailable());
fontConfigSubstitution.resetCache();
}
| Modifier and Type | Method and Description |
|---|---|
boolean |
isFontConfigAvailable()
Check if fontconfig utility is available or not.
|
void |
resetCache()
Resets the cache of fontconfig calling results.
|
void |
setEnabled(boolean value)
Specifies whether the rule is enabled or not.
|
getEnabled, getSyncRootpublic void setEnabled(boolean value)
Examples:
Shows operating system-dependent font config substitution.
FontSettings fontSettings = new FontSettings();
FontConfigSubstitutionRule fontConfigSubstitution = fontSettings.getSubstitutionSettings().getFontConfigSubstitution();
// The FontConfigSubstitutionRule object works differently on Windows/non-Windows platforms.
// On Windows, it is unavailable.
if (SystemUtils.IS_OS_WINDOWS) {
Assert.assertFalse(fontConfigSubstitution.getEnabled());
Assert.assertFalse(fontConfigSubstitution.isFontConfigAvailable());
}
// On Linux/Mac, we will have access to it, and will be able to perform operations.
if (SystemUtils.IS_OS_LINUX) {
Assert.assertTrue(fontConfigSubstitution.getEnabled());
Assert.assertTrue(fontConfigSubstitution.isFontConfigAvailable());
fontConfigSubstitution.resetCache();
}
setEnabled in class FontSubstitutionRulevalue - The corresponding boolean value.public boolean isFontConfigAvailable()
Examples:
Shows operating system-dependent font config substitution.
FontSettings fontSettings = new FontSettings();
FontConfigSubstitutionRule fontConfigSubstitution = fontSettings.getSubstitutionSettings().getFontConfigSubstitution();
// The FontConfigSubstitutionRule object works differently on Windows/non-Windows platforms.
// On Windows, it is unavailable.
if (SystemUtils.IS_OS_WINDOWS) {
Assert.assertFalse(fontConfigSubstitution.getEnabled());
Assert.assertFalse(fontConfigSubstitution.isFontConfigAvailable());
}
// On Linux/Mac, we will have access to it, and will be able to perform operations.
if (SystemUtils.IS_OS_LINUX) {
Assert.assertTrue(fontConfigSubstitution.getEnabled());
Assert.assertTrue(fontConfigSubstitution.isFontConfigAvailable());
fontConfigSubstitution.resetCache();
}
public void resetCache()
Examples:
Shows operating system-dependent font config substitution.
FontSettings fontSettings = new FontSettings();
FontConfigSubstitutionRule fontConfigSubstitution = fontSettings.getSubstitutionSettings().getFontConfigSubstitution();
// The FontConfigSubstitutionRule object works differently on Windows/non-Windows platforms.
// On Windows, it is unavailable.
if (SystemUtils.IS_OS_WINDOWS) {
Assert.assertFalse(fontConfigSubstitution.getEnabled());
Assert.assertFalse(fontConfigSubstitution.isFontConfigAvailable());
}
// On Linux/Mac, we will have access to it, and will be able to perform operations.
if (SystemUtils.IS_OS_LINUX) {
Assert.assertTrue(fontConfigSubstitution.getEnabled());
Assert.assertTrue(fontConfigSubstitution.isFontConfigAvailable());
fontConfigSubstitution.resetCache();
}