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

Free Support Forum - aspose.com

How to use custom fonts?

Dear everyone,

We are trying to generate PDF files from our DWGs and we could not set our own ttf font. How can we do that?

Unfortunately the

CadImage::setDefaultFont("fontname")

does not work.
We tried to override the fonts in the styles that are in use in DWG file, without any success:

CadStylesList styles = image.getStyles();
for ( Object obj : styles )
{
   CadStyleTableObject style = (CadStyleTableObject)obj;
   if ( style.getPrimaryFontName() != null && lcFontReplacement.containsKey( style.getPrimaryFontName().toLowerCase() ) )
   {
        style.setPrimaryFontName( lcFontReplacement.get( style.getPrimaryFontName().toLowerCase() ));
   }
}

Any other idea?

Thanks in advance.

@m4gic,
I guess your approach with overriding is correct. What will happen if simplify:

for (CadStyleTableObject style : (Iterable) cadImage.getStyles())
{
style.setPrimaryFontName(“Arial”);
}

If it is possible, attach file here and show us what font you want to change, we will dig deeper how to do that.