Vectorize text - font issue

We are evaluating the SVG library. We are dynamically adding text to an SVG. Now, we want to vectorize the text so, it’s “embedded” in the graphic.

Quickly, I tried the online vectorize and the font was not honored. Can I expect this problem from the .NET library too. I will be test .NET in a few days but, thought I’d save time if somebody could answer.

@crich04

Can you please share a sample SVG for our reference in which you want to vectorize the text? We will test the scenario in our environment and address it accordingly.

The SVG
https://dl.source360group.com/downloads/crich/svg/svg-with-live-text.svg

A screenshot of SVG
https://dl.source360group.com/downloads/crich/svg/png-of-svg.png

Vectorized using online Aspose service
https://dl.source360group.com/downloads/crich/svg/vectorized.svg

Screenshot of vectorized svg
https://dl.source360group.com/downloads/crich/svg/png-vectorized.png

@crich04

Please find the SVG that we vectorized in our environment while using Aspose.SVG for .NET and the below code snippet:

var doc = new Aspose.Svg.SVGDocument(dataDir + "svg-with-live-text.svg");
var options = new Aspose.Svg.Saving.SVGSaveOptions();
options.VectorizeText = true;
doc.Save(dataDir + "svg-with-live-text_true.svg", options);

svg-with-live-text_true.zip (24.8 KB)

This looks great. Thank you. We will try with our evaluation version and then, make a purchase if we can verify.

Thanks,

@crich04

Sure, take your time to evaluate the API. You can also use a free 30-days temporary license to evaluate the API without any restrictions. Feel free to let us know in case you face any issues.

I’m using following code snippet to vectorize the image and the Open Sans Font is disappearing

        var imageFilePath = $"{newImageDiretoryBase}\\{request.PartnerName}-{fileType}{Path.GetExtension(fileName)}";
        var liveTextImageFilePath = $"{newImageDiretoryBase}\\{fileId}{Path.GetExtension(fileName)}";

        var svgDoc = new SVGDocument(liveTextImageFilePath);
        var options = new Aspose.Svg.Saving.SVGSaveOptions() { VectorizeText = true };
        svgDoc.Save(imageFilePath, options);

also when I convert it into a png using this 2 ways the Open Sans font gone

        var pngSaveOptions = new ImageSaveOptions();
        pngSaveOptions.Format = ImageFormat.Png;
        Converter.ConvertSVG(svgDoc, pngSaveOptions, Path.ChangeExtension(imageFilePath, "png"));

        var imageOptions = new ImageRenderingOptions();
        using (var imageFile = new ImageDevice(imageOptions, Path.ChangeExtension(imageFilePath, "png")))
        {
            svgDoc.RenderTo(imageFile);
        }

both code snippets generate me the png but in both cases the font is changed, any thougths

We already using the full version, we purchase it just to take advantage of vectorize and export functionality but is not working as we expected

@gcastro

Could you please share your sample SVG file for our reference? We will test the scenario in our environment and address it accordingly.

Here are the live text and the vectorized I’m using, we already purchase the aspose svg full version and requested the Paid support services with accointing@somnio.com.

Please as soon as you have an answer please let me know

Accenture LLP-Full Color.zip (30.0 KB)

@gcastro

We tested using the 22.6 version of the API using some code snippets that you have shared but we could not notice the issue that you mentioned. For your kind reference, all output files are also attached. outputs.zip (91.3 KB)

Could you please make sure that the required font is properly installed in the system where you are performing the conversion? In case you still face any issues, please let us know.

Hello we are using 22.6.0 version and the fonts are already installed in the dev machine and in QA server but the process is not working I’m not sure if I need somethin else to make it work, attached you can find my references in my .net project

Please as soon as you have an answer please let me know

image.png (31.2 KB)

The outputs file you inclued is not longer available

@gcastro

You can download the files from this link.

Furthermore, an investigation ticket as SVGNET-97 has been logged in our issue tracking system to investigate this case. In case you already have paid support subscription and this issue is a showstopper for you, you may please create a post in paid support forum with the reference of ticket ID. The ticket will be escalated to the highest priority and will be investigated on urgent basis.

@gcastro

Hello we are using 22.6.0 version and the fonts are already installed in the dev machine".

Aspose.SVG by default searches fonts in the %windir%\Fonts folder, but it is possible that ‘Open Sans’ fonts were installed into the folder of the local user. So as a workaround, we can suggest adding the local user fonts folder to the font search paths, like this:

var imageFilePath = OutputFolder + "result.svg";
var liveTextImageFilePath = InputFolder + "Accenture LLP-Life Text-Full Color.svg";
using (var configuration = new Configuration())
{
    var userAgentService = configuration.GetService<IUserAgentService>();
    var fontsFoloders = userAgentService.FontsSettings.GetFontsLookupFolders().ToList();
    fontsFoloders.Add(Environment.ExpandEnvironmentVariables(@"%userprofile%\AppData\Local\Microsoft\Windows\Fonts"));
    userAgentService.FontsSettings.SetFontsLookupFolders(fontsFoloders.ToArray());
    using (var svgDoc = new SVGDocument(liveTextImageFilePath, configuration))
    {
        var options = new Aspose.Svg.Saving.SVGSaveOptions() { VectorizeText = true };
        svgDoc.Save(imageFilePath, options);
    }
}

this should help, but if it doesn’t help, then you can also add an additional folder where the Open Sans font is located:

fontsFoloders.Add("path to the folder with Open Sans fonts");

We are going to wait for a response from you, but in any case, we will add %userprofile%\AppData\Local\Microsoft\Windows\Fonts to search by default in the future versions.

@gcastro

We have published version 22.7.0 which added the local Windows custom fonts folder to the list of font folders that Aspose.SVG looks at.

We believe it should fix the issue SVGNET-97.

As a bonus, 2 additional improvements have been made for text vectorization:

  • We have reduced the size of SVG files produced by text vectorization by about 2 times by using quadratic beziers instead of cubic beziers and replacing relative path commands with absolute ones;

  • We added support for loading SVG ‘dtd’ schemas directly from the Aspose.SVG assembly instead of trying to download them from online resources, which in some cases can significantly reduce the loading time of SVG documents.

The size of your ‘vectorized’ documents was reduced more than 2 times, and vectorization works faster.