DEV Community

Dmitry Matuzko
Dmitry Matuzko

Posted on

3 1

Introduction to Aspose.CAD, Part 6

Part 1

Part 2

Part 3

Part 4

Part 5

Aspose.CAD allows one to render a DWG file to raster image with a font other than specified in the file. Here's how to do that:

Font substitution

Fonts for text in DWG files are specified in style table objects, represented in Aspose.CAD by a CadStyleTableObject class. Collection of these objects are present in Styles property of CadImage instance. Styles have names, which can be used to differentiate them. There's an example on how to change font used by a class with particular name:

using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath))
{
    // Iterate over the items of CadStyleDictionary
    foreach (CadStyleTableObject style in cadImage.Styles)
    {
        if (style.StyleName == "Roman")
        {
            // Specify the font for one particular style
            style.PrimaryFontName = "Arial";
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

For now, that's all, stay tuned!

For more examples please visit the Aspose.CAD GitHub page. There's also Twitter and Facebook pages for news on Aspose.CAD.

Image of Datadog

Master Mobile Monitoring for iOS Apps

Monitor your app’s health with real-time insights into crash-free rates, start times, and more. Optimize performance and prevent user churn by addressing critical issues like app hangs, and ANRs. Learn how to keep your iOS app running smoothly across all devices by downloading this eBook.

Get The eBook

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay