The problem when exporting DWG to SVG

Hello. I faced the problem when trying to export DWG to SVG. I use the Aspose.CAD for Java version 19.5.
The problem is “Caused by: com.aspose.cad.internal.Exceptions.InvalidOperationException: Cannot find table ‘loca’ in the font file.”. It appears only on a remote server, everything is ok on a local machine. It seems that the problem is in the lack of required fonts on the server. But I even don’t know what fonts are missed, the exception description does not have such information.
Is there a way to use any fonts provided by the OS? Moreover, I don`t need any text in the output SVG file.

@hliakau

I suggest you to please first try using latest available, Aspose.CAD for Java 20.12 on your end with all fonts that are used in DWG. If there is still an issue then please share the source DWG file reproducing the issue along with source code and stack trace with us. Secondly, you can compare the fonts by simply validating the fonts that are available on machine where rendering is fine to where it is not rendering well. There is no option in API to skip the text part in exported output. Although, It allows to select the layers that you want to be part of exported output.

In this case, is there a way to replace all the fonts in the file with a specific one, for example, Arial?

@hliakau

You can load the CadImage and then may try following sample code to replace the font to desired.

// way to redefine used font name for styles
foreach (CadStyleTableObject style in cadImage.Styles)
{
   style.PrimaryFontName = "Arial";
}

and this

foreach (CadStyleTableObject styleTable in cadImage.Styles)
                        {
                            styleTable.PrimaryFontName = "ARIALUNI.TTF";
                            CadXdata xdata = styleTable.XdataContainer.GetAcadData();
                            if (xdata != null && xdata.DataList.Count > 0)
                            {
                                for (int i = 0; i < xdata.DataList.Count; i++)
                                {
                                    if (xdata.DataList[i].Code == (int)CadEntityAttribute.Cad1000
                                        && xdata.DataList[i].GetStringValue() != "AnnotativeData")
                                    {
                                        string fullFontName = xdata.DataList[i].GetStringValue();
                                        if (!string.IsNullOrEmpty(fullFontName))
                                        {
                                            xdata.DataList[i].Value = "Arial Unicode MS";
                                            break;
                                        }
                                    }
                                }
                            }
                        }