tarikjabiri / js-dxf

JavaScript DXF writer
MIT License
179 stars 75 forks source link

How to draw texts with Cyrillic characters #14

Closed bojko108 closed 5 years ago

bojko108 commented 5 years ago

Hello! I have problems with creating texts with Cyrillic characters. Don't think that there is really an issue with this library as it creates text entities as expected - they are drawn and the text value is set correctly. The problem is probably due to the fact that the header section is not created and the drawing code page is not set correctly.

This is the result when I open the DXF file in AutoCAD: 2019-10-14_164113 The second text, which does not use cyrillic characters is displayed.

I've created a sandbox here: https://codesandbox.io/embed/dxf-writer-text-issue-5o1of.

I've tried to set the DXF version and the code page in the header section, but with no luck:

0
SECTION
2
HEADER
9
$ACADVER
1
AC1024
9
$DWGCODEPAGE
3
ANSI_1251
0
ENDSEC
... rest of the DXF string - created with this library

But when loading in AutoCAD it gives errors and cannot be loaded. The error is:

Error in APPID Table
DXF read error on line 112.
Invalid or incomplete DXF input -- drawing discarded.

Probably the header section is missing some required parameters, but can't find more info about it. Does someone know how to correctly set these options in the header section?

ognjen-petrovic commented 5 years ago

Hi. Maybe you just need to choose a proper font? When I open your example in LibreCAD I see diamonds. I created a copy of text and changed font to unicode and got this:

image

bojko108 commented 5 years ago

Thanks, I tried and it works in LibreCAD. In AutoCAD however, it doesn't. I think the problem is thаt AutoCAD can't read the text value properly and changing the font style has no effect at all. I'll try to find more info about headers section in DXF.