Hello,
The subject is quite similar to this topic I created few months ago, but with a different outcome: Incorrect render of text with font from Aptos family
My customer is using the font Montserrat in his workbook.
When the range is rendered to an EMF file using Aspose.Cells, the Montserrat font is not used for all cells.
You can see the result of the image created in this screenshot, after copying the EMF to a PowerPoint slide:
image-copied-in-PPT.png (32,0 Ko)
The image shows that on the 3 first rows, the Arial font is used for the numbers (while the texts on the left is using the Montserrat font), and starting from the middle of the 4th row, the Montserrat font is used.
There is my code to generate the image:
public static void ExportToImage(string sourceDocument, string worksheetName, string destinationFile, string rangeAddress)
{
Console.WriteLine(@"Montserrat is available: " + FontConfigs.IsFontAvailable("Montserrat")); // returns true
string winFontCacheFolder =
System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft", "FontCache");
FontConfigs.SetFontFolder(winFontCacheFolder, true);
Console.WriteLine(@"Montserrat is available: " + FontConfigs.IsFontAvailable("Montserrat")); // returns true
Workbook asposeWorkbook = new Workbook(sourceDocument);
var asposeSheet = asposeWorkbook.Worksheets[worksheetName];
var range = asposeSheet.Cells.CreateRange(rangeAddress);
ImageOrPrintOptions options = new ImageOrPrintOptions()
{
ImageType = ImageType.OfficeCompatibleEmf,
OnlyArea = true,
Transparent = true,
DefaultFont = "Arial",
HorizontalResolution = 600,
VerticalResolution = 600,
};
asposeSheet.PageSetup.PrintArea = range.RefersTo;
asposeSheet.PageSetup.CustomPaperSize(MeasureUnitsHelper.PointToInch(range.Width), MeasureUnitsHelper.PointToInch(range.Height));
var renderer = new SheetRender(asposeSheet, options);
renderer.ToImage(0, destinationFile);
}
What is interesting here is that if I comment the line that sets the default font to Arial DefaultFont = "Arial", from ImageOrPrintOptions, then the image is correctly rendered with the Montserrat font everywhere.
The following zip file contains the source workbook you can use to reproduce the issue, alongside with two EMF files, one with DefaultFont being set (image-with-arial.emf), and the second with the this property not being set (image-without-arial.emf).
montserrat.zip (15,2 Ko)
I am using the latest version of Aspose.Cells at the moment: 26.1.0.