FontSubstitutionReason

Inheritance: java.lang.Object

public class FontSubstitutionReason

Specifies the reason of font substitution.

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());
 

Fields

FieldDescription
ALTERNATIVE_NAMEFont substitution by alternative name from the document.
DEFAULT_FONT_SUBSTITUTION_RULEFont substitution by default font rule.
FIRST_AVAILABLE_FONTFont substitution with the first available font.
FONT_CONFIG_SUBSTITUTION_RULEFont substitution by font config rule.
FONT_INFO_SUBSTITUTION_RULEFont substitution by font info rule.
FONT_NAME_SUBSTITUTION_RULEFont substitution by font name rule.
TABLE_SUBSTITUTION_RULEFont substitution by table rule.
length

Methods

MethodDescription
fromName(String fontSubstitutionReasonName)
getName(int fontSubstitutionReason)
getValues()
toString(int fontSubstitutionReason)

ALTERNATIVE_NAME

public static int ALTERNATIVE_NAME

Font substitution by alternative name from the document.

DEFAULT_FONT_SUBSTITUTION_RULE

public static int DEFAULT_FONT_SUBSTITUTION_RULE

Font substitution by default font rule.

FIRST_AVAILABLE_FONT

public static int FIRST_AVAILABLE_FONT

Font substitution with the first available font.

FONT_CONFIG_SUBSTITUTION_RULE

public static int FONT_CONFIG_SUBSTITUTION_RULE

Font substitution by font config rule.

FONT_INFO_SUBSTITUTION_RULE

public static int FONT_INFO_SUBSTITUTION_RULE

Font substitution by font info rule.

FONT_NAME_SUBSTITUTION_RULE

public static int FONT_NAME_SUBSTITUTION_RULE

Font substitution by font name rule.

TABLE_SUBSTITUTION_RULE

public static int TABLE_SUBSTITUTION_RULE

Font substitution by table rule.

length

public static int length

fromName(String fontSubstitutionReasonName)

public static int fromName(String fontSubstitutionReasonName)

Parameters:

ParameterTypeDescription
fontSubstitutionReasonNamejava.lang.String

Returns: int

getName(int fontSubstitutionReason)

public static String getName(int fontSubstitutionReason)

Parameters:

ParameterTypeDescription
fontSubstitutionReasonint

Returns: java.lang.String

getValues()

public static int[] getValues()

Returns: int[]

toString(int fontSubstitutionReason)

public static String toString(int fontSubstitutionReason)

Parameters:

ParameterTypeDescription
fontSubstitutionReasonint

Returns: java.lang.String