FontAutoColor Property |
Namespace: Aspose.Words
When text has 'automatic color', the actual color of text is calculated automatically so that it is readable against the background color. As you change the background color, the text color will automatically switch to black or white in MS Word to maximize legibility.
Run run = new Run(new Document()); // Remove direct color, so it can be calculated automatically with Font.AutoColor run.Font.Color = Color.Empty; // When we set black color for background, autocolor for font must be white run.Font.Shading.BackgroundPatternColor = Color.Black; Assert.AreEqual(Color.White, run.Font.AutoColor); // When we set white color for background, autocolor for font must be black run.Font.Shading.BackgroundPatternColor = Color.White; Assert.AreEqual(Color.Black, run.Font.AutoColor);