dxf-viewer icon indicating copy to clipboard operation
dxf-viewer copied to clipboard

There are deficiencies in the HATCH - related rendering, and the FONT does not wrap.

Open hqbHawke opened this issue 5 months ago • 7 comments

Image Image

hqbHawke avatar Aug 04 '25 14:08 hqbHawke

Some sample file needed. It may be some synthetic minimalistic sample illustrating some particular problem.

vagran avatar Aug 05 '25 06:08 vagran

Of course, I'm happy to provide them. Here are the drawings with bugs. https://aigc-1364883968.cos.ap-guangzhou.myqcloud.com/aigc/2025/08/05/00971c0ae2844f0dab39832f2058b4f0.dxf

hqbHawke avatar Aug 05 '25 14:08 hqbHawke

Complex hatch wont stable render due to unstable tesseltaion. earcut that used for tesselation not handle a lot of cases when fill contours intersected or collinear themself, or when one of point included in more that 1 contour.

For that i use tess2 ( GNU TESS implementation)

@hqbHawke You can check my fork and if ok i going to make PR.

https://github.com/eXponenta/dxf-viewer/

Sample:

Image

Source: complex.zip

About mtext: its to hard stable resolve mtext wrapping in Japanese/Chinese/Hundi and all Arabic languages due to hieroglyphics and ligatures. Only browser know layout rules for that languages. This is because when you decompose non-ASCII based text it can be broken ( ligatures and hieroglyphics is 2+ byte long and if you split one then you may got 2 another different characters)

eXponenta avatar Aug 14 '25 09:08 eXponenta

@hqbHawke

Image

eXponenta avatar Aug 14 '25 10:08 eXponenta

@hqbHawke

图像

The analysis of "hatch" seems correct. For the mtext entity, there will be a font width corresponding to 40 in the parsed result. We can recognize this width to achieve automatic line wrapping. I have made adjustments based on your work, and now it can be parsed normally. You can try this approach

hqbHawke avatar Aug 15 '25 01:08 hqbHawke

@eXponenta

Image It can be seen that the text line breaks are displayed correctly. then,The issue with the text lies in the encoding format. Some use GBK while others use UTF-8. You can adopt certain methods to identify the file encoding, as I notice you're using UTF-8 by default for all files.

hqbHawke avatar Aug 15 '25 01:08 hqbHawke

@hqbHawke Yep, encoding existing in document header. There are a way got it before parsing stage and redecode file in new code page.

This require rewrite DXFFetcher and insert to it validation pass.

Currently DXFFetcher always read files as utf-8. By spec a DXF greater than 2004 is always utf-8. Can you check that ezdxf also parse it correctly)?

https://ezdxf.readthedocs.io/en/stable/dxfinternals/fileencoding.html

eXponenta avatar Aug 15 '25 04:08 eXponenta