Page 1 of 1

Fonts

Posted: 14 Sep 2016, 12:26
by roman
Hello,

I should change the font added programmatically, but I always get the same output.

I'd need a font whicht is very sharp when printed.

Here is my code how I add text:

Code: Select all

var mText = new CADMText
            {
                Style = new CADStyle() {
                    FontName = "Verdana",
                    Color = Color.Black,
                    Converter = cadEditorControl.Image.Converter,
                    Visibility = true
                    
                },
                Text = "Test Text!",
                Color = Color.Black,
                Point = new DPoint(50, 50, 0),
                Height = 10,
                

            };

            Image.Converter.GetSection(ConvSection.Entities).AddEntity(mText);
            Image.Converter.OnCreate(mText);
            Image.Converter.Loads(mText);
            cadEditorControl.PictureBox.Invalidate();
            cadEditorControl.Update();

Re: Fonts

Posted: 19 Sep 2016, 20:19
by support
Hello Roman,

You missed the following:

1) You should specify a name of the font file (.ttf or .shx) using a CADStyle.PrimaryFont property.
2) A new CADStyle instance must be added into the STYLES section of CADConverter.

Given the abovementioned points, you should use the following code:

Code: Select all

var style = new CADStyle()
{
    PrimaryFont = "H08.TTF",
    FontName = "Hershey Complex Script",
};
cadEditorControl.Image.Converter.GetSection(ConvSection.Styles).AddEntity(style);
cadEditorControl.Image.Converter.Loads(style);

var mText = new CADMText
{
    Style = style,
    Text = "Test Text!",
    Align = 5,
    Point = new DPoint(50, 50, 0),
    Height = 10,
    Color = Color.Black,
};

cadEditorControl.Image.Converter.GetSection(ConvSection.Entities).AddEntity(mText);
cadEditorControl.Image.Converter.Loads(mText);
cadEditorControl.Image.GetExtents();
cadEditorControl.PictureBox.Invalidate();
cadEditorControl.Update();
Mikhail

Re: Fonts

Posted: 02 Nov 2016, 15:12
by roman
Thank you, got it working now.