DEV Community

Dmitry Matuzko
Dmitry Matuzko

Posted on

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.

Top comments (0)