Set font for the text on Chart title in C#

We have already shown you how to set font for the text on Chart legend and Chart Axis in C# by using Spire.Presentation. This article will focus on demonstrating how to set font for text on chart title in C#.

Here comes the code snippets:

Step 1: Create a presentation instance and load the document from file.

Presentation presentation = new Presentation();
presentation.LoadFromFile("sample.pptx", FileFormat.Pptx2010);

Step 2: Get the chart that need to be formatted the font for the text on chart title.

IChart chart = presentation.Slides[0].Shapes[0] as IChart;

Step 3: Set the font for the text on chart title area.

chart.ChartTitle.TextProperties.Paragraphs[0].DefaultCharacterProperties.LatinFont = new TextFont("Arial Unicode MS");
chart.ChartTitle.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.SolidColor.KnownColor = KnownColors.Blue;
chart.ChartTitle.TextProperties.Paragraphs[0].DefaultCharacterProperties.FontHeight = 50;

Step 4: Save the document to file:

presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);

Effective screenshot after formatting the font for the chart title.

Set font for the text on Chart title in C#

Full codes:

using Spire.Presentation;
using Spire.Presentation.Charts;

namespace SetFont
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation presentation = new Presentation();
            presentation.LoadFromFile("sample.pptx", FileFormat.Pptx2010);

            IChart chart = presentation.Slides[0].Shapes[0] as IChart;

            chart.ChartTitle.TextProperties.Paragraphs[0].DefaultCharacterProperties.LatinFont = new TextFont("Arial Unicode MS");
            chart.ChartTitle.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.SolidColor.KnownColor = KnownColors.Blue;
            chart.ChartTitle.TextProperties.Paragraphs[0].DefaultCharacterProperties.FontHeight = 50;

            presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);
        }
    }
}