We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Font Settings ChartArea

How can I insert a font from the file? I would like to change the font of a pie chart


You can install the font files (e.g., .ttf files) on the system. Alternatively, you may place the font files into your desired folder and set the folder path while configuring the font files at the start (if you are rendering spreadsheet). Now if you change the font for different objects of Pie chart in code (via Aspose.Cells API), it will be effective.


Ok, but I didn’t understand one thing. How do I set my font?

		// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
	// The path to the documents directory.

	String dataDir = Report.getDataDir(Report.class);
	// Defining string variables to store paths to font folders & font file
	String fontFolder1 = dataDir;
	String fontFile = dataDir + File.separator+ "GothicA1-Regular.ttf";

	// Setting first font folder with setFontFolder method
	// Second parameter directs the API to search the sub folders for font files
	FontConfigs.setFontFolder(fontFolder1, true);

	// Setting both font folders with setFontFolders method
	// Second parameter prohibits the API to search the sub folders for font files
	FontConfigs.setFontFolders(new String[] { fontFolder1}, false);

	// Defining FolderFontSource
	FontSourceBase sourceFolder = new FolderFontSource(fontFolder1, false);

	// Defining FileFontSource
	FileFontSource sourceFile = new FileFontSource(fontFile);

	// Defining MemoryFontSource
	byte[] bytes = Files.readAllBytes(new File(fontFile).toPath());
	FontSourceBase sourceMemory = new MemoryFontSource(bytes);

	// Setting font sources
	FontConfigs.setFontSources(new FontSourceBase[] { sourceFolder, sourceFile, sourceMemory });


what name should I put?


You need to specify the name of the font, e.g. “Arial”, “Calibri”, “Times New Roman”, “Tahoma”, “MS Gothic”, etc.

So in my case what name should I put? GothicA1-Regular? My file name?


I am not entirely sure about it. Apparently, you may put “GothicA1-Regular” as font name. But again if you have renamed the font file name already, then you may try to to use original name, e.g., “MS Gothic”, etc.

It’s always nice to share solutions.
I solved:
putting in the name of the font, the name I found inside the .tff file


Good to know that your issue is sorted out now. In the event of further queries or issue, feel free to write us back.