Text style question

Hi,

How can I set text style using Aspose.CAD library? I want to make text bold, italic, strikeout or underlined.

Thanks

@AlexBilakovskyi

Can you please share the details of your requirements in the form of sample file so that we may help you better in this regard.

@mudassir.fayyaz

Here is what I would like to achieve. Screenshoot and .dwg file attached. Is it possible to do this programmatically?

Thanks,
example.zip (12.3 KB)
textStyle.png (2.4 KB)

@AlexBilakovskyi

We need to assess the requirements and for that I have created a ticket with ID CADNET-1353 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be addressed.

@AlexBilakovskyi

Using latest version of Aspose.CAD, MText entity has FullClearText property that returns text without formatting symbols. Also, Text property is text with formatting keycodes. The following code sample to set MText entity text style properties

using (CadImage cadImage = (CadImage)Image.Load(fileName))
  {
    foreach (ICadBaseEntity entity in cadImage.Entities)
      {
       if (entity is CadMText)
          {
            CadMText mtext = entity as CadMText;            

            // \\L - underlined
            string underlined = "{\\LTesting}";

            // \\fArial - font name, b1 - bold (b0 not bold), i1 - italic (i0 - not italic)
            string bold_italic = "{\\fArial|b1|i1;text}";

            mtext.Text = underlined +" "+ bold_italic;
           }
      }
  }

@mudassir.fayyaz

Looks like it works! Thanks for your help. Appreciate it a lot!

@AlexBilakovskyi

It’s good to know that suggested option has worked on your end.