apply font folder

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
윤영철
Posts: 2
Joined: 10 Oct 2016, 11:13
Contact:

apply font folder

Post by 윤영철 » 10 Oct 2016, 11:29

I am using to add the CADViewerControl to the program.
I want to open a drawing file by applying a shx font folder.

Code: Select all

cadViewerControl1.SHXForm.AddPath("E:\\test");
CADConst.DefaultSHXParameters.UseSHXFonts = true;
cadViewerControl1.LoadFile("E:\\test\\test1.dwg");
I used the code does not apply.
I would like to know how to apply the shx&ttf folder.

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: apply font folder

Post by support » 18 Oct 2016, 19:39

Hello,

This code will be enough to apply a folder with SHX fonts:

Code: Select all

cadViewerControl1.SHXForm.AddPath("E:\\test");
CADConst.DefaultSHXParameters.UseSHXFonts is set to true by default, so you may omit this line:

Code: Select all

CADConst.DefaultSHXParameters.UseSHXFonts = true;
TTF fonts are read only from the system folder c:\Windows\Fonts\. To override the usage of the SHX fonts and enable the TTF fonts, you may use the following code:

Code: Select all

cadViewerControl1.SHXForm.AddPath("E:\\test");
CADConst.DefaultSHXParameters.UseSHXFonts = false;
CADConst.DefaultSHXParameters.UseTTFFonts = true;
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

윤영철
Posts: 2
Joined: 10 Oct 2016, 11:13
Contact:

Re: apply font folder

Post by 윤영철 » 19 Oct 2016, 05:49

Please tell us what is wrong.

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using CADImport;

namespace TEST
{
    public partial class Form1 : Form
    {
        String _sampleDir;
        String _sampleFile;
        
        public Form1()
        {
            InitializeComponent();

            DirectoryInfo di = new DirectoryInfo(Application.StartupPath);

            _sampleDir = di.Parent.FullName + "\\sample";
            _sampleFile = _sampleDir + "\\sample.dwg";

        }

        // shx fonts folder
        private void button1_Click(object sender, EventArgs e)
        {
            cadViewerControl1.SHXForm.AddPath(_sampleDir);
            
            cadViewerControl1.AddSHXPaths();
        }

        // use shxfont
        private void button2_Click(object sender, EventArgs e)
        {
            CADConst.DefaultSHXParameters.UseSHXFonts = true;
            CADConst.DefaultSHXParameters.UseTTFFonts = false;
            CADConst.DefaultSHXParameters.UseMultyTTFFonts = true;

            cadViewerControl1.ReOpen();
        }

        // sample file open
        private void button3_Click(object sender, EventArgs e)
        {
            cadViewerControl1.LoadFile(_sampleFile);
        }
    }
}
I have attached sample souece, drawing file, shx font.
Attachments
TEST.zip
(72.29 KiB) Downloaded 1161 times

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: apply font folder

Post by support » 19 Oct 2016, 18:16

Hello,

Thank you for the test project.

Your code is correct, the problem is in a missing Big Font file @extfont2.shx which is used by the text style. Big Fonts are intended for displaying non-ASCII characters in Asian texts.

The file @extfont2.shx comes with CAD .NET library and can be found in the \CAD .NET 11\shx\ folder. You should copy this file to the \sample folder (or any other SHX folder added from your code).


Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply