Change font of chart title

Window 10 The title font of the chart running on PC is different from the title font of chart running on linux server.

Save as Html file.

I have coded the following code to change the font of the chart title, and I have also installed the font file on the linux server.


            FontConfigs.setFontFolder("/usr/share/fonts/malgun", true);
	FolderFontSource sourceFolder = new FolderFontSource("/usr/share/fonts/malgun", false);
	FileFontSource sourceFile = new FileFontSource("/usr/share/fonts/malgun/malgun.ttf");
	FileFontSource sourceFile2 = new FileFontSource("/usr/share/fonts/malgun/malgunbd.ttf");

	byte[] bytes = Files.readAllBytes(new File("/usr/share/fonts/malgun/malgun.ttf").toPath());
	MemoryFontSource sourceMemory = new MemoryFontSource(bytes);

	// Setting font sources
	FontConfigs.setFontSources(new FontSourceBase[] { sourceFolder, sourceFile, sourceMemory });
	
	bytes = Files.readAllBytes(new File("/usr/share/fonts/malgun/malgunbd.ttf").toPath());
	sourceMemory = new MemoryFontSource(bytes);
	FontConfigs.setFontSources(new FontSourceBase[] { sourceFolder, sourceFile2, sourceMemory })

            chart.get(j).getTitle().getTextFont()activeTab.setName("malgun");

            HtmlSaveOptions sv = new HtmlSaveOptions(SaveFormat.HTML);
	
	sv.setDefaultFontName("malgun");

window 10
image.png (24.0 KB)

linux
image.png (24.7 KB)


I will contact you because the font is not applied.

We also ask you how to apply the tff file directly.

@rnjswlwl3c751

Thanks for using Aspose APIs.

We need to experiment few things. Please spare us some time. We will update you asap.

@rnjswlwl3c751

Thanks for using Aspose APIs.

We have looked into your code and found you are setting font source again and again. Just this line at the beginning is ok.

FontConfigs.setFontFolder("/usr/share/fonts/malgun", true);

So, remove all these lines

FontConfigs.setFontFolder("/usr/share/fonts/malgun", true);
FolderFontSource sourceFolder = new FolderFontSource("/usr/share/fonts/malgun", false);
FileFontSource sourceFile = new FileFontSource("/usr/share/fonts/malgun/malgun.ttf");
FileFontSource sourceFile2 = new FileFontSource("/usr/share/fonts/malgun/malgunbd.ttf");

byte[] bytes = Files.readAllBytes(new File("/usr/share/fonts/malgun/malgun.ttf").toPath());
MemoryFontSource sourceMemory = new MemoryFontSource(bytes);

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

bytes = Files.readAllBytes(new File("/usr/share/fonts/malgun/malgunbd.ttf").toPath());
sourceMemory = new MemoryFontSource(bytes);
FontConfigs.setFontSources(new FontSourceBase[] { sourceFolder, sourceFile2, sourceMemory })

It should then fix your issue. If you still find any issue, then in order to investigate your issue further, please share with us your runnable sample code, sample Excel file(s) and font files. We will look into it and help you asap.

I applied the source and changed the font name.
Now the correct font is applied. Thank you.

@rnjswlwl3c751

Thanks for your feedback. It is good to know that your issue is now sorted out. Let us know if you encounter any other issue, we will be glad to look into it and help you further.