FontSubstitutionReason

FontSubstitutionReason enumeration

Specifies the reason of font substitution.

public enum FontSubstitutionReason

Values

NameValueDescription
AlternativeName0Font substitution by alternative name from the document.
FontNameSubstitutionRule1Font substitution by font name rule.
FontConfigSubstitutionRule2Font substitution by font config rule.
TableSubstitutionRule3Font substitution by table rule.
FontInfoSubstitutionRule4Font substitution by font info rule.
DefaultFontSubstitutionRule5Font substitution by default font rule.
FirstAvailableFont6Font substitution with the first available font.

Examples

Shows how to get additional information about font substitution.

Document doc = new Document(MyDir + "Rendering.docx");

WarningInfoCollection callback = new WarningInfoCollection();
doc.WarningCallback = callback;

FontSettings fontSettings = new FontSettings();
fontSettings.SubstitutionSettings.DefaultFontSubstitution.DefaultFontName = "Arial";
fontSettings.SetFontsFolder(FontsDir, false);
fontSettings.SubstitutionSettings.TableSubstitution.AddSubstitutes("Arial", "Arvo", "Slab");

doc.FontSettings = fontSettings;
doc.Save(ArtifactsDir + "FontSettings.SubstitutionWarnings.pdf");

FontSubstitutionWarningInfo warningInfo = (FontSubstitutionWarningInfo)callback[0];
Assert.That(warningInfo.Source, Is.EqualTo(WarningSource.Layout));
Assert.That(warningInfo.WarningType, Is.EqualTo(WarningType.FontSubstitution));
Assert.That(warningInfo.Reason, Is.EqualTo(FontSubstitutionReason.TableSubstitutionRule));
Assert.That(warningInfo.Description, Is.EqualTo("Font \'Arial\' has not been found. Using \'Arvo\' font instead. Reason: table substitution."));
Assert.That(warningInfo.RequestedBold, Is.True);
Assert.That(warningInfo.RequestedItalic, Is.False);
Assert.That(warningInfo.RequestedFamilyName, Is.EqualTo("Arial"));

See Also