TableSubstitutionRule Class

Table font substitution rule.

Inheritance Hierarchy

Namespace:  Aspose.Words.Fonts
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.7.0

Syntax

public class TableSubstitutionRule : FontSubstitutionRule

The TableSubstitutionRule type exposes the following members.

Properties

  NameDescription
Public propertyCode exampleEnabled
Specifies whether the rule is enabled or not.
(Inherited from FontSubstitutionRule.)

Methods

  NameDescription
Public methodCode exampleAddSubstitutes
Adds substitute font names for given original font name.
Public methodEquals (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodCode exampleGetSubstitutes
Returns array containing substitute font names for the specified original font name.
Public methodGetType (Inherited from Object.)
Public methodCode exampleLoad(Stream)
Loads table substitution settings from XML stream.
Public methodCode exampleLoad(String)
Loads table substitution settings from XML file.
Public methodLoadAndroidSettings
Loads predefined table substitution settings for Linux platform.
Public methodCode exampleLoadLinuxSettings
Loads predefined table substitution settings for Linux platform.
Public methodCode exampleLoadWindowsSettings
Loads predefined table substitution settings for Windows platform.
Public methodCode exampleSave(Stream)
Saves the current table substitution settings to stream.
Public methodCode exampleSave(String)
Saves the current table substitution settings to file.
Public methodCode exampleSetSubstitutes
Override substitute font names for given original font name.
Public methodToString (Inherited from Object.)

Remarks

This rule defines the list of substitute font names to be used if the original font is not available. Substitutes will be checked for the font name and the AltName (if any).

Examples

Shows how to access font substitution tables for Windows and Linux.
// Create a blank document and a new FontSettings object
Document doc = new Document();
FontSettings fontSettings = new FontSettings();
doc.FontSettings = fontSettings;

// Create a new table substitution rule and load the default Windows font substitution table
TableSubstitutionRule tableSubstitutionRule = fontSettings.SubstitutionSettings.TableSubstitution;
tableSubstitutionRule.LoadWindowsSettings();

// In Windows, the default substitute for the "Times New Roman CE" font is "Times New Roman"
Assert.AreEqual(new[] { "Times New Roman" }, tableSubstitutionRule.GetSubstitutes("Times New Roman CE").ToArray());

// We can save the table for viewing in the form of an XML document
tableSubstitutionRule.Save(ArtifactsDir + "Font.TableSubstitutionRule.Windows.xml");

// Linux has its own substitution table
// If "FreeSerif" is unavailable to substitute for "Times New Roman CE", we then look for "Liberation Serif", and so on
tableSubstitutionRule.LoadLinuxSettings();
Assert.AreEqual(new[] { "FreeSerif", "Liberation Serif", "DejaVu Serif" }, tableSubstitutionRule.GetSubstitutes("Times New Roman CE").ToArray());

// Save the Linux substitution table using a stream
using (FileStream fileStream = new FileStream(ArtifactsDir + "Font.TableSubstitutionRule.Linux.xml", FileMode.Create))
{
    tableSubstitutionRule.Save(fileStream);
}

See Also