FontSubstitutionWarningInfo

FontSubstitutionWarningInfo class

Contains information about a font substitution warning that Aspose.Words issued during document loading or saving.

public class FontSubstitutionWarningInfo : WarningInfo

Properties

NameDescription
Description { get; }Returns the description of the warning.
Reason { get; }Font substitution reason.
RequestedBold { get; }Indicates whether bold style was requested.
RequestedFamilyName { get; }Requested font family name.
RequestedItalic { get; }Indicates whether italic style was requested.
ResolvedFont { get; }Resolved font.
Source { get; }Returns the source of the warning.
WarningType { get; }Returns the type of the warning.

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