public class FontSubstitutionReason
extends java.lang.Object
Examples:
Shows how to get additional information about font substitution.
Document doc = new Document(getMyDir() + "Rendering.docx");
WarningInfoCollection callback = new WarningInfoCollection();
doc.setWarningCallback(callback);
FontSettings fontSettings = new FontSettings();
fontSettings.getSubstitutionSettings().getDefaultFontSubstitution().setDefaultFontName("Arial");
fontSettings.setFontsFolder(getFontsDir(), false);
fontSettings.getSubstitutionSettings().getTableSubstitution().addSubstitutes("Arial", "Arvo", "Slab");
doc.setFontSettings(fontSettings);
doc.save(getArtifactsDir() + "FontSettings.SubstitutionWarnings.pdf");
FontSubstitutionWarningInfo warningInfo = (FontSubstitutionWarningInfo)callback.get(0);
Assert.assertEquals(WarningSource.LAYOUT, warningInfo.getSource());
Assert.assertEquals(WarningType.FONT_SUBSTITUTION, warningInfo.getWarningType());
Assert.assertEquals(FontSubstitutionReason.TABLE_SUBSTITUTION_RULE, warningInfo.getReason());
Assert.assertEquals("Font \'Arial\' has not been found. Using \'Arvo\' font instead. Reason: table substitution.", warningInfo.getDescription());
Assert.assertTrue(warningInfo.getRequestedBold());
Assert.assertFalse(warningInfo.getRequestedItalic());
Assert.assertEquals("Arial", warningInfo.getRequestedFamilyName());
| Modifier and Type | Field and Description |
|---|---|
static int |
ALTERNATIVE_NAME
Font substitution by alternative name from the document.
|
static int |
DEFAULT_FONT_SUBSTITUTION_RULE
Font substitution by default font rule.
|
static int |
FIRST_AVAILABLE_FONT
Font substitution with the first available font.
|
static int |
FONT_CONFIG_SUBSTITUTION_RULE
Font substitution by font config rule.
|
static int |
FONT_INFO_SUBSTITUTION_RULE
Font substitution by font info rule.
|
static int |
FONT_NAME_SUBSTITUTION_RULE
Font substitution by font name rule.
|
static int |
length |
static int |
TABLE_SUBSTITUTION_RULE
Font substitution by table rule.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
fromName(java.lang.String fontSubstitutionReasonName) |
static java.lang.String |
getName(int fontSubstitutionReason) |
static int[] |
getValues() |
static java.lang.String |
toString(int fontSubstitutionReason) |
public static int ALTERNATIVE_NAME
public static int FONT_NAME_SUBSTITUTION_RULE
public static int FONT_CONFIG_SUBSTITUTION_RULE
public static int TABLE_SUBSTITUTION_RULE
public static int FONT_INFO_SUBSTITUTION_RULE
public static int DEFAULT_FONT_SUBSTITUTION_RULE
public static int FIRST_AVAILABLE_FONT
public static int length