xanderdin / LibreCAD_dxf2pdf_standalone

Standalone extracted version of LibreCAD's dxf2pdf tool that could be run without running X server.
GNU General Public License v2.0
11 stars 2 forks source link

Missing fonts in export #2

Closed ahrberg closed 5 years ago

ahrberg commented 5 years ago

Nice work making this package! I tried it out today and after some trouble with the build environment (never compiled LibreCad) I got it to compile and convert dxf to pdf. But I miss fonts like you mention in your article (https://xanderdin.github.io/en/post/lets-lubricate-the-wheel/).

Any idéas why? When I export to pdf using LibreCad GUI it works.

xanderdin commented 5 years ago

dxf2pdf depends on LibreCAD resources files (fonts, patterns). And it tries to find them in the same directory where the dxf2pdf binary located itself. After successful build the OUT directory should contain dxf2pdf and also resources directory. If you move or copy dxf2pdf binary to other location, make sure you also copy resources directory to the same location. It should be like this:

your_dir
        ├── dxf2pdf
        └── resources
            ├── fonts
            └── patterns

This could be the reason why your generated pdf is missing fonts.

ahrberg commented 5 years ago

Thanks for fast reply!

I just run in as in the example so my OUT directory contains the tree you describe and I start the dxf2pdf process in the OUT directory. I don't have the LibreCad master compiled so I have not yet tried the command line export from LibreCad master just this repo. And I only run the prepare.sh without a tag.

xanderdin commented 5 years ago

What operating system do you use?

I'm attaching a zip file which contains a dxf file. That drawing has two rectangles on an A4 landscape sheet. The first rectangle contains some text. The second a hatch. When I run it through dxf2pdf I get the resulting pdf (also attached)

one.zip one.pdf

Can you run dxf2pdf one.dxf on your machine and tell about the result?

ahrberg commented 5 years ago

OS: macOs 10.14.6

Used ./dxf2pdf one.dxf and got the following. I can se the out lines in the pdf but very thin. Also tried to export in LibreCAD GUI (2.1.3), with expected result with text and hash.

one.pdf

xanderdin commented 5 years ago

Hm, looks strange.

Unfortunately, I have no access to a physical computer with macOS. I'm running on Linux. It would be nice to hear from you if you would manage to build LibreCAD from master branch on macOS. But most probably you will encounter problems of doing that.

Just yesterday I was trying to build LibreCAD in the cloud macOS machine. It wasn't that easy but I finally managed it (I wouldn't recommend my approach used in the cloud for the personal computer though). If you brave enough you can try and test the resulted dmg package for MacOS from here (Artifacts button -> MacOSPackage). But please keep in mind, I never tested that package myself and don't even know if it runs at all. It is built from my LibreCAD fork, play_with_azure branch, the only differences from the current LibreCAD master are those related to Azure Pipelines build configurations.

On my side, when I get some spare time I'm gonna write Azure Pipelines configuration for building this LibreCAD_dxf2pdf_standalone project on macOS in the cloud and try to reproduce this issue in the cloud.

ahrberg commented 5 years ago

I tried out your fork build and it works. The pdf export is the same in the GUI as in the command line. But the line thickness is very thin, also text and hash is very thin. I can only see the lines in Adobe Reader, not in other PDF readers. But this must be a LibreCAD issue. I do not have this issue with thin lines in pdf export in LibreCAD 2.1.3.

PDF from running ./LibreCAD dxf2pdf one.pdf one_2.2.0-rc1-242-gc4387f10.pdf

PDF from 2.1.3 GUI one_2.1.3.pdf

xanderdin commented 5 years ago

I tried out your fork build and it works.

Oh, nice to hear that!

But this must be a LibreCAD issue. I do not have this issue with thin lines in pdf export in LibreCAD 2.1.3.

Though you don't have thin lines issues in 2.1.3, it may be related to https://github.com/LibreCAD/LibreCAD/issues/553 and https://github.com/LibreCAD/LibreCAD/issues/950 somehow.

ahrberg commented 5 years ago

I found the problem. Line widths defaults to 0.00 mm for me. This results in thin (basically no lines) when exporting with 2.2. In 2.1.3 it exports with line width. So for me the change in 2.2 make sense. I changed line width to 0.13 mm and then it exports fine in 2.2!

Default when opening the dxf image

Still when I build LibreCAD_dxf2pdf_standalone I only get lines, not font and hash. I'm in for helping if needed.

one_0.13_lines.pdf

one_0.13_lines.dxf.zip

xanderdin commented 5 years ago

I looked in LibreCAD sources and logs of my recent cloud builds and found that for MacOS the directory tree is different from that for Linux. Please, create the following structure and see if it helps (also note, the Resources directory starts from capital R):

your_dir
    ├── MacOS
    │   └── dxf2pdf
    └── Resources
        ├── fonts
        └── patterns
xanderdin commented 5 years ago

I tested it in the cloud and now can confirm that this is MacOS resources location issue. I added a patch to remove the difference and made it the same as on Linux (#3). Now both on Linux and MacOS the same directory tree is valid:

.
├── dxf2pdf
└── resources
    ├── fonts
    └── patterns

@ahrberg, thank you for reporting the issue!

ahrberg commented 5 years ago

Thank you for fixing this!

I can also confirm the export is working with font and hash.

jwoehrle commented 4 years ago

I ran into the same problem with printing a dxf with a hatch... The hatch was not included in the pdf.

Copying resources subdirectory to location of execution fixed the issue. Thanks a lot !