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

Free Support Forum - aspose.com

Aspose.Slides is not processing different custom fonts

We have uploaded some custom fonts (Myraid Pro) so that when the uploaded PDF document has got the embedded custom font then it gets picked up and process. Aspose process them fine when the font family has got different font name eg. Arquitecta Bold, Arquitecta Italic, Arquitecta whereas when we upload custom font family which has got same font name for all fonts in the font family eg. Myraid font name for all family like bold, italic etc. In the later case, Aspose only processes the Myraid regular but ignores other font family. I have attached the Myraid font family for reference. Can you please let us know whether there is a way to overcome this?
Myriad Pro (1).zip (393.6 KB)

@publishinteractive

Would you kindly also share a sample source PDF along with the sample code snippet that you are using to process it? We will test the scenario in our environment and address it accordingly.

I have attached the sample source2020 NA POS Study - Rev A.zip (6.2 MB)
ppt

The code that we use is

async Task CopyOrEmbedFonts()
{
if (FileExtension.FromPath(request.DisplayName).IsPowerpoint())
{
using var presentation = await this.ReadPresentationOrDefaultAsync(sourcePath, cancellationToken);
if (presentation == null)
{
return false;
}

                    if (this.powerpointFontEmbedder.EmbedFonts(presentation))
                    {
                        var saveFormat = FileExtension.FromPath(request.DisplayName) == FileExtension.Ppt
                            ? SaveFormat.Ppt
                            : SaveFormat.Pptx;

                        using var updatedPresentation = new MemoryStream();

                        presentation.Save(updatedPresentation, saveFormat);
                        updatedPresentation.Position = 0;

                        await this.cloudFileSystem.UploadFileAsync(file.Path, updatedPresentation);
                        return true;
                    }
                }

public bool EmbedFonts(Presentation presentation)
{
var fontPath = this.serverPathResolver.ResolvePath("~/Resources/CustomFonts/");
var possibleFonts = this.GetTenantFonts(this.fileSystem.ReadAllText(Path.Combine(fontPath, “manifest.json”)));
var presentationFonts = presentation.FontsManager.GetFonts().Select(f => f.FontName).Except(presentation.FontsManager.GetEmbeddedFonts().Select(f => f.FontName));
var fontsToEmbed = possibleFonts.Keys
.Intersect(presentationFonts, StringComparer.InvariantCultureIgnoreCase)
.ToList();

        foreach (var font in fontsToEmbed)
        {
            var fontData = this.fileSystem.ReadAllBytes(Path.Combine(fontPath, possibleFonts[font]));
            presentation.FontsManager.AddEmbeddedFont(fontData, EmbedFontCharacters.All);
        }

        return fontsToEmbed.Any();
    }

@publishinteractive,
Thank you for the issue description. Unfortunately, we cannot use your code snippet containing many unknown variables. Please check the issue with the latest version of Aspose.Slides and try to use FontLoader for external fonts as shown below:

var fontFolders = new String[] { fontFolder };
FontsLoader.LoadExternalFonts(fontFolders);

// converting a presentation
// ...

FontsLoader.ClearCache();

Documents: Custom Font
API Reference: FontsLoader Class

If the issue persists, please share and specify the following:

  • comprehensive code example or simple project
  • your output file after embedding fonts
  • screenshots indicating the problems
  • OS version on which this issue appears

Can you please let us know which property of the font e.g font family name or fullname or compatible full you take to process the ppt file to embed the font. I tried that you mentioned using fontLoader but still it doesn’t work for bold fonts. I was trying to edit some property of the font using fontForge application but still it didn’t pick up

image.jpg (162.5 KB)

@publishinteractive

Can you please elaborate the requirement in detail along with source code, source file, generated output and snapshot of issue that you are facing.