Free Support Forum - aspose.com

SVG insert to slide: Losing embedded font information on machine where used font not installed (.NET Core)

I am embedding an SVG image in a slide that has a Roboto-Regular font. When I run the code the first time, the font is not correct. The second time I run the same code the font is correct and the output file is larger. See the attached pptx files. Note that the font is not installed on the computer. If it is installed, it worksSVGInsertProblem.zip (133.7 KB)
.
My code is a simple .net Core 2.1 console app. The Roboto-Regular.ttf file is embedded as a resource. I attached the file for your convenience.

Here is my code. Notice I just call the same method twice. For some reason the second time works, but the first does not.

namespace TestAspose
{//https://docs.aspose.com/display/slidesnet/Manipulating+Text
class Program
{
static void Main(string[] args)
{

        CreatePPT(@"c:\asposetest\wrong-font.pptx");//First time the font is wrong
        CreatePPT(@"c:\asposetest\correct-font.pptx");//Second time the font is correct           

        void CreatePPT(string fileName)
        {
            using (Presentation presentation = new Presentation())
            {
                License license = new License();
                license.SetLicense("Aspose.Slides.lic");
                string svgContent = "<svg width='500' height='500'><g transform='translate(100,100)'><text id='TextElement' x='0' y='0' style='font-family:Roboto;font-size:24'>My SVG With Roboto</text></g></svg>";

                ISvgImage svgImage = new SvgImage(svgContent);
                var emfImage = presentation.Images.AddImage(svgImage);
                presentation.Slides[0].Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, emfImage.Width, emfImage.Height, emfImage);

                MemoryStream stream = new MemoryStream();
                Assembly asm = Assembly.GetExecutingAssembly();
                using (Stream resourceStream = asm.GetManifestResourceStream("TestAspose.Roboto-Regular.ttf"))
                {
                    byte[] fontData = new byte[resourceStream.Length];

                    resourceStream.Read(fontData, 0, fontData.Length);
                    FontsLoader.LoadExternalFont(fontData);
                }
                
                presentation.Save(fileName, SaveFormat.Pptx);
            }
        }
    }       
}

}

@kevin.brashear.gartn,

I have observed the issue shared by you. An issue with ID SLIDESNET-41677 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.